Update ci.yml #118
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file defines our primary CI workflow that runs on pull requests | ||
# and also on pushes to special branches (auto, try). | ||
# | ||
# The actual definition of the executed jobs is calculated by a Python | ||
# script located at src/ci/github-actions/calculate-job-matrix.py, which | ||
# uses job definition data from src/ci/github-actions/jobs.yml. | ||
# You should primarily modify the `jobs.yml` file if you want to modify | ||
# what jobs are executed in CI. | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- auto | ||
- try | ||
- try-perf | ||
- automation/bors/try | ||
pull_request: | ||
branches: | ||
- "**" | ||
permissions: | ||
contents: read | ||
packages: write | ||
defaults: | ||
run: | ||
# On Linux, macOS, and Windows, use the system-provided bash as the default | ||
# shell. (This should only make a difference on Windows, where the default | ||
# shell is PowerShell.) | ||
shell: bash | ||
concurrency: | ||
# For a given workflow, if we push to the same branch, cancel all previous builds on that branch. | ||
# We add an exception for try builds (try branch) and unrolled rollup builds (try-perf), which | ||
# are all triggered on the same branch, but which should be able to run concurrently. | ||
group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }} | ||
cancel-in-progress: true | ||
env: | ||
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate" | ||
# This will be empty in PR jobs. | ||
TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }} | ||
jobs: | ||
# The job matrix for `calculate_matrix` is defined in src/ci/github-actions/jobs.yml. | ||
# It calculates which jobs should be executed, based on the data of the ${{ github }} context. | ||
# If you want to modify CI jobs, take a look at src/ci/github-actions/jobs.yml. | ||
calculate_matrix: | ||
name: Calculate job matrix | ||
runs-on: ubuntu-latest | ||
outputs: | ||
jobs: ${{ steps.jobs.outputs.jobs }} | ||
run_type: ${{ steps.jobs.outputs.run_type }} | ||
steps: | ||
- name: Checkout the source code | ||
uses: actions/checkout@v4 | ||
- name: Calculate the CI job matrix | ||
env: | ||
COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | ||
run: python3 src/ci/github-actions/calculate-job-matrix.py >> $GITHUB_OUTPUT | ||
id: jobs | ||
job: | ||
name: ${{ matrix.name }} | ||
needs: [ calculate_matrix ] | ||
runs-on: "${{ matrix.os }}" | ||
defaults: | ||
run: | ||
shell: ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }} | ||
timeout-minutes: 360 | ||
env: | ||
CI_JOB_NAME: ${{ matrix.image }} | ||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse | ||
# commit of PR sha or commit sha. `GITHUB_SHA` is not accurate for PRs. | ||
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} | ||
DOCKER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SCCACHE_BUCKET: rust-lang-ci-sccache2 | ||
CACHE_DOMAIN: ci-caches.rust-lang.org | ||
continue-on-error: ${{ matrix.continue_on_error || false }} | ||
strategy: | ||
matrix: | ||
# Check the `calculate_matrix` job to see how is the matrix defined. | ||
include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }} | ||
steps: | ||
- name: list env | ||
run: ls env: | ||
shell: pwsh | ||
# 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: [ calculate_matrix, job ] | ||
# !cancelled() executes the job regardless of whether the previous jobs passed or failed | ||
if: ${{ !cancelled() && contains(fromJSON('["auto", "try"]'), needs.calculate_matrix.outputs.run_type) }} | ||
steps: | ||
- name: checkout the source code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
# Calculate the exit status of the whole CI workflow. | ||
# If all dependent jobs were successful, this exits with 0 (and the outcome job continues successfully). | ||
# If a some dependent job has failed, this exits with 1. | ||
- name: calculate the correct exit status | ||
run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}' | ||
# 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: needs.calculate_matrix.outputs.run_type == 'auto' | ||
env: | ||
TOOLSTATE_ISSUES_API_URL: https://api.github.com/repos/rust-lang/rust/issues | ||
TOOLSTATE_PUBLISH: 1 |