final test? let's hope so

This commit is contained in:
pazpi 2025-12-04 23:04:15 +01:00
parent 47ccfe8cf1
commit 8538c28f28

View file

@ -107,21 +107,9 @@ jobs:
build: build:
needs: check-updates needs: check-updates
if: needs.check-updates.outputs.changed == 'true' && needs.check-updates.outputs.hosts != '[]' && needs.check-updates.outputs.hosts != '' if: needs.check-updates.outputs.changed == 'true'
runs-on: nix runs-on: nix
strategy:
fail-fast: false
matrix:
host: ${{ fromJson(needs.check-updates.outputs.hosts || '[]') }}
steps: steps:
- name: Debug - show received values
run: |
echo "=== DEBUG: Values received from check-updates job ==="
echo "needs.check-updates.outputs.changed = '${{ needs.check-updates.outputs.changed }}'"
echo "needs.check-updates.outputs.hosts = '${{ needs.check-updates.outputs.hosts }}'"
echo "matrix.host = '${{ matrix.host }}'"
echo "=== END DEBUG ==="
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -130,33 +118,81 @@ jobs:
with: with:
name: flake-lock 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 id: build
run: | run: |
HOST="${{ matrix.host }}" set -euo pipefail
echo "DEBUG: matrix.host='$HOST'"
echo "DEBUG: raw matrix.host='${{ matrix.host }}'" if [ ! -f hosts.json ]; then
if [ -z "$HOST" ]; then echo "Error: hosts.json not found"
echo "Error: Host name is empty" exit 1
echo "This usually means the 'hosts' output from check-updates job was not received properly" 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 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 exit 1
fi fi
echo "Building host: $HOST"
nix build ".#nixosConfigurations.${HOST}.config.system.build.toplevel" --no-link 2>&1 | tee build-output.txt
continue-on-error: true continue-on-error: true
- name: Upload build log on failure - name: Upload build logs
if: failure() || steps.build.outcome == 'failure' if: always()
uses: forgejo/upload-artifact@v4 uses: forgejo/upload-artifact@v4
with: with:
name: build-failure-${{ matrix.host }} name: build-logs
path: build-output.txt path: build-*.txt
retention-days: 7 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 - name: Check build result
run: | run: |
if [ "${{ steps.build.outcome }}" == "failure" ]; then if [ "${{ steps.build.outcome }}" == "failure" ]; then
echo "Build failed for ${{ matrix.host }}" echo "Some builds failed - check build-logs artifact"
exit 1 exit 1
fi fi
@ -180,32 +216,48 @@ jobs:
with: with:
name: flake-lock name: flake-lock
- name: Download failure artifacts - name: Download build results
uses: forgejo/download-artifact@v4
with:
name: build-results
continue-on-error: true
- name: Download hosts list
uses: forgejo/download-artifact@v4
with:
name: hosts-list
- name: Download build logs
if: needs.build.result == 'failure' if: needs.build.result == 'failure'
uses: forgejo/download-artifact@v4 uses: forgejo/download-artifact@v4
with: with:
pattern: build-failure-* name: build-logs
path: failures path: logs
merge-multiple: false
continue-on-error: true continue-on-error: true
- name: Create branch and commit - name: Create branch and commit
id: branch id: branch
run: | run: |
set_output() {
echo "::set-output name=$1::$2"
if [ -n "${GITHUB_OUTPUT:-}" ]; then
echo "$1=$2" >> "$GITHUB_OUTPUT"
fi
}
BRANCH_NAME="auto-update/$(date +%Y-%m-%d)" BRANCH_NAME="auto-update/$(date +%Y-%m-%d)"
git checkout -b "$BRANCH_NAME" git checkout -b "$BRANCH_NAME"
git add flake.lock git add flake.lock
git commit -m "chore: update flake inputs $(date +%Y-%m-%d)" git commit -m "chore: update flake inputs $(date +%Y-%m-%d)"
git push origin "$BRANCH_NAME" git push origin "$BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT set_output branch_name "$BRANCH_NAME"
- name: Create Pull Request - name: Create Pull Request
if: needs.build.result == 'success' if: needs.build.result == 'success'
env: env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
run: | run: |
HOSTS='${{ needs.check-updates.outputs.hosts }}' HOSTS=$(cat hosts.json)
HOST_LIST=$(echo "$HOSTS" | jq -r '.[] | "- " + .' | tr '\n' '\n') HOST_LIST=$(echo "$HOSTS" | jq -r '.[] | "- " + .')
curl -X POST \ curl -X POST \
-H "Authorization: token $FORGEJO_TOKEN" \ -H "Authorization: token $FORGEJO_TOKEN" \
@ -223,26 +275,22 @@ jobs:
env: env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
run: | run: |
# Collect failed hosts from artifact directories
FAILED_HOSTS="" FAILED_HOSTS=""
FAILURE_DETAILS="" FAILURE_DETAILS=""
if [ -d "failures" ]; then # Read failed hosts from build results
for dir in failures/build-failure-*; do if [ -f "failed-hosts.txt" ]; then
if [ -d "$dir" ]; then for HOST in $(cat failed-hosts.txt); do
HOST=$(basename "$dir" | sed 's/build-failure-//') FAILED_HOSTS="$FAILED_HOSTS\n- $HOST"
FAILED_HOSTS="$FAILED_HOSTS\n- $HOST"
# Get build log if available
if [ -f "$dir/build-output.txt" ]; then if [ -f "logs/build-${HOST}.txt" ]; then
# Get last 50 lines of build output LOG_TAIL=$(tail -50 "logs/build-${HOST}.txt" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
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<details>\n<summary>$HOST build log (last 50 lines)</summary>\n\n\`\`\`\n$LOG_TAIL\n\`\`\`\n</details>"
FAILURE_DETAILS="$FAILURE_DETAILS\n\n<details>\n<summary>$HOST build log (last 50 lines)</summary>\n\n\`\`\`\n$LOG_TAIL\n\`\`\`\n</details>"
fi
fi fi
done done
fi fi
# If no failure artifacts found, list from matrix
if [ -z "$FAILED_HOSTS" ]; then if [ -z "$FAILED_HOSTS" ]; then
FAILED_HOSTS="\n- (Unable to determine failed hosts - check workflow logs)" FAILED_HOSTS="\n- (Unable to determine failed hosts - check workflow logs)"
fi fi