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_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')"
try-success:
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
outcome:
name: bors build finished
runs-on: ubuntu-latest
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'"
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'"
if: "!cancelled() && github.event_name == 'push'"
steps:
- name: checkout the source code
uses: actions/checkout@v4
with:
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
run: src/ci/publish_toolstate.sh
shell: bash
if: "steps.outputs.status == 0 && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
env:
TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}"
name: bors build finished
runs-on: ubuntu-latest
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
- name: set the correct exit status
run: "exit ${{ steps.outputs.status == 0 }}"

View File

@ -270,33 +270,32 @@ jobs:
# erroring about invalid credentials instead.
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
# build completed, as there is no practical way to detect when a workflow is
# successful listening to webhooks only.
try-success:
# This job isused to tell bors the final status of the build, as there is no practical way to detect
# when a workflow is successful listening to webhooks only in our current bors implementation (homu).
outcome:
name: bors build finished
runs-on: ubuntu-latest
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-success-job
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
# !cancelled() executes the job regardless of whether the previous jobs passed or failed
if: "!cancelled() && github.event_name == 'push'"
steps:
- name: checkout the source code
uses: actions/checkout@v4
with:
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
run: src/ci/publish_toolstate.sh
shell: bash
if: steps.outputs.status == 0 && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'
env:
TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}
auto-failure:
needs: [ job ]
if: "!success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
<<: *base-failure-job
- name: set the correct exit status
run: exit ${{ steps.outputs.status }}