|
1 | | -# This file defines our primary CI workflow that runs on pull requests |
2 | | -# and also on pushes to special branches (auto, try). |
3 | | -# |
4 | | -# The actual definition of the executed jobs is calculated by the |
5 | | -# `src/ci/citool` crate, which |
6 | | -# uses job definition data from src/ci/github-actions/jobs.yml. |
7 | | -# You should primarily modify the `jobs.yml` file if you want to modify |
8 | | -# what jobs are executed in CI. |
9 | | - |
10 | 1 | name: CI |
| 2 | + |
11 | 3 | on: |
12 | 4 | push: |
13 | | - branches: |
14 | | - - auto |
15 | | - - try |
16 | | - - try-perf |
17 | | - - automation/bors/try |
| 5 | + branches: [ risc0 ] |
18 | 6 | pull_request: |
19 | | - branches: |
20 | | - - "**" |
21 | | - |
22 | | -permissions: |
23 | | - contents: read |
24 | | - packages: write |
| 7 | + branches: [ risc0, "risc0-*" ] |
| 8 | + workflow_call: |
| 9 | + workflow_dispatch: |
25 | 10 |
|
26 | | -defaults: |
27 | | - run: |
28 | | - # On Linux, macOS, and Windows, use the system-provided bash as the default |
29 | | - # shell. (This should only make a difference on Windows, where the default |
30 | | - # shell is PowerShell.) |
31 | | - shell: bash |
32 | | - |
33 | | -concurrency: |
34 | | - # For a given workflow, if we push to the same branch, cancel all previous builds on that branch. |
35 | | - # We add an exception for try builds (try branch) and unrolled rollup builds (try-perf), which |
36 | | - # are all triggered on the same branch, but which should be able to run concurrently. |
37 | | - group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }} |
38 | | - cancel-in-progress: true |
39 | | -env: |
40 | | - TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate" |
41 | | - # This will be empty in PR jobs. |
42 | | - TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }} |
43 | 11 | jobs: |
44 | | - # The job matrix for `calculate_matrix` is defined in src/ci/github-actions/jobs.yml. |
45 | | - # It calculates which jobs should be executed, based on the data of the ${{ github }} context. |
46 | | - # If you want to modify CI jobs, take a look at src/ci/github-actions/jobs.yml. |
47 | | - calculate_matrix: |
48 | | - name: Calculate job matrix |
49 | | - runs-on: ubuntu-24.04 |
50 | | - outputs: |
51 | | - jobs: ${{ steps.jobs.outputs.jobs }} |
52 | | - run_type: ${{ steps.jobs.outputs.run_type }} |
53 | | - steps: |
54 | | - - name: Checkout the source code |
55 | | - uses: actions/checkout@v4 |
56 | | - # Cache citool to make its build faster, as it's in the critical path. |
57 | | - # The rust-cache doesn't bleed into the main `job`, so it should not affect any other |
58 | | - # Rust compilation. |
59 | | - - name: Cache citool |
60 | | - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 |
61 | | - with: |
62 | | - workspaces: src/ci/citool |
63 | | - - name: Calculate the CI job matrix |
64 | | - env: |
65 | | - COMMIT_MESSAGE: ${{ github.event.head_commit.message }} |
66 | | - run: | |
67 | | - cd src/ci/citool |
68 | | - CARGO_INCREMENTAL=0 cargo test |
69 | | - CARGO_INCREMENTAL=0 cargo run calculate-job-matrix >> $GITHUB_OUTPUT |
70 | | - id: jobs |
71 | | - job: |
72 | | - name: ${{ matrix.full_name }} |
73 | | - needs: [ calculate_matrix ] |
74 | | - runs-on: "${{ matrix.os }}" |
75 | | - timeout-minutes: 360 |
76 | | - # The bors environment contains secrets required for elevated workflows (try and auto builds), |
77 | | - # which need to access e.g. S3 and upload artifacts. We want to provide access to that |
78 | | - # environment only on the try/auto branches, which are only accessible to bors. |
79 | | - # This also ensures that PR CI (which doesn't get write access to S3) works, as it cannot |
80 | | - # access the environment. |
81 | | - # |
82 | | - # We only enable the environment for the rust-lang/rust repository, so that rust-lang-ci/rust |
83 | | - # CI works until we migrate off it (since that repository doesn't contain the environment). |
84 | | - environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/auto')) && 'bors') || '' }} |
85 | | - env: |
86 | | - CI_JOB_NAME: ${{ matrix.name }} |
87 | | - CI_JOB_DOC_URL: ${{ matrix.doc_url }} |
88 | | - GITHUB_WORKFLOW_RUN_ID: ${{ github.run_id }} |
89 | | - GITHUB_REPOSITORY: ${{ github.repository }} |
90 | | - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse |
91 | | - # commit of PR sha or commit sha. `GITHUB_SHA` is not accurate for PRs. |
92 | | - HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} |
93 | | - DOCKER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
94 | | - SCCACHE_BUCKET: rust-lang-ci-sccache2 |
95 | | - SCCACHE_REGION: us-west-1 |
96 | | - CACHE_DOMAIN: ci-caches.rust-lang.org |
97 | | - continue-on-error: ${{ matrix.continue_on_error || false }} |
| 12 | + build: |
98 | 13 | strategy: |
| 14 | + fail-fast: false |
99 | 15 | matrix: |
100 | | - # Check the `calculate_matrix` job to see how is the matrix defined. |
101 | | - include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }} |
| 16 | + include: |
| 17 | + - os: macOS |
| 18 | + arch: ARM64 |
| 19 | + triple: aarch64-apple-darwin |
| 20 | + - os: Linux |
| 21 | + arch: X64 |
| 22 | + triple: x86_64-unknown-linux-gnu |
| 23 | + runs-on: [ self-hosted, release, "${{ matrix.os }}", "${{ matrix.arch }}" ] |
102 | 24 | steps: |
103 | | - - name: Install cargo in AWS CodeBuild |
104 | | - if: matrix.codebuild |
105 | | - run: | |
106 | | - # Check if cargo is installed |
107 | | - if ! command -v cargo &> /dev/null; then |
108 | | - echo "Cargo not found, installing Rust..." |
109 | | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal |
110 | | - # Make cargo available in PATH |
111 | | - echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
112 | | - fi |
| 25 | + - name: Install Rust |
| 26 | + uses: risc0/actions-rs-toolchain@v1 |
| 27 | + with: |
| 28 | + toolchain: stable |
| 29 | + - uses: lukka/get-cmake@v3.27.4 |
113 | 30 |
|
114 | | - - name: disable git crlf conversion |
115 | | - run: git config --global core.autocrlf false |
| 31 | + - name: Check out risc0/rust |
| 32 | + uses: actions/checkout@v3 |
| 33 | + with: |
| 34 | + submodules: 'recursive' |
| 35 | + path: rust |
| 36 | + fetch-depth: 0 |
116 | 37 |
|
117 | | - - name: checkout the source code |
| 38 | + - name: Check out risc0/risc0 |
118 | 39 | uses: actions/checkout@v4 |
119 | 40 | with: |
120 | | - fetch-depth: 2 |
121 | | - |
122 | | - # Free up disk space on Linux by removing preinstalled components that |
123 | | - # we do not need. We do this to enable some of the less resource |
124 | | - # intensive jobs to run on free runners, which however also have |
125 | | - # less disk space. |
126 | | - - name: free up disk space |
127 | | - run: src/ci/scripts/free-disk-space.sh |
128 | | - if: matrix.free_disk |
129 | | - |
130 | | - # Rust Log Analyzer can't currently detect the PR number of a GitHub |
131 | | - # Actions build on its own, so a hint in the log message is needed to |
132 | | - # point it in the right direction. |
133 | | - - name: configure the PR in which the error message will be posted |
134 | | - run: echo "[CI_PR_NUMBER=$num]" |
135 | | - env: |
136 | | - num: ${{ github.event.number }} |
137 | | - if: needs.calculate_matrix.outputs.run_type == 'pr' |
138 | | - |
139 | | - - name: add extra environment variables |
140 | | - run: src/ci/scripts/setup-environment.sh |
141 | | - env: |
142 | | - # Since it's not possible to merge `${{ matrix.env }}` with the other |
143 | | - # variables in `job.<name>.env`, the variables defined in the matrix |
144 | | - # are passed to the `setup-environment.sh` script encoded in JSON, |
145 | | - # which then uses log commands to actually set them. |
146 | | - EXTRA_VARIABLES: ${{ toJson(matrix.env) }} |
147 | | - |
148 | | - - name: ensure the channel matches the target branch |
149 | | - run: src/ci/scripts/verify-channel.sh |
150 | | - |
151 | | - - name: collect CPU statistics |
152 | | - run: src/ci/scripts/collect-cpu-stats.sh |
153 | | - |
154 | | - - name: show the current environment |
155 | | - run: src/ci/scripts/dump-environment.sh |
156 | | - |
157 | | - - name: install awscli |
158 | | - run: src/ci/scripts/install-awscli.sh |
159 | | - |
160 | | - - name: install sccache |
161 | | - run: src/ci/scripts/install-sccache.sh |
162 | | - |
163 | | - - name: select Xcode |
164 | | - run: src/ci/scripts/select-xcode.sh |
165 | | - |
166 | | - - name: install clang |
167 | | - run: src/ci/scripts/install-clang.sh |
168 | | - |
169 | | - - name: install tidy |
170 | | - run: src/ci/scripts/install-tidy.sh |
171 | | - |
172 | | - - name: install WIX |
173 | | - run: src/ci/scripts/install-wix.sh |
174 | | - |
175 | | - - name: disable git crlf conversion |
176 | | - run: src/ci/scripts/disable-git-crlf-conversion.sh |
| 41 | + repository: risc0/risc0 |
| 42 | + ref: main |
| 43 | + path: risc0 |
177 | 44 |
|
178 | | - - name: checkout submodules |
179 | | - run: src/ci/scripts/checkout-submodules.sh |
| 45 | + - name: set RISC0_HOME |
| 46 | + run: echo "RISC0_HOME=$GITHUB_WORKSPACE/rzup_artifacts" >> $GITHUB_ENV |
180 | 47 |
|
181 | | - - name: install MinGW |
182 | | - run: src/ci/scripts/install-mingw.sh |
| 48 | + - name: Build |
| 49 | + run: GITHUB_ACTIONS=false cargo run --bin rzup -- build rust --path $GITHUB_WORKSPACE/rust |
| 50 | + working-directory: risc0 |
183 | 51 |
|
184 | | - - name: install ninja |
185 | | - run: src/ci/scripts/install-ninja.sh |
186 | | - |
187 | | - - name: enable ipv6 on Docker |
188 | | - # Don't run on codebuild because systemctl is not available |
189 | | - if: ${{ !matrix.codebuild }} |
190 | | - run: src/ci/scripts/enable-docker-ipv6.sh |
191 | | - |
192 | | - # Disable automatic line ending conversion (again). On Windows, when we're |
193 | | - # installing dependencies, something switches the git configuration directory or |
194 | | - # re-enables autocrlf. We've not tracked down the exact cause -- and there may |
195 | | - # be multiple -- but this should ensure submodules are checked out with the |
196 | | - # appropriate line endings. |
197 | | - - name: disable git crlf conversion |
198 | | - run: src/ci/scripts/disable-git-crlf-conversion.sh |
199 | | - |
200 | | - - name: ensure line endings are correct |
201 | | - run: src/ci/scripts/verify-line-endings.sh |
202 | | - |
203 | | - - name: ensure backported commits are in upstream branches |
204 | | - run: src/ci/scripts/verify-backported-commits.sh |
205 | | - |
206 | | - - name: ensure the stable version number is correct |
207 | | - run: src/ci/scripts/verify-stable-version-number.sh |
208 | | - |
209 | | - # Show the environment just before we run the build |
210 | | - # This makes it easier to diagnose problems with the above install scripts. |
211 | | - - name: show the current environment |
212 | | - run: src/ci/scripts/dump-environment.sh |
213 | | - |
214 | | - # Pre-build citool before the following step uninstalls rustup |
215 | | - # Build it into the build directory, to avoid modifying sources |
216 | | - - name: build citool |
217 | | - run: | |
218 | | - cd src/ci/citool |
219 | | - CARGO_INCREMENTAL=0 CARGO_TARGET_DIR=../../../build/citool cargo build |
220 | | -
|
221 | | - - name: run the build |
222 | | - run: | |
223 | | - set +e |
224 | | - # Redirect stderr to stdout to avoid reordering the two streams in the GHA logs. |
225 | | - src/ci/scripts/run-build-from-ci.sh 2>&1 |
226 | | - STATUS=$? |
227 | | - set -e |
228 | | -
|
229 | | - if [[ "$STATUS" -ne 0 && -n "$CI_JOB_DOC_URL" ]]; then |
230 | | - echo "****************************************************************************" |
231 | | - echo "To find more information about this job, visit the following URL:" |
232 | | - echo "$CI_JOB_DOC_URL" |
233 | | - echo "****************************************************************************" |
234 | | - fi |
235 | | - exit ${STATUS} |
236 | | - env: |
237 | | - AWS_ACCESS_KEY_ID: ${{ (github.repository == 'rust-lang/rust' && secrets.CACHES_AWS_ACCESS_KEY_ID) || env.CACHES_AWS_ACCESS_KEY_ID }} |
238 | | - AWS_SECRET_ACCESS_KEY: ${{ (github.repository == 'rust-lang/rust' && secrets.CACHES_AWS_SECRET_ACCESS_KEY) || secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }} |
239 | | - |
240 | | - - name: create github artifacts |
241 | | - run: src/ci/scripts/create-doc-artifacts.sh |
242 | | - |
243 | | - - name: print disk usage |
244 | | - run: | |
245 | | - echo "disk usage:" |
246 | | - df -h |
247 | | -
|
248 | | - - name: upload artifacts to github |
249 | | - uses: actions/upload-artifact@v4 |
250 | | - with: |
251 | | - # name is set in previous step |
252 | | - name: ${{ env.DOC_ARTIFACT_NAME }} |
253 | | - path: obj/artifacts/doc |
254 | | - if-no-files-found: ignore |
255 | | - retention-days: 5 |
256 | | - |
257 | | - - name: upload artifacts to S3 |
258 | | - run: src/ci/scripts/upload-artifacts.sh |
259 | | - env: |
260 | | - AWS_ACCESS_KEY_ID: ${{ (github.repository == 'rust-lang/rust' && secrets.ARTIFACTS_AWS_ACCESS_KEY_ID) || env.ARTIFACTS_AWS_ACCESS_KEY_ID }} |
261 | | - AWS_SECRET_ACCESS_KEY: ${{ (github.repository == 'rust-lang/rust' && secrets.ARTIFACTS_AWS_SECRET_ACCESS_KEY) || secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }} |
262 | | - # Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy |
263 | | - # builders *should* have the AWS credentials available. Still, explicitly |
264 | | - # adding the condition is helpful as this way CI will not silently skip |
265 | | - # deploying artifacts from a dist builder if the variables are misconfigured, |
266 | | - # erroring about invalid credentials instead. |
267 | | - if: github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1' |
268 | | - |
269 | | - - name: postprocess metrics into the summary |
270 | | - # This step is not critical, and if some I/O problem happens, we don't want |
271 | | - # to cancel the build. |
272 | | - continue-on-error: true |
| 52 | + - name: "Archive toolchain" |
273 | 53 | run: | |
274 | | - if [ -f build/metrics.json ]; then |
275 | | - METRICS=build/metrics.json |
276 | | - elif [ -f obj/build/metrics.json ]; then |
277 | | - METRICS=obj/build/metrics.json |
278 | | - else |
279 | | - echo "No metrics.json found" |
280 | | - exit 0 |
281 | | - fi |
282 | | -
|
283 | | - # Get closest bors merge commit |
284 | | - PARENT_COMMIT=`git rev-list --author='bors <bors@rust-lang.org>' -n1 --first-parent HEAD^1` |
285 | | -
|
286 | | - ./build/citool/debug/citool postprocess-metrics \ |
287 | | - --job-name ${CI_JOB_NAME} \ |
288 | | - --parent ${PARENT_COMMIT} \ |
289 | | - ${METRICS} >> ${GITHUB_STEP_SUMMARY} |
290 | | -
|
291 | | - - name: upload job metrics to DataDog |
292 | | - # This step is not critical, and if some I/O problem happens, we don't want |
293 | | - # to cancel the build. |
294 | | - continue-on-error: true |
295 | | - if: needs.calculate_matrix.outputs.run_type != 'pr' |
296 | | - env: |
297 | | - DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} |
298 | | - DD_GITHUB_JOB_NAME: ${{ matrix.full_name }} |
299 | | - run: ./build/citool/debug/citool upload-build-metrics build/cpu-usage.csv |
300 | | - |
301 | | - # This job isused to tell bors the final status of the build, as there is no practical way to detect |
302 | | - # when a workflow is successful listening to webhooks only in our current bors implementation (homu). |
303 | | - outcome: |
304 | | - name: bors build finished |
305 | | - runs-on: ubuntu-24.04 |
306 | | - needs: [ calculate_matrix, job ] |
307 | | - # !cancelled() executes the job regardless of whether the previous jobs passed or failed |
308 | | - if: ${{ !cancelled() && contains(fromJSON('["auto", "try"]'), needs.calculate_matrix.outputs.run_type) }} |
309 | | - steps: |
310 | | - - name: checkout the source code |
311 | | - uses: actions/checkout@v4 |
| 54 | + tar \ |
| 55 | + --exclude lib/rustlib/src \ |
| 56 | + --exclude lib/rustlib/rustc-src \ |
| 57 | + -hczvf \ |
| 58 | + ./rust-toolchain-${{ matrix.triple }}.tar.gz \ |
| 59 | + -C $GITHUB_WORKSPACE/rzup_artifacts/toolchains/*rust*/ \ |
| 60 | + . |
| 61 | + working-directory: rust |
| 62 | + |
| 63 | + - name: "Upload workflow artifact" |
| 64 | + uses: "actions/upload-artifact@v4" |
312 | 65 | with: |
313 | | - fetch-depth: 2 |
314 | | - # Calculate the exit status of the whole CI workflow. |
315 | | - # If all dependent jobs were successful, this exits with 0 (and the outcome job continues successfully). |
316 | | - # If a some dependent job has failed, this exits with 1. |
317 | | - - name: calculate the correct exit status |
318 | | - run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}' |
319 | | - # Publish the toolstate if an auto build succeeds (just before push to master) |
320 | | - - name: publish toolstate |
321 | | - run: src/ci/publish_toolstate.sh |
322 | | - shell: bash |
323 | | - if: needs.calculate_matrix.outputs.run_type == 'auto' |
324 | | - env: |
325 | | - TOOLSTATE_ISSUES_API_URL: https://api.github.com/repos/rust-lang/rust/issues |
326 | | - TOOLSTATE_PUBLISH: 1 |
| 66 | + name: "rust-toolchain-${{ matrix.triple }}.tar.gz" |
| 67 | + path: "rust/rust-toolchain-${{ matrix.triple }}.tar.gz" |
0 commit comments