Skip to content

Commit

Permalink
ci: Prevent artifact-from-cirrus from failing when freebsd didn't run
Browse files Browse the repository at this point in the history
This can happen when the build was not triggered because of only_if.
  • Loading branch information
wolfgangwalther committed Mar 4, 2024
1 parent 5d0395e commit a329787
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
10 changes: 1 addition & 9 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
24 changes: 17 additions & 7 deletions .github/actions/artifact-from-cirrus/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,37 @@ 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)"
if [ -z "$conclusion" ]; then
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: |
Expand All @@ -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 }}
Expand Down

0 comments on commit a329787

Please sign in to comment.