Unify outcome jobs

This commit is contained in:
Jakub Beránek 2024-04-25 11:04:49 +02:00
parent e27af2917b
commit 23341500a6
No known key found for this signature in database
GPG Key ID: 909CD0D26483516B
2 changed files with 26 additions and 51 deletions

View File

@ -152,49 +152,25 @@ jobs:
AWS_ACCESS_KEY_ID: "${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}" AWS_ACCESS_KEY_ID: "${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}"
if: "success() && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')" if: "success() && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')"
try-success: outcome:
needs:
- job
if: "success() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'"
steps:
- name: mark the job as a success
run: exit 0
shell: bash
name: bors build finished name: bors build finished
runs-on: ubuntu-latest runs-on: ubuntu-latest
try-failure:
needs: needs:
- job - job
if: "!success() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'" if: "!cancelled() && github.event_name == 'push'"
steps:
- name: mark the job as a failure
run: exit 1
shell: bash
name: bors build finished
runs-on: ubuntu-latest
auto-success:
needs:
- job
if: "success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
steps: steps:
- name: checkout the source code - name: checkout the source code
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 2 fetch-depth: 2
- name: calculate the correct exit status
id: status
run: "jq --exit-status 'all(.result == \"success\" or .result == \"skipped\")' <<< '${{ toJson(needs) }}'\necho \"status=$?\" >> $GITHUB_OUTPUT\n"
- name: publish toolstate - name: publish toolstate
run: src/ci/publish_toolstate.sh run: src/ci/publish_toolstate.sh
shell: bash shell: bash
if: "steps.outputs.status == 0 && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
env: env:
TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}" TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}"
name: bors build finished - name: set the correct exit status
runs-on: ubuntu-latest run: "exit ${{ steps.outputs.status == 0 }}"
auto-failure:
needs:
- job
if: "!success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
steps:
- name: mark the job as a failure
run: exit 1
shell: bash
name: bors build finished
runs-on: ubuntu-latest

View File

@ -270,33 +270,32 @@ jobs:
# erroring about invalid credentials instead. # erroring about invalid credentials instead.
if: success() && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1') if: success() && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')
# These jobs don't actually test anything, but they're used to tell bors the # This job isused to tell bors the final status of the build, as there is no practical way to detect
# build completed, as there is no practical way to detect when a workflow is # when a workflow is successful listening to webhooks only in our current bors implementation (homu).
# successful listening to webhooks only. outcome:
try-success: name: bors build finished
runs-on: ubuntu-latest
needs: [ job ] needs: [ job ]
if: "success() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'" # !cancelled() executes the job regardless of whether the previous jobs passed or failed
<<: *base-success-job if: "!cancelled() && github.event_name == 'push'"
try-failure:
needs: [ job ]
if: "!success() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'"
<<: *base-failure-job
auto-success:
needs: [ job ]
if: "success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
<<: *base-outcome-job
steps: steps:
- name: checkout the source code - name: checkout the source code
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 2 fetch-depth: 2
# Calculate the exit status of the whole CI workflow (0 if all dependent jobs were either successful
# or skipped, otherwise 1).
- name: calculate the correct exit status
id: status
run: |
jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'
echo "status=$?" >> $GITHUB_OUTPUT
# Publish the toolstate if an auto build succeeds (just before push to master)
- name: publish toolstate - name: publish toolstate
run: src/ci/publish_toolstate.sh run: src/ci/publish_toolstate.sh
shell: bash shell: bash
if: steps.outputs.status == 0 && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'
env: env:
TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }} TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}
- name: set the correct exit status
auto-failure: run: exit ${{ steps.outputs.status }}
needs: [ job ]
if: "!success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
<<: *base-failure-job