From d59ce13442123a4f634e73b7b47ba5b3d6cd7108 Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 22:12:07 +0100 Subject: [PATCH 01/14] Fix just artifact repo --- .forgejo/workflows/auto-update.yaml | 10 +++++----- modules/services/forgejo.nix | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.forgejo/workflows/auto-update.yaml b/.forgejo/workflows/auto-update.yaml index 597d9ca..cb04339 100644 --- a/.forgejo/workflows/auto-update.yaml +++ b/.forgejo/workflows/auto-update.yaml @@ -14,7 +14,7 @@ jobs: hosts: ${{ steps.hosts.outputs.hosts }} steps: - name: Checkout repository - uses: forgejo/checkout@v4 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -61,7 +61,7 @@ jobs: host: ${{ fromJson(needs.check-updates.outputs.hosts) }} steps: - name: Checkout repository - uses: forgejo/checkout@v4 + uses: actions/checkout@v4 - name: Download updated flake.lock uses: forgejo/download-artifact@v4 @@ -77,7 +77,7 @@ jobs: - name: Upload build log on failure if: failure() || steps.build.outcome == 'failure' - uses: forgejo/upload-artifact + uses: forgejo/upload-artifact@v4 with: name: build-failure-${{ matrix.host }} path: build-output.txt @@ -96,7 +96,7 @@ jobs: runs-on: nix steps: - name: Checkout repository - uses: forgejo/checkout@v4 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -177,7 +177,7 @@ jobs: FAILED_HOSTS="\n- (Unable to determine failed hosts - check workflow logs)" fi - ISSUE_BODY="Weekly flake update failed to build some hosts.\n\n**Branch:** \`${{ steps.branch.outputs.branch_name }}\`\n**Run:** ${{ github.server_url }}/${{ github.repository }}/forgejo/runs/${{ github.run_id }}\n\n**Failed hosts:**$FAILED_HOSTS\n$FAILURE_DETAILS\n\nGenerated on: $(date -Iseconds)" + ISSUE_BODY="Weekly flake update failed to build some hosts.\n\n**Branch:** \`${{ steps.branch.outputs.branch_name }}\`\n**Run:** ${{ forge.server_url }}/${{ forge.repository }}/actions/runs/${{ forge.run_id }}\n\n**Failed hosts:**$FAILED_HOSTS\n$FAILURE_DETAILS\n\nGenerated on: $(date -Iseconds)" curl -X POST \ -H "Authorization: token $FORGEJO_TOKEN" \ diff --git a/modules/services/forgejo.nix b/modules/services/forgejo.nix index a069514..52f0ee5 100644 --- a/modules/services/forgejo.nix +++ b/modules/services/forgejo.nix @@ -88,7 +88,7 @@ in }; actions = { ENABLED = true; - DEFAULT_ACTIONS_URL = "github"; + DEFAULT_ACTIONS_URL = "https://code.forgejo.org"; ARTIFACT_RETENTION_DAYS = 90; }; } cfg.settings; -- 2.51.2 From 28e9ef6a2c3cd3977b90fce78a5c76c480cdf9c2 Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 22:15:05 +0100 Subject: [PATCH 02/14] Fix correct run number --- .forgejo/workflows/auto-update.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/auto-update.yaml b/.forgejo/workflows/auto-update.yaml index cb04339..ac5c732 100644 --- a/.forgejo/workflows/auto-update.yaml +++ b/.forgejo/workflows/auto-update.yaml @@ -177,7 +177,7 @@ jobs: FAILED_HOSTS="\n- (Unable to determine failed hosts - check workflow logs)" fi - ISSUE_BODY="Weekly flake update failed to build some hosts.\n\n**Branch:** \`${{ steps.branch.outputs.branch_name }}\`\n**Run:** ${{ forge.server_url }}/${{ forge.repository }}/actions/runs/${{ forge.run_id }}\n\n**Failed hosts:**$FAILED_HOSTS\n$FAILURE_DETAILS\n\nGenerated on: $(date -Iseconds)" + ISSUE_BODY="Weekly flake update failed to build some hosts.\n\n**Branch:** \`${{ steps.branch.outputs.branch_name }}\`\n**Run:** ${{ forge.server_url }}/${{ forge.repository }}/actions/runs/${{ forge.run_number }}\n\n**Failed hosts:**$FAILED_HOSTS\n$FAILURE_DETAILS\n\nGenerated on: $(date -Iseconds)" curl -X POST \ -H "Authorization: token $FORGEJO_TOKEN" \ @@ -186,7 +186,7 @@ jobs: \"title\": \"Build failure: weekly flake update $(date +%Y-%m-%d)\", \"body\": \"$ISSUE_BODY\" }" \ - "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/issues" + "${{ forge.server_url }}/api/v1/repos/${{ forge.repository }}/issues" - name: Cleanup if: always() -- 2.51.2 From 1cb9e1ea6ad23260ec586109bf4fab1987f4fc59 Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 22:19:39 +0100 Subject: [PATCH 03/14] Try to fix HOSTS variable --- .forgejo/workflows/auto-update.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/auto-update.yaml b/.forgejo/workflows/auto-update.yaml index ac5c732..d352ff8 100644 --- a/.forgejo/workflows/auto-update.yaml +++ b/.forgejo/workflows/auto-update.yaml @@ -40,7 +40,7 @@ jobs: if: steps.changes.outputs.changed == 'true' run: | HOSTS=$(nix eval --json .#colmena --apply 'x: builtins.filter (n: n != "meta" && builtins.elem "lxc" (x.${n}.deployment.tags or [])) (builtins.attrNames x)') - echo "hosts=$HOSTS" >> $FORGEJO_OUTPUT + echo "hosts="$HOSTS >> $FORGEJO_OUTPUT echo "Discovered hosts: $HOSTS" - name: Upload flake.lock -- 2.51.2 From e52587380c59c0d0e3e8fa8a676039868a0771d5 Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 22:26:20 +0100 Subject: [PATCH 04/14] Debug n1 --- .forgejo/workflows/auto-update.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.forgejo/workflows/auto-update.yaml b/.forgejo/workflows/auto-update.yaml index d352ff8..ae7ed50 100644 --- a/.forgejo/workflows/auto-update.yaml +++ b/.forgejo/workflows/auto-update.yaml @@ -60,6 +60,10 @@ jobs: matrix: host: ${{ fromJson(needs.check-updates.outputs.hosts) }} steps: + - name: Debug HOSTS + run: | + echo "HOSTS: " ${{ needs.check-updates.outputs.hosts }} + - name: Checkout repository uses: actions/checkout@v4 -- 2.51.2 From 4c8c2ae9f6c5dea428ab73ecb13c8a62834e4dbe Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 22:27:24 +0100 Subject: [PATCH 05/14] debug fromJson --- .forgejo/workflows/auto-update.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/auto-update.yaml b/.forgejo/workflows/auto-update.yaml index ae7ed50..8d0ce18 100644 --- a/.forgejo/workflows/auto-update.yaml +++ b/.forgejo/workflows/auto-update.yaml @@ -62,7 +62,7 @@ jobs: steps: - name: Debug HOSTS run: | - echo "HOSTS: " ${{ needs.check-updates.outputs.hosts }} + echo "HOSTS: "${{ fromJson(needs.check-updates.outputs.hosts) }} - name: Checkout repository uses: actions/checkout@v4 -- 2.51.2 From 82176e96d14f1a4198f50f03631d9f40e2edd0ab Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 22:34:29 +0100 Subject: [PATCH 06/14] try not to stripe down quotes --- .forgejo/workflows/auto-update.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/auto-update.yaml b/.forgejo/workflows/auto-update.yaml index 8d0ce18..f623c7b 100644 --- a/.forgejo/workflows/auto-update.yaml +++ b/.forgejo/workflows/auto-update.yaml @@ -40,7 +40,11 @@ jobs: if: steps.changes.outputs.changed == 'true' run: | HOSTS=$(nix eval --json .#colmena --apply 'x: builtins.filter (n: n != "meta" && builtins.elem "lxc" (x.${n}.deployment.tags or [])) (builtins.attrNames x)') - echo "hosts="$HOSTS >> $FORGEJO_OUTPUT + { + echo 'hosts<> $FORGEJO_OUTPUT echo "Discovered hosts: $HOSTS" - name: Upload flake.lock @@ -62,7 +66,7 @@ jobs: steps: - name: Debug HOSTS run: | - echo "HOSTS: "${{ fromJson(needs.check-updates.outputs.hosts) }} + echo 'HOSTS: ${{ needs.check-updates.outputs.hosts }}' - name: Checkout repository uses: actions/checkout@v4 -- 2.51.2 From 58c3ea7c6ac594d2dab88444b7739691f0e45cc3 Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 22:38:36 +0100 Subject: [PATCH 07/14] Try n3 --- .forgejo/workflows/auto-update.yaml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.forgejo/workflows/auto-update.yaml b/.forgejo/workflows/auto-update.yaml index f623c7b..a3a91a2 100644 --- a/.forgejo/workflows/auto-update.yaml +++ b/.forgejo/workflows/auto-update.yaml @@ -40,11 +40,7 @@ jobs: if: steps.changes.outputs.changed == 'true' run: | HOSTS=$(nix eval --json .#colmena --apply 'x: builtins.filter (n: n != "meta" && builtins.elem "lxc" (x.${n}.deployment.tags or [])) (builtins.attrNames x)') - { - echo 'hosts<> $FORGEJO_OUTPUT + echo "hosts=$HOSTS" >> $FORGEJO_OUTPUT echo "Discovered hosts: $HOSTS" - name: Upload flake.lock @@ -62,11 +58,11 @@ jobs: strategy: fail-fast: false matrix: - host: ${{ fromJson(needs.check-updates.outputs.hosts) }} + host: ${{ needs.check-updates.outputs.hosts }} steps: - name: Debug HOSTS run: | - echo 'HOSTS: ${{ needs.check-updates.outputs.hosts }}' + echo "HOSTS: "${{ needs.check-updates.outputs.hosts }} - name: Checkout repository uses: actions/checkout@v4 -- 2.51.2 From 5c7ef1d78133a126dc6dc2b3712d4b10f6f9b609 Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 22:44:00 +0100 Subject: [PATCH 08/14] test with github example --- .forgejo/workflows/test-matrix.yaml | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .forgejo/workflows/test-matrix.yaml diff --git a/.forgejo/workflows/test-matrix.yaml b/.forgejo/workflows/test-matrix.yaml new file mode 100644 index 0000000..97731b3 --- /dev/null +++ b/.forgejo/workflows/test-matrix.yaml @@ -0,0 +1,55 @@ +name: shared matrix +on: + push: + workflow_dispatch: + +jobs: + define-matrix: + runs-on: nix + + outputs: + colors: ${{ steps.colors.outputs.colors }} + + steps: + - name: Define Colors + id: colors + run: | + echo 'colors=["red", "green", "blue"]' >> "$GITHUB_OUTPUT" + + produce-artifacts: + runs-on: nix + needs: define-matrix + strategy: + matrix: + color: ${{ fromJSON(needs.define-matrix.outputs.colors) }} + + steps: + - name: Define Color + env: + color: ${{ matrix.color }} + run: | + echo "$color" > color + - name: Produce Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.color }} + path: color + + consume-artifacts: + runs-on: nix + needs: + - define-matrix + - produce-artifacts + strategy: + matrix: + color: ${{ fromJSON(needs.define-matrix.outputs.colors) }} + + steps: + - name: Retrieve Artifact + uses: actions/download-artifact@v5 + with: + name: ${{ matrix.color }} + + - name: Report Color + run: | + cat color -- 2.51.2 From 0a40546403ceb446ccbda8cb7ad4b4933ca82a46 Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 22:46:21 +0100 Subject: [PATCH 09/14] Prova --- .forgejo/workflows/auto-update.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/auto-update.yaml b/.forgejo/workflows/auto-update.yaml index a3a91a2..8518836 100644 --- a/.forgejo/workflows/auto-update.yaml +++ b/.forgejo/workflows/auto-update.yaml @@ -20,7 +20,7 @@ jobs: - name: Configure Git run: | - git config user.name "Flake Update Bot" + git config user.name "Flake Update Bot" git config user.email "bot@noreply.local" - name: Update flake inputs -- 2.51.2 From 4bbbd2112b2fe23aebd99d6c419b5d2b3ab8891d Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 22:48:09 +0100 Subject: [PATCH 10/14] fix action urls --- .forgejo/workflows/test-matrix.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/test-matrix.yaml b/.forgejo/workflows/test-matrix.yaml index 97731b3..1cc6e41 100644 --- a/.forgejo/workflows/test-matrix.yaml +++ b/.forgejo/workflows/test-matrix.yaml @@ -30,7 +30,7 @@ jobs: run: | echo "$color" > color - name: Produce Artifact - uses: actions/upload-artifact@v4 + uses: forgejo/upload-artifact@v4 with: name: ${{ matrix.color }} path: color @@ -46,7 +46,7 @@ jobs: steps: - name: Retrieve Artifact - uses: actions/download-artifact@v5 + uses: forgejo/download-artifact@v5 with: name: ${{ matrix.color }} -- 2.51.2 From 636491fd226143e670cfa9944d27f47dc0ba3c4d Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 22:53:17 +0100 Subject: [PATCH 11/14] FORGEJO_OUTPUT --- .forgejo/workflows/test-matrix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/test-matrix.yaml b/.forgejo/workflows/test-matrix.yaml index 1cc6e41..d634a37 100644 --- a/.forgejo/workflows/test-matrix.yaml +++ b/.forgejo/workflows/test-matrix.yaml @@ -14,7 +14,7 @@ jobs: - name: Define Colors id: colors run: | - echo 'colors=["red", "green", "blue"]' >> "$GITHUB_OUTPUT" + echo 'colors=["red", "green", "blue"]' >> "$FORGEJO_OUTPUT" produce-artifacts: runs-on: nix -- 2.51.2 From d4e5268f1c6d185b9cec3f2015e793c79852ef64 Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 22:58:18 +0100 Subject: [PATCH 12/14] Test2 --- .forgejo/workflows/test-matrix.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.forgejo/workflows/test-matrix.yaml b/.forgejo/workflows/test-matrix.yaml index d634a37..2776368 100644 --- a/.forgejo/workflows/test-matrix.yaml +++ b/.forgejo/workflows/test-matrix.yaml @@ -4,6 +4,18 @@ on: workflow_dispatch: jobs: + + test: + runs-on: nix + strategy: + matrix: + variant: ['bookworm', 'bullseye'] + node: ['18', '20'] + steps: + - uses: https://code.forgejo.org/actions/setup-node@v4 + with: + node-version: '${{ matrix.node }}' + define-matrix: runs-on: nix -- 2.51.2 From 3162e365b91d6b056f50a7c63c89226806515ca0 Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 23:09:21 +0100 Subject: [PATCH 13/14] Forgejo does not support dynamic matrix. d'ho --- .forgejo/workflows/auto-update.yaml | 152 ++++++++++++++++++++-------- .forgejo/workflows/test-matrix.yaml | 67 ------------ 2 files changed, 110 insertions(+), 109 deletions(-) delete mode 100644 .forgejo/workflows/test-matrix.yaml diff --git a/.forgejo/workflows/auto-update.yaml b/.forgejo/workflows/auto-update.yaml index 8518836..c6742b4 100644 --- a/.forgejo/workflows/auto-update.yaml +++ b/.forgejo/workflows/auto-update.yaml @@ -11,7 +11,6 @@ jobs: runs-on: nix outputs: changed: ${{ steps.changes.outputs.changed }} - hosts: ${{ steps.hosts.outputs.hosts }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -20,7 +19,7 @@ jobs: - name: Configure Git run: | - git config user.name "Flake Update Bot" + git config user.name "Flake Update Bot" git config user.email "bot@noreply.local" - name: Update flake inputs @@ -36,11 +35,18 @@ jobs: fi - name: Extract LXC hosts - id: hosts if: steps.changes.outputs.changed == 'true' run: | + set -euo pipefail HOSTS=$(nix eval --json .#colmena --apply 'x: builtins.filter (n: n != "meta" && builtins.elem "lxc" (x.${n}.deployment.tags or [])) (builtins.attrNames x)') - echo "hosts=$HOSTS" >> $FORGEJO_OUTPUT + + # Validate the output is a non-empty JSON array + if ! echo "$HOSTS" | jq -e '. | if type == "array" and length > 0 then true else false end' > /dev/null 2>&1; then + echo "Error: No LXC hosts found or invalid JSON output: $HOSTS" + exit 1 + fi + + echo "$HOSTS" > hosts.json echo "Discovered hosts: $HOSTS" - name: Upload flake.lock @@ -51,19 +57,19 @@ jobs: path: flake.lock retention-days: 1 + - name: Upload hosts list + if: steps.changes.outputs.changed == 'true' + uses: forgejo/upload-artifact@v4 + with: + name: hosts-list + path: hosts.json + retention-days: 1 + build: needs: check-updates if: needs.check-updates.outputs.changed == 'true' runs-on: nix - strategy: - fail-fast: false - matrix: - host: ${{ needs.check-updates.outputs.hosts }} steps: - - name: Debug HOSTS - run: | - echo "HOSTS: "${{ needs.check-updates.outputs.hosts }} - - name: Checkout repository uses: actions/checkout@v4 @@ -72,25 +78,81 @@ jobs: with: name: flake-lock - - name: Build ${{ matrix.host }} + - name: Download hosts list + uses: forgejo/download-artifact@v4 + with: + name: hosts-list + + - name: Build all hosts id: build run: | - echo "Building host: ${{ matrix.host }}" - nix build .#nixosConfigurations.${{ matrix.host }}.config.system.build.toplevel --no-link 2>&1 | tee build-output.txt + set -euo pipefail + + if [ ! -f hosts.json ]; then + echo "Error: hosts.json not found" + exit 1 + fi + + HOSTS=$(cat hosts.json) + echo "Building hosts: $HOSTS" + + FAILED_HOSTS="" + SUCCESS_HOSTS="" + + for HOST in $(echo "$HOSTS" | jq -r '.[]'); do + echo "" + echo "==========================================" + echo "Building: $HOST" + echo "==========================================" + + if nix build ".#nixosConfigurations.${HOST}.config.system.build.toplevel" --no-link --quiet 2>&1 | tee "build-${HOST}.txt"; then + echo "✓ Build succeeded: $HOST" + SUCCESS_HOSTS="$SUCCESS_HOSTS $HOST" + else + echo "✗ Build failed: $HOST" + FAILED_HOSTS="$FAILED_HOSTS $HOST" + fi + done + + echo "" + echo "==========================================" + echo "Build Summary" + echo "==========================================" + echo "Succeeded:$SUCCESS_HOSTS" + echo "Failed:$FAILED_HOSTS" + + # Save results for report job + echo "$FAILED_HOSTS" > failed-hosts.txt + echo "$SUCCESS_HOSTS" > success-hosts.txt + + if [ -n "$FAILED_HOSTS" ]; then + echo "Some builds failed" + exit 1 + fi continue-on-error: true - - name: Upload build log on failure - if: failure() || steps.build.outcome == 'failure' + - name: Upload build logs + if: always() uses: forgejo/upload-artifact@v4 with: - name: build-failure-${{ matrix.host }} - path: build-output.txt + name: build-logs + path: build-*.txt retention-days: 7 + - name: Upload build results + if: always() + uses: forgejo/upload-artifact@v4 + with: + name: build-results + path: | + failed-hosts.txt + success-hosts.txt + retention-days: 1 + - name: Check build result run: | if [ "${{ steps.build.outcome }}" == "failure" ]; then - echo "Build failed for ${{ matrix.host }}" + echo "Some builds failed - check build-logs artifact" exit 1 fi @@ -114,13 +176,23 @@ jobs: with: name: flake-lock - - name: Download failure artifacts + - name: Download hosts list + uses: forgejo/download-artifact@v4 + with: + name: hosts-list + + - name: Download build results + uses: forgejo/download-artifact@v4 + with: + name: build-results + continue-on-error: true + + - name: Download build logs if: needs.build.result == 'failure' uses: forgejo/download-artifact@v4 with: - pattern: build-failure-* - path: failures - merge-multiple: false + name: build-logs + path: logs continue-on-error: true - name: Create branch and commit @@ -138,8 +210,8 @@ jobs: env: FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} run: | - HOSTS='${{ needs.check-updates.outputs.hosts }}' - HOST_LIST=$(echo "$HOSTS" | jq -r '.[] | "- " + .' | tr '\n' '\n') + HOSTS=$(cat hosts.json) + HOST_LIST=$(echo "$HOSTS" | jq -r '.[] | "- " + .') curl -X POST \ -H "Authorization: token $FORGEJO_TOKEN" \ @@ -157,31 +229,27 @@ jobs: env: FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} run: | - # Collect failed hosts from artifact directories FAILED_HOSTS="" FAILURE_DETAILS="" - if [ -d "failures" ]; then - for dir in failures/build-failure-*; do - if [ -d "$dir" ]; then - HOST=$(basename "$dir" | sed 's/build-failure-//') - FAILED_HOSTS="$FAILED_HOSTS\n- $HOST" - - if [ -f "$dir/build-output.txt" ]; then - # Get last 50 lines of build output - LOG_TAIL=$(tail -50 "$dir/build-output.txt" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g') - FAILURE_DETAILS="$FAILURE_DETAILS\n\n
\n$HOST build log (last 50 lines)\n\n\`\`\`\n$LOG_TAIL\n\`\`\`\n
" - fi + # Read failed hosts from build results + if [ -f "failed-hosts.txt" ]; then + for HOST in $(cat failed-hosts.txt); do + FAILED_HOSTS="$FAILED_HOSTS\n- $HOST" + + # Get build log if available + if [ -f "logs/build-${HOST}.txt" ]; then + LOG_TAIL=$(tail -50 "logs/build-${HOST}.txt" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g') + FAILURE_DETAILS="$FAILURE_DETAILS\n\n
\n$HOST build log (last 50 lines)\n\n\`\`\`\n$LOG_TAIL\n\`\`\`\n
" fi done fi - # If no failure artifacts found, list from matrix if [ -z "$FAILED_HOSTS" ]; then FAILED_HOSTS="\n- (Unable to determine failed hosts - check workflow logs)" fi - ISSUE_BODY="Weekly flake update failed to build some hosts.\n\n**Branch:** \`${{ steps.branch.outputs.branch_name }}\`\n**Run:** ${{ forge.server_url }}/${{ forge.repository }}/actions/runs/${{ forge.run_number }}\n\n**Failed hosts:**$FAILED_HOSTS\n$FAILURE_DETAILS\n\nGenerated on: $(date -Iseconds)" + ISSUE_BODY="Weekly flake update failed to build some hosts.\n\n**Branch:** \`${{ steps.branch.outputs.branch_name }}\`\n**Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n\n**Failed hosts:**$FAILED_HOSTS\n$FAILURE_DETAILS\n\nGenerated on: $(date -Iseconds)" curl -X POST \ -H "Authorization: token $FORGEJO_TOKEN" \ @@ -190,10 +258,10 @@ jobs: \"title\": \"Build failure: weekly flake update $(date +%Y-%m-%d)\", \"body\": \"$ISSUE_BODY\" }" \ - "${{ forge.server_url }}/api/v1/repos/${{ forge.repository }}/issues" + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/issues" - name: Cleanup if: always() run: | nix-collect-garbage -d - rm -rf result .direnv failures + rm -rf result .direnv logs diff --git a/.forgejo/workflows/test-matrix.yaml b/.forgejo/workflows/test-matrix.yaml deleted file mode 100644 index 2776368..0000000 --- a/.forgejo/workflows/test-matrix.yaml +++ /dev/null @@ -1,67 +0,0 @@ -name: shared matrix -on: - push: - workflow_dispatch: - -jobs: - - test: - runs-on: nix - strategy: - matrix: - variant: ['bookworm', 'bullseye'] - node: ['18', '20'] - steps: - - uses: https://code.forgejo.org/actions/setup-node@v4 - with: - node-version: '${{ matrix.node }}' - - define-matrix: - runs-on: nix - - outputs: - colors: ${{ steps.colors.outputs.colors }} - - steps: - - name: Define Colors - id: colors - run: | - echo 'colors=["red", "green", "blue"]' >> "$FORGEJO_OUTPUT" - - produce-artifacts: - runs-on: nix - needs: define-matrix - strategy: - matrix: - color: ${{ fromJSON(needs.define-matrix.outputs.colors) }} - - steps: - - name: Define Color - env: - color: ${{ matrix.color }} - run: | - echo "$color" > color - - name: Produce Artifact - uses: forgejo/upload-artifact@v4 - with: - name: ${{ matrix.color }} - path: color - - consume-artifacts: - runs-on: nix - needs: - - define-matrix - - produce-artifacts - strategy: - matrix: - color: ${{ fromJSON(needs.define-matrix.outputs.colors) }} - - steps: - - name: Retrieve Artifact - uses: forgejo/download-artifact@v5 - with: - name: ${{ matrix.color }} - - - name: Report Color - run: | - cat color -- 2.51.2 From 17304af351cec8e19501e738352c61074abe5284 Mon Sep 17 00:00:00 2001 From: pazpi Date: Sun, 7 Dec 2025 23:17:45 +0100 Subject: [PATCH 14/14] first create the auto update branch, update flake.nix, commit and then build all hosts. --- .forgejo/workflows/auto-update.yaml | 69 ++++++++++------------------- 1 file changed, 24 insertions(+), 45 deletions(-) diff --git a/.forgejo/workflows/auto-update.yaml b/.forgejo/workflows/auto-update.yaml index c6742b4..59a4702 100644 --- a/.forgejo/workflows/auto-update.yaml +++ b/.forgejo/workflows/auto-update.yaml @@ -7,10 +7,11 @@ on: workflow_dispatch: {} jobs: - check-updates: + prepare: runs-on: nix outputs: changed: ${{ steps.changes.outputs.changed }} + branch_name: ${{ steps.commit.outputs.branch_name }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -30,10 +31,24 @@ jobs: run: | if git diff --quiet flake.lock; then echo "changed=false" >> $FORGEJO_OUTPUT + echo "No changes to flake.lock" else echo "changed=true" >> $FORGEJO_OUTPUT + echo "flake.lock has been updated" fi + - name: Create branch and commit + id: commit + if: steps.changes.outputs.changed == 'true' + run: | + BRANCH_NAME="auto-update/$(date +%Y-%m-%d)" + git checkout -b "$BRANCH_NAME" + git add flake.lock + git commit -m "chore: update flake inputs $(date +%Y-%m-%d)" + git push origin "$BRANCH_NAME" + echo "branch_name=$BRANCH_NAME" >> $FORGEJO_OUTPUT + echo "Created and pushed branch: $BRANCH_NAME" + - name: Extract LXC hosts if: steps.changes.outputs.changed == 'true' run: | @@ -49,14 +64,6 @@ jobs: echo "$HOSTS" > hosts.json echo "Discovered hosts: $HOSTS" - - name: Upload flake.lock - if: steps.changes.outputs.changed == 'true' - uses: forgejo/upload-artifact@v4 - with: - name: flake-lock - path: flake.lock - retention-days: 1 - - name: Upload hosts list if: steps.changes.outputs.changed == 'true' uses: forgejo/upload-artifact@v4 @@ -66,17 +73,14 @@ jobs: retention-days: 1 build: - needs: check-updates - if: needs.check-updates.outputs.changed == 'true' + needs: prepare + if: needs.prepare.outputs.changed == 'true' runs-on: nix steps: - - name: Checkout repository + - name: Checkout update branch uses: actions/checkout@v4 - - - name: Download updated flake.lock - uses: forgejo/download-artifact@v4 with: - name: flake-lock + ref: ${{ needs.prepare.outputs.branch_name }} - name: Download hosts list uses: forgejo/download-artifact@v4 @@ -157,25 +161,10 @@ jobs: fi report: - needs: [check-updates, build] - if: always() && needs.check-updates.outputs.changed == 'true' + needs: [prepare, build] + if: always() && needs.prepare.outputs.changed == 'true' runs-on: nix steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Configure Git - run: | - git config user.name "Flake Update Bot" - git config user.email "bot@noreply.local" - - - name: Download updated flake.lock - uses: forgejo/download-artifact@v4 - with: - name: flake-lock - - name: Download hosts list uses: forgejo/download-artifact@v4 with: @@ -195,16 +184,6 @@ jobs: path: logs continue-on-error: true - - name: Create branch and commit - id: branch - run: | - BRANCH_NAME="auto-update/$(date +%Y-%m-%d)" - git checkout -b "$BRANCH_NAME" - git add flake.lock - git commit -m "chore: update flake inputs $(date +%Y-%m-%d)" - git push origin "$BRANCH_NAME" - echo "branch_name=$BRANCH_NAME" >> $FORGEJO_OUTPUT - - name: Create Pull Request if: needs.build.result == 'success' env: @@ -219,7 +198,7 @@ jobs: -d '{ "title": "chore: weekly flake update", "body": "Automated flake update from CI.\n\nThis PR updates all flake inputs and has been verified to build successfully.\n\n**Hosts built:**\n'"$(echo "$HOST_LIST" | sed 's/$/\\n/g' | tr -d '\n')"'\n\nGenerated on: '"$(date -Iseconds)"'", - "head": "'"${{ steps.branch.outputs.branch_name }}"'", + "head": "'"${{ needs.prepare.outputs.branch_name }}"'", "base": "master" }' \ "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/pulls" @@ -249,7 +228,7 @@ jobs: FAILED_HOSTS="\n- (Unable to determine failed hosts - check workflow logs)" fi - ISSUE_BODY="Weekly flake update failed to build some hosts.\n\n**Branch:** \`${{ steps.branch.outputs.branch_name }}\`\n**Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n\n**Failed hosts:**$FAILED_HOSTS\n$FAILURE_DETAILS\n\nGenerated on: $(date -Iseconds)" + ISSUE_BODY="Weekly flake update failed to build some hosts.\n\n**Branch:** \`${{ needs.prepare.outputs.branch_name }}\`\n**Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n\n**Failed hosts:**$FAILED_HOSTS\n$FAILURE_DETAILS\n\nGenerated on: $(date -Iseconds)" curl -X POST \ -H "Authorization: token $FORGEJO_TOKEN" \ -- 2.51.2