From 8f20b3433e0a9f9a3222e561ecd43462828a6a40c76c2b957e4cd75a393b04d7 Mon Sep 17 00:00:00 2001 From: Nicolas Belouin Date: Mon, 24 Feb 2025 15:44:23 +0100 Subject: [PATCH] Fix PR closed workflow Signed-off-by: Nicolas Belouin --- .gitea/workflows/pr_project.yaml | 22 +++++++++++++++++----- .gitea/workflows/sync_config.yaml | 5 ++++- .gitea/workflows/sync_meta.yaml | 7 +++++-- README.md | 15 ++------------- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/.gitea/workflows/pr_project.yaml b/.gitea/workflows/pr_project.yaml index 8d37420..dd366c2 100644 --- a/.gitea/workflows/pr_project.yaml +++ b/.gitea/workflows/pr_project.yaml @@ -1,4 +1,4 @@ -name: Synchronize Project Config +name: Build PR in OBS on: pull_request_target: types: @@ -9,11 +9,17 @@ on: branches-ignore: - "devel" +concurrency: + group: ${{ gitea.workflow }}-${{ gitea.ref }} + cancel-in-progress: true + jobs: sync-pr-project: + name: "Build PR in OBS" runs-on: tumbleweed steps: - - run: | + - name: Setup OSC + run: | zypper in -y python3-jinja2 mkdir -p ~/.config/osc cat >~/.config/osc/oscrc <<'EOF' @@ -26,22 +32,28 @@ jobs: EOF # Waiting on PR to get merged for support in upstream action/checkout action - uses: 'https://github.com/yangskyboxlabs/action-checkout@sha256' + name: Checkout repository with: object-format: 'sha256' - - run: | + - name: "[if PR is closed] Delete project in OBS" + run: | if [ "${{ gitea.event.action }}" = "closed" ]; then PROJECT="$(grep PROJECT .obs/common.py | sed 's/PROJECT = "\(.*\)"/\1/')" - osc rdelete "${PROJECT}:Staging:PR-${{ gitea.event.number }}" + osc rdelete -f -r -m "PR closed" "${PROJECT}:Staging:PR-${{ gitea.event.number }}" fi - - env: + - name: "Setup PR project in OBS" + env: SCM_URL: ${{ gitea.event.pull_request.head.repo.clone_url }}#${{ gitea.head_ref }} run: | if [ "${{ gitea.event.action }}" != "closed" ]; then PROJECT="$(grep PROJECT .obs/common.py | sed 's/PROJECT = "\(.*\)"/\1/')" python3 .obs/render_meta.py --pr ${{ gitea.event.number }} --scm-url "${SCM_URL}" | osc meta prj "${PROJECT}:Staging:PR-${{ gitea.event.number }}" -F - + echo "Project created ${PROJECT}:Staging:PR-${{ gitea.event.number }}" + echo "Follow build at: https://build.opensuse.org/project/monitor/${PROJECT}:Staging:PR-${{ gitea.event.number }}" fi - env: GIT_SHA: ${{ gitea.event.pull_request.head.sha }} + name: "Wait for OBS to build the project" run: | if [ "${{ gitea.event.action }}" != "closed" ]; then PROJECT="$(grep PROJECT .obs/common.py | sed 's/PROJECT = "\(.*\)"/\1/')" diff --git a/.gitea/workflows/sync_config.yaml b/.gitea/workflows/sync_config.yaml index e4f23fd..dfa6c77 100644 --- a/.gitea/workflows/sync_config.yaml +++ b/.gitea/workflows/sync_config.yaml @@ -9,9 +9,11 @@ on: jobs: sync-prjconf: + name: "Update prjconf in OBS" runs-on: tumbleweed steps: - - run: | + - name: Setup OSC + run: | mkdir -p ~/.config/osc cat >~/.config/osc/oscrc <<'EOF' [general] @@ -23,6 +25,7 @@ jobs: EOF # Waiting on PR to get merged for support in upstream action/checkout action - uses: 'https://github.com/yangskyboxlabs/action-checkout@sha256' + name: Checkout repository with: object-format: 'sha256' - run: | diff --git a/.gitea/workflows/sync_meta.yaml b/.gitea/workflows/sync_meta.yaml index 3c13f76..29eab1b 100644 --- a/.gitea/workflows/sync_meta.yaml +++ b/.gitea/workflows/sync_meta.yaml @@ -12,7 +12,8 @@ jobs: sync-prj-meta: runs-on: tumbleweed steps: - - run: | + - name: Setup OSC + run: | zypper in -y python3-jinja2 mkdir -p ~/.config/osc cat >~/.config/osc/oscrc <<'EOF' @@ -25,9 +26,11 @@ jobs: EOF # Waiting on PR to get merged for support in upstream action/checkout action - uses: 'https://github.com/yangskyboxlabs/action-checkout@sha256' + name: Checkout repository with: object-format: 'sha256' - - run: | + - name: "Update or create OBS Project" + run: | PROJECT="$(grep PROJECT .obs/common.py | sed 's/PROJECT = "\(.*\)"/\1/')" set -o pipefail if meta="$(osc meta prj "${PROJECT}" 2>/dev/null | sha256sum)"; then diff --git a/README.md b/README.md index 5cd009a..6becf8d 100644 --- a/README.md +++ b/README.md @@ -5,15 +5,6 @@ Contains the definition of the packages built on OBS for the SUSE Edge Solution This repository is linked to an OBS project: Every directory in this repository represents a package in that OBS project, those should be synced automatically from this repository. -## Adding a package - -To add a package, first create a directory with your package as you intend it in OBS. - -Then run the `.obs/add_package.py` script to create the package in the OBS project and add the required elements to the synchronization workflow. -This script is using the `osc` command behind the scenes, so ensure you have it installed and correctly configured, as well as you have the correct permissions to create a new package in the project. - -You will then get asked to push your changes. - ## Testing a fork or a development branch You can create a project in your home space in OBS, use the same prjconf as the one of "isv:SUSE:Edge:Factory", and copy the repositories part of the metadata (adjust self references). @@ -23,16 +14,14 @@ Then add a scmsync stanza to your metadata like this (adjust repository path and https://src.opensuse.org/suse-edge/Factory#main ``` +This is done automatically for any PR filed against this repository. + ## Cutting a release version branch 1. Do the appropriate git branch command 2. Change the project path in `.obs/common.py` file (e.g. from `isv:SUSE:Edge:Factory` to `isv:SUSE:Edge:3.2`) 3. Change the branch reference in `.obs/common.py` file (e.g. from `main` to `3.2`) -4. Edit the `.obs/workflows.yml` file to change the references to the correct projects 5. Commit those changes to the new branch and push the new branch -6. Create the base and to-test projects (e.g. `isv:SUSE:Edge:3.2` and `isv:SUSE:Edge:3.2:ToTest`), use the `isv:SUSE:Edge:Factory` projects as example for metadata part -7. Use the prjconf of Factory in all those projects -8. Run the `.obs/sync_packages.py` script to create all the packages in the base project 9. Go take a few cups of coffee/tea/mate/... while waiting for OBS to build everything 10. Once built do an `osc release` of the project for it to be copied over in the `ToTest` section 11. Hand over to QA to test whatever is in `ToTest`. (You can continue to work on the base branch if needed meanwhile)