2024-04-29 14:32:35 -05:00
|
|
|
# This file defines our primary CI workflow that runs on pull requests
|
|
|
|
# and also on pushes to special branches (auto, try).
|
2019-11-26 05:06:30 -06:00
|
|
|
#
|
2024-04-29 14:32:35 -05:00
|
|
|
# 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.
|
2019-11-26 05:06:30 -06:00
|
|
|
|
|
|
|
name: CI
|
2024-04-29 14:32:35 -05:00
|
|
|
on:
|
2019-11-26 05:06:30 -06:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- auto
|
|
|
|
- try
|
2020-07-21 13:53:39 -05:00
|
|
|
- try-perf
|
2023-10-02 14:38:50 -05:00
|
|
|
- automation/bors/try
|
2019-11-26 05:06:30 -06:00
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- "**"
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2022-09-02 11:37:17 -05:00
|
|
|
permissions:
|
|
|
|
contents: read
|
2024-01-21 07:26:20 -06:00
|
|
|
packages: write
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2020-04-22 11:53:11 -05:00
|
|
|
defaults:
|
|
|
|
run:
|
2024-04-29 14:32:35 -05:00
|
|
|
# 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.)
|
2020-07-17 08:44:14 -05:00
|
|
|
shell: bash
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2023-06-23 04:22:23 -05:00
|
|
|
concurrency:
|
2024-04-29 14:32:35 -05:00
|
|
|
# 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 }}
|
2023-06-23 04:22:23 -05:00
|
|
|
cancel-in-progress: true
|
2024-04-27 04:36:42 -05:00
|
|
|
env:
|
|
|
|
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
|
2024-06-05 09:41:59 -05:00
|
|
|
# This will be empty in PR jobs.
|
|
|
|
TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}
|
2019-11-26 05:06:30 -06:00
|
|
|
jobs:
|
2024-04-29 14:32:35 -05:00
|
|
|
# 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.
|
2024-04-04 07:27:38 -05:00
|
|
|
calculate_matrix:
|
|
|
|
name: Calculate job matrix
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
2024-04-29 14:32:35 -05:00
|
|
|
jobs: ${{ steps.jobs.outputs.jobs }}
|
2024-04-27 05:09:18 -05:00
|
|
|
run_type: ${{ steps.jobs.outputs.run_type }}
|
2024-04-04 07:27:38 -05:00
|
|
|
steps:
|
|
|
|
- name: Checkout the source code
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Calculate the CI job matrix
|
2024-05-02 14:44:47 -05:00
|
|
|
env:
|
|
|
|
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
2024-04-19 14:41:49 -05:00
|
|
|
run: python3 src/ci/github-actions/calculate-job-matrix.py >> $GITHUB_OUTPUT
|
2024-04-04 07:27:38 -05:00
|
|
|
id: jobs
|
2024-04-20 02:07:11 -05:00
|
|
|
job:
|
2024-04-29 14:32:35 -05:00
|
|
|
name: ${{ matrix.name }}
|
|
|
|
needs: [ calculate_matrix ]
|
2024-04-24 08:00:42 -05:00
|
|
|
runs-on: "${{ matrix.os }}"
|
|
|
|
defaults:
|
|
|
|
run:
|
2024-04-29 14:32:35 -05:00
|
|
|
shell: ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}
|
2024-07-12 04:27:46 -05:00
|
|
|
timeout-minutes: 240
|
2019-11-26 05:06:30 -06:00
|
|
|
env:
|
2024-04-29 14:32:35 -05:00
|
|
|
CI_JOB_NAME: ${{ matrix.image }}
|
2023-01-31 20:13:57 -06:00
|
|
|
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
|
2024-04-29 14:32:35 -05:00
|
|
|
# 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 }}
|
2020-07-20 10:43:48 -05:00
|
|
|
SCCACHE_BUCKET: rust-lang-ci-sccache2
|
|
|
|
CACHE_DOMAIN: ci-caches.rust-lang.org
|
2024-04-29 14:32:35 -05:00
|
|
|
continue-on-error: ${{ matrix.continue_on_error || false }}
|
2019-11-26 05:06:30 -06:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2024-04-29 14:32:35 -05:00
|
|
|
# Check the `calculate_matrix` job to see how is the matrix defined.
|
|
|
|
include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}
|
2019-11-26 05:06:30 -06:00
|
|
|
steps:
|
2024-04-29 14:32:35 -05:00
|
|
|
- if: contains(matrix.os, 'windows')
|
2024-02-12 22:37:31 -06:00
|
|
|
uses: msys2/setup-msys2@v2.22.0
|
|
|
|
with:
|
2024-04-29 14:32:35 -05:00
|
|
|
# i686 jobs use mingw32. x86_64 and cross-compile jobs use mingw64.
|
|
|
|
msystem: ${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}
|
|
|
|
# don't try to download updates for already installed packages
|
2024-02-12 22:37:31 -06:00
|
|
|
update: false
|
2024-04-29 14:32:35 -05:00
|
|
|
# don't try to use the msys that comes built-in to the github runner,
|
|
|
|
# so we can control what is installed (i.e. not python)
|
2024-02-12 22:37:31 -06:00
|
|
|
release: true
|
2024-04-29 14:32:35 -05:00
|
|
|
# Inherit the full path from the Windows environment, with MSYS2's */bin/
|
|
|
|
# dirs placed in front. This lets us run Windows-native Python etc.
|
2024-02-12 22:37:31 -06:00
|
|
|
path-type: inherit
|
2024-04-29 14:32:35 -05:00
|
|
|
install: >
|
|
|
|
make
|
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: disable git crlf conversion
|
|
|
|
run: git config --global core.autocrlf false
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: checkout the source code
|
2023-09-08 00:18:21 -05:00
|
|
|
uses: actions/checkout@v4
|
2019-11-26 05:06:30 -06:00
|
|
|
with:
|
|
|
|
fetch-depth: 2
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2024-10-11 02:03:16 -05:00
|
|
|
# Free up disk space on Linux by removing preinstalled components that
|
|
|
|
# we do not need. We do this to enable some of the less resource
|
|
|
|
# intensive jobs to run on free runners, which however also have
|
|
|
|
# less disk space.
|
|
|
|
- name: free up disk space
|
|
|
|
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
|
2024-11-05 09:56:41 -06:00
|
|
|
if: matrix.free_disk
|
2024-10-11 02:03:16 -05:00
|
|
|
|
2024-04-29 14:32:35 -05:00
|
|
|
# Rust Log Analyzer can't currently detect the PR number of a GitHub
|
|
|
|
# Actions build on its own, so a hint in the log message is needed to
|
|
|
|
# point it in the right direction.
|
2020-07-20 10:11:30 -05:00
|
|
|
- name: configure the PR in which the error message will be posted
|
2024-04-29 14:32:35 -05:00
|
|
|
run: echo "[CI_PR_NUMBER=$num]"
|
2020-07-20 10:11:30 -05:00
|
|
|
env:
|
2024-04-29 14:32:35 -05:00
|
|
|
num: ${{ github.event.number }}
|
2024-04-27 05:09:18 -05:00
|
|
|
if: needs.calculate_matrix.outputs.run_type == 'pr'
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: add extra environment variables
|
|
|
|
run: src/ci/scripts/setup-environment.sh
|
|
|
|
env:
|
2024-04-29 14:32:35 -05:00
|
|
|
# Since it's not possible to merge `${{ matrix.env }}` with the other
|
|
|
|
# variables in `job.<name>.env`, the variables defined in the matrix
|
|
|
|
# are passed to the `setup-environment.sh` script encoded in JSON,
|
|
|
|
# which then uses log commands to actually set them.
|
|
|
|
EXTRA_VARIABLES: ${{ toJson(matrix.env) }}
|
|
|
|
|
2024-10-11 23:41:39 -05:00
|
|
|
- name: setup upstream remote
|
|
|
|
run: src/ci/scripts/setup-upstream-remote.sh
|
|
|
|
|
2021-05-06 11:47:37 -05:00
|
|
|
- name: ensure the channel matches the target branch
|
|
|
|
run: src/ci/scripts/verify-channel.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: collect CPU statistics
|
|
|
|
run: src/ci/scripts/collect-cpu-stats.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: show the current environment
|
|
|
|
run: src/ci/scripts/dump-environment.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2023-10-02 21:18:44 -05:00
|
|
|
- name: install awscli
|
|
|
|
run: src/ci/scripts/install-awscli.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: install sccache
|
|
|
|
run: src/ci/scripts/install-sccache.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2022-11-19 14:18:09 -06:00
|
|
|
- name: select Xcode
|
|
|
|
run: src/ci/scripts/select-xcode.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: install clang
|
|
|
|
run: src/ci/scripts/install-clang.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2023-10-31 15:32:37 -05:00
|
|
|
- name: install tidy
|
|
|
|
run: src/ci/scripts/install-tidy.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: install WIX
|
|
|
|
run: src/ci/scripts/install-wix.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: disable git crlf conversion
|
|
|
|
run: src/ci/scripts/disable-git-crlf-conversion.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2022-03-01 12:16:47 -06:00
|
|
|
- name: checkout submodules
|
|
|
|
run: src/ci/scripts/checkout-submodules.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: install MinGW
|
|
|
|
run: src/ci/scripts/install-mingw.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: install ninja
|
|
|
|
run: src/ci/scripts/install-ninja.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: enable ipv6 on Docker
|
|
|
|
run: src/ci/scripts/enable-docker-ipv6.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
|
|
|
# Disable automatic line ending conversion (again). On Windows, when we're
|
|
|
|
# installing dependencies, something switches the git configuration directory or
|
|
|
|
# re-enables autocrlf. We've not tracked down the exact cause -- and there may
|
|
|
|
# be multiple -- but this should ensure submodules are checked out with the
|
|
|
|
# appropriate line endings.
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: disable git crlf conversion
|
|
|
|
run: src/ci/scripts/disable-git-crlf-conversion.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: ensure line endings are correct
|
|
|
|
run: src/ci/scripts/verify-line-endings.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2021-07-29 12:00:13 -05:00
|
|
|
- name: ensure backported commits are in upstream branches
|
|
|
|
run: src/ci/scripts/verify-backported-commits.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2022-01-20 14:18:04 -06:00
|
|
|
- name: ensure the stable version number is correct
|
|
|
|
run: src/ci/scripts/verify-stable-version-number.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: run the build
|
2024-04-29 14:32:35 -05:00
|
|
|
# Redirect stderr to stdout to avoid reordering the two streams in the GHA logs.
|
2024-04-02 04:34:53 -05:00
|
|
|
run: src/ci/scripts/run-build-from-ci.sh 2>&1
|
2019-11-26 05:06:30 -06:00
|
|
|
env:
|
2024-04-29 14:32:35 -05:00
|
|
|
AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}
|
|
|
|
|
2023-06-07 18:20:39 -05:00
|
|
|
- name: create github artifacts
|
|
|
|
run: src/ci/scripts/create-doc-artifacts.sh
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2024-10-11 04:13:57 -05:00
|
|
|
- name: print disk usage
|
|
|
|
run: |
|
|
|
|
echo "disk usage:"
|
|
|
|
df -h
|
|
|
|
|
2023-06-07 18:20:39 -05:00
|
|
|
- name: upload artifacts to github
|
2024-03-23 11:06:02 -05:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-06-07 18:20:39 -05:00
|
|
|
with:
|
2024-04-29 14:32:35 -05:00
|
|
|
# name is set in previous step
|
|
|
|
name: ${{ env.DOC_ARTIFACT_NAME }}
|
2023-06-07 18:20:39 -05:00
|
|
|
path: obj/artifacts/doc
|
|
|
|
if-no-files-found: ignore
|
|
|
|
retention-days: 5
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2019-11-26 05:06:30 -06:00
|
|
|
- name: upload artifacts to S3
|
|
|
|
run: src/ci/scripts/upload-artifacts.sh
|
|
|
|
env:
|
2024-04-29 14:32:35 -05:00
|
|
|
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)] }}
|
|
|
|
# Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy
|
|
|
|
# builders *should* have the AWS credentials available. Still, explicitly
|
|
|
|
# adding the condition is helpful as this way CI will not silently skip
|
|
|
|
# deploying artifacts from a dist builder if the variables are misconfigured,
|
|
|
|
# erroring about invalid credentials instead.
|
2024-04-27 05:02:05 -05:00
|
|
|
if: github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1'
|
2024-04-29 14:32:35 -05:00
|
|
|
|
2024-09-26 06:44:06 -05:00
|
|
|
- name: upload job metrics to DataDog
|
|
|
|
if: needs.calculate_matrix.outputs.run_type != 'pr'
|
|
|
|
env:
|
|
|
|
DATADOG_SITE: datadoghq.com
|
|
|
|
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
|
|
|
|
DD_GITHUB_JOB_NAME: ${{ matrix.name }}
|
|
|
|
run: |
|
|
|
|
npm install -g @datadog/datadog-ci@^2.x.x
|
|
|
|
python3 src/ci/scripts/upload-build-metrics.py build/cpu-usage.csv
|
|
|
|
|
2024-04-29 14:32:35 -05:00
|
|
|
# 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).
|
2024-04-25 04:04:49 -05:00
|
|
|
outcome:
|
2019-11-26 05:06:30 -06:00
|
|
|
name: bors build finished
|
|
|
|
runs-on: ubuntu-latest
|
2024-04-27 05:09:18 -05:00
|
|
|
needs: [ calculate_matrix, job ]
|
2024-04-29 14:32:35 -05:00
|
|
|
# !cancelled() executes the job regardless of whether the previous jobs passed or failed
|
2024-04-27 05:09:18 -05:00
|
|
|
if: ${{ !cancelled() && contains(fromJSON('["auto", "try"]'), needs.calculate_matrix.outputs.run_type) }}
|
2019-11-26 05:06:30 -06:00
|
|
|
steps:
|
2024-04-27 08:48:35 -05:00
|
|
|
- name: checkout the source code
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
fetch-depth: 2
|
2024-04-29 14:32:35 -05:00
|
|
|
# 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.
|
2024-04-25 04:04:49 -05:00
|
|
|
- name: calculate the correct exit status
|
2024-04-29 14:32:35 -05:00
|
|
|
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)
|
2024-04-23 08:16:21 -05:00
|
|
|
- name: publish toolstate
|
|
|
|
run: src/ci/publish_toolstate.sh
|
2020-04-29 09:32:06 -05:00
|
|
|
shell: bash
|
2024-04-27 05:09:18 -05:00
|
|
|
if: needs.calculate_matrix.outputs.run_type == 'auto'
|
2024-04-23 08:16:21 -05:00
|
|
|
env:
|
2024-05-15 08:48:52 -05:00
|
|
|
TOOLSTATE_ISSUES_API_URL: https://api.github.com/repos/rust-lang/rust/issues
|
|
|
|
TOOLSTATE_PUBLISH: 1
|