diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 232707b1d5..c559cf2103 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -173,6 +173,7 @@ jobs: if [ "${attempt}" -gt 1 ]; then sleep 5 fi + # shellcheck disable=SC2016 # the single quotes hold a jq program: $newest is a jq variable, not a shell one if page=$(gh api "repos/${GH_REPO}/actions/workflows/build.yml/runs?branch=dev&status=success&per_page=30" --jq '[.workflow_runs[] | select(.event == "push")] | (map(.updated_at) | max) as $newest | if $newest > env.FRESH_AFTER then .[].id else "stale \($newest // "none")" end'); then case "${page}" in stale*) @@ -596,7 +597,8 @@ jobs: # -shellcheck= and -pyflakes= are off on purpose. This job runs on Windows, and actionlint 1.7.12 hangs there # as soon as it pipes a `run:` script to shellcheck.exe (measured on claude-review-guard.yml with shellcheck # 0.10.0 and 0.11.0: no output and no exit). The bash-script checks need an ubuntu runner, where both tools - # are installed. + # are installed: the `workflow-lint` job below runs the same actionlint with shellcheck on (#5970). This step + # keeps the YAML, expression, `needs:` and action-input checks on the Windows job; that job adds the shell checks. - name: Detect changed workflow files id: workflow-filter if: needs.guard-build.outputs.run == 'true' @@ -770,6 +772,48 @@ jobs: overwrite: true if-no-files-found: ignore + # #5970: the shell half of the workflow lint. The Windows step in guard-tests runs actionlint with shellcheck and + # pyflakes off (it hangs on Windows when it pipes a `run:` script to shellcheck.exe), so nothing there reads the + # bash in a `run:` block. This job runs the rhysd/actionlint Docker image on ubuntu, where shellcheck is installed + # and on, over every file under .github/workflows/. The image is pinned by tag and by digest, so a moved tag cannot + # change what the guard checks. It runs on the same trigger as the Windows step: a pull request that changes a file + # under .github/workflows/, and every push to main or dev. On any other diff the job still runs and ends success + # with its lint step skipped, so the result jobs (darling-pg-result, lite-tests-result) read `success` and need no + # planned-skip arm for it. A finding fails the job and so both required result checks. It does not start + # guard-cancel: it costs a minute, and the shards' answer is not wasted by a lint finding. + workflow-lint: + name: Workflow lint (actionlint with shellcheck) + needs: gate + if: ${{ needs.gate.outputs.run == 'true' && github.event_name != 'release' }} + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + steps: + - uses: actions/checkout@v7 + + - name: Detect changed workflow files + id: workflow-filter + uses: dorny/paths-filter@v4 + with: + base: ${{ github.event_name == 'push' && github.event.before || '' }} + filters: | + workflows: + - '.github/workflows/**' + + - name: Lint the workflow files with actionlint and shellcheck + if: github.event_name == 'push' || steps.workflow-filter.outputs.workflows == 'true' + shell: bash + env: + ACTIONLINT_IMAGE: rhysd/actionlint:1.7.12@sha256:b1934ee5f1c509618f2508e6eb47ee0d3520686341fec936f3b79331f9315667 + run: | + set -uo pipefail + # No -ignore and no shellcheck-off flag: a finding is fixed in the workflow, not silenced here. + if ! docker run --rm -v "${GITHUB_WORKSPACE}:/repo" -w /repo "${ACTIONLINT_IMAGE}" -no-color; then + echo "::error title=actionlint found problems::Fix them in the workflow file. The findings, shellcheck's among them, are listed above." + exit 1 + fi + # #5949: when the Guard tests (or their build) fail on a pull request, cancel the rest of the run, so a bad # pull request costs the minutes the guard took and not the whole shard run it no longer waits for. A separate # job, so the guard job keeps its own `failure` conclusion (a cancel called from inside a job turns that job @@ -2445,7 +2489,7 @@ jobs: # something other than success, and this fails loudly and says which. darling-pg-result: name: Darling PostgreSQL tests - needs: [gate, guard-build, guard-build-lite, guard-tests, darling-pg] + needs: [gate, guard-build, guard-build-lite, guard-tests, workflow-lint, darling-pg] if: ${{ !cancelled() || (github.event_name == 'pull_request' && (needs.guard-build.result == 'failure' || needs.guard-build-lite.result == 'failure' || needs.guard-tests.result == 'failure')) }} runs-on: ubuntu-latest timeout-minutes: 5 @@ -2456,6 +2500,7 @@ jobs: env: RESULT: ${{ needs.darling-pg.result }} GUARD_RESULT: ${{ needs.guard-build.result != 'success' && needs.guard-build.result || needs.guard-build-lite.result != 'success' && needs.guard-build-lite.result || needs.guard-tests.result }} + LINT_RESULT: ${{ needs.workflow-lint.result }} GATE_RESULT: ${{ needs.gate.result }} GATE_RUN: ${{ needs.gate.outputs.run }} EVENT_NAME: ${{ github.event_name }} @@ -2484,6 +2529,13 @@ jobs: fi exit 1 fi + # #5970: the workflow lint (actionlint with shellcheck, on ubuntu) runs on every event but a release. It ends + # `success` when no workflow file changed (its lint step is skipped, not the job), so anything else is a + # finding, a failed run or a cancel. `skipped` is fine on a release only: the job does not run there. + if [ "${LINT_RESULT}" != "success" ] && ! { [ "${EVENT_NAME}" = "release" ] && [ "${LINT_RESULT}" = "skipped" ]; }; then + echo "::error title=Workflow lint failed::workflow-lint result='${LINT_RESULT}' - actionlint (with shellcheck) reported a problem in a workflow file, or the job did not finish. Read the Workflow lint job's log." + exit 1 + fi case "${RESULT}" in success) echo "::notice title=Darling PG shards green::Every shard succeeded, or the Darling gate skipped the suite on all of them." ;; @@ -3408,7 +3460,7 @@ jobs: full "no test map is pinned for this run" else ok=0 - for attempt in 1 2 3; do + for _ in 1 2 3; do rm -rf shadow/map if gh run download "${MAP_RUN}" -n test-map -D shadow/map; then ok=1; break; fi sleep 5 @@ -3538,7 +3590,7 @@ jobs: # (result)" for the shards to gate merges — noted on #3887.) lite-tests-result: name: Lite tests (result) - needs: [gate, guard-build, guard-build-lite, guard-tests, lite-scope, lite-tests] + needs: [gate, guard-build, guard-build-lite, guard-tests, workflow-lint, lite-scope, lite-tests] if: ${{ (!cancelled() || (github.event_name == 'pull_request' && (needs.guard-build.result == 'failure' || needs.guard-build-lite.result == 'failure' || needs.guard-tests.result == 'failure'))) && github.event_name != 'release' }} runs-on: ubuntu-latest timeout-minutes: 5 @@ -3549,6 +3601,7 @@ jobs: env: RESULT: ${{ needs.lite-tests.result }} GUARD_RESULT: ${{ needs.guard-build.result != 'success' && needs.guard-build.result || needs.guard-build-lite.result != 'success' && needs.guard-build-lite.result || needs.guard-tests.result }} + LINT_RESULT: ${{ needs.workflow-lint.result }} GATE_RESULT: ${{ needs.gate.result }} GATE_RUN: ${{ needs.gate.outputs.run }} EVENT_NAME: ${{ github.event_name }} @@ -3578,6 +3631,13 @@ jobs: fi exit 1 fi + # #5970: the workflow lint (actionlint with shellcheck, on ubuntu) runs on every event but a release. It ends + # `success` when no workflow file changed (its lint step is skipped, not the job), so anything else is a + # finding, a failed run or a cancel. `skipped` is fine on a release only: the job does not run there. + if [ "${LINT_RESULT}" != "success" ] && ! { [ "${EVENT_NAME}" = "release" ] && [ "${LINT_RESULT}" = "skipped" ]; }; then + echo "::error title=Workflow lint failed::workflow-lint result='${LINT_RESULT}' - actionlint (with shellcheck) reported a problem in a workflow file, or the job did not finish. Read the Workflow lint job's log." + exit 1 + fi # #5669: the one planned skip of the whole matrix. The lite-scope job found nothing the Lite suite depends on in # this pull request's files, so the shards were not started. It is checked AFTER the gate and guard arms above # (a declined run or a failed guard never reaches it) and needs all three facts: a pull request, a matrix that diff --git a/.github/workflows/claude-review-guard.yml b/.github/workflows/claude-review-guard.yml index 720b173a47..1797f3ba85 100644 --- a/.github/workflows/claude-review-guard.yml +++ b/.github/workflows/claude-review-guard.yml @@ -444,6 +444,7 @@ jobs: # already on the head listed `steps: []` for both its jobs, and so did a Build run of the # same minute). A job that ran always has steps, so an empty list under a review job that # did not skip means "not listed yet", not "the step was renamed". + # shellcheck disable=SC2016 # the single quotes hold a jq program: $j is a jq variable, not a shell one jobs_jq='([.jobs[] | select(.name == env.REVIEW_JOB)] | .[0]) as $j | "\($j.conclusion // "-") \(($j.steps // []) | length)" + " \(([.jobs[].steps[]? | select(.name == env.REVIEW_STEP)] | .[0].conclusion) // "-")"' diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2c3514df0d..4aff70eab4 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -69,7 +69,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # The 14:00 UTC cron builds the test map only (#5945); the 06:00 cron is the full nightly. MAP_ONLY: ${{ github.event.schedule == '0 14 * * *' }} - run: gh workflow run nightly.yml --repo ${{ github.repository }} --ref dev -f from_schedule=true -f map_only=${MAP_ONLY} + run: gh workflow run nightly.yml --repo "${GITHUB_REPOSITORY}" --ref dev -f from_schedule=true -f map_only="${MAP_ONLY}" # Everything below runs only in a workflow_dispatch run — the scheduled re-dispatch or a # manual one — which executes from the dispatched ref (dev for the scheduled path). @@ -138,10 +138,10 @@ jobs: run: | RECENT=$(git log --since="24 hours ago" --oneline | head -1) if [ -n "$RECENT" ]; then - echo "has_changes=true" >> $GITHUB_OUTPUT + echo "has_changes=true" >> "$GITHUB_OUTPUT" echo "New commits found — building nightly" else - echo "has_changes=false" >> $GITHUB_OUTPUT + echo "has_changes=false" >> "$GITHUB_OUTPUT" echo "No new commits — skipping nightly build" fi diff --git a/.github/workflows/sql-validation.yml b/.github/workflows/sql-validation.yml index b9b88615ea..e668b3bb34 100644 --- a/.github/workflows/sql-validation.yml +++ b/.github/workflows/sql-validation.yml @@ -79,7 +79,7 @@ jobs: env: SA_PASSWORD: CI_Test#2026! run: | - for script in $(ls install/[0-9]*.sql | sort); do + for script in install/[0-9]*.sql; do filename=$(basename "$script") # Skip scripts that require SQL Agent or are test/troubleshooting diff --git a/Darling/Darling.Tests/GuardStageWorkflowTests.cs b/Darling/Darling.Tests/GuardStageWorkflowTests.cs index 6b2bf85a20..cc3c5a611a 100644 --- a/Darling/Darling.Tests/GuardStageWorkflowTests.cs +++ b/Darling/Darling.Tests/GuardStageWorkflowTests.cs @@ -283,8 +283,8 @@ public void EveryJobThatTheGuardStageGates_ListsItInNeeds() } /* The result jobs read both guard jobs, so a failed guard class run or a failed guard build reaches the required checks. */ - Assert.Contains("\n needs: [gate, guard-build, guard-build-lite, guard-tests, darling-pg]\n", JobBlock(yaml, "darling-pg-result"), StringComparison.Ordinal); - Assert.Contains("\n needs: [gate, guard-build, guard-build-lite, guard-tests, lite-scope, lite-tests]\n", JobBlock(yaml, "lite-tests-result"), StringComparison.Ordinal); + Assert.Contains("\n needs: [gate, guard-build, guard-build-lite, guard-tests, workflow-lint, darling-pg]\n", JobBlock(yaml, "darling-pg-result"), StringComparison.Ordinal); + Assert.Contains("\n needs: [gate, guard-build, guard-build-lite, guard-tests, workflow-lint, lite-scope, lite-tests]\n", JobBlock(yaml, "lite-tests-result"), StringComparison.Ordinal); } ///