From a329787d0874df4ca4ff833844b9c382c67aced1 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 2 Mar 2024 13:23:34 +0100 Subject: [PATCH] ci: Prevent artifact-from-cirrus from failing when freebsd didn't run This can happen when the build was not triggered because of only_if. --- .cirrus.yml | 10 +------- .../actions/artifact-from-cirrus/action.yaml | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index cee5d375639..e025801b0d8 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -5,19 +5,11 @@ build_task: name: Build FreeBSD (Stack) install_script: pkg install -y postgresql16-client hs-stack git - # This also includes nix and cabal related files, because the - # Github Actions build workflow will run on those and the - # "Fetch from FreeBSD" job should not fail. only_if: | + $CIRRUS_PR == '' || changesInclude( '.github/workflows/build.yaml', - '.github/actions/setup-nix/**', - '.github/scripts/**', - '.github/*', - '*.nix', - 'nix/**', '.cirrus.yml', - 'cabal.project*', 'postgrest.cabal', 'stack.yaml*', '**.hs' diff --git a/.github/actions/artifact-from-cirrus/action.yaml b/.github/actions/artifact-from-cirrus/action.yaml index 466ee15b6e7..ec111c6502a 100644 --- a/.github/actions/artifact-from-cirrus/action.yaml +++ b/.github/actions/artifact-from-cirrus/action.yaml @@ -48,13 +48,14 @@ runs: shell: bash run: | gh api "${{ steps.check-suite.outputs.check_runs_url }}" \ - | jq -er '.check_runs[] | select(.name == "${{ inputs.task }}")' > /dev/null + | jq -er '.check_runs[] | select(.name == "${{ inputs.task }}" or name == "Build Parsing Results")' > /dev/null - name: Wait for Cirrus CI to complete task + id: completion shell: bash run: | get_conclusion() { gh api "${{ steps.check-suite.outputs.check_runs_url }}" \ - | jq -r '.check_runs[] | select(.name == "${{ inputs.task }}" and .status == "completed") | .conclusion' + | jq -r '.check_runs[] | select((.name == "${{ inputs.task }}" or name == "Build Parsing Results") and .status == "completed") | .conclusion' } while true; do conclusion="$(get_conclusion)" @@ -62,14 +63,22 @@ runs: echo "Cirrus CI task has not completed, yet. Waiting..." sleep 30 else - if [ "$conclusion" == "success" ]; then - break - else - exit 1 - fi + case "$conclusion" in + success) # Cirrus CI job succeeded + break + ;; + neutral) # Cirrus CI job didn't run because of "only_if" + break + ;; + *) + exit 1 + ;; + esac fi done + echo "conclusion=$conclusion" >> "$GITHUB_OUTPUT" - name: Download artifact from Cirrus CI + if: steps.completion.outputs.conclusion == 'success' id: download shell: bash run: | @@ -84,6 +93,7 @@ runs: unzip "${archive}" -d "${artifacts}" echo "artifacts=${artifacts}" >> "$GITHUB_OUTPUT" - name: Save artifact to GitHub Actions + if: steps.completion.outputs.conclusion == 'success' uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4 with: name: ${{ inputs.upload }}