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