Skip to content

Commit 72a7a1c

Browse files
authored
Add CI files to 1.81.0 (#19)
1 parent eeb90cd commit 72a7a1c

File tree

2 files changed

+83
-225
lines changed

2 files changed

+83
-225
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 225 deletions
Original file line numberDiff line numberDiff line change
@@ -1,240 +1,64 @@
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 a Python
5-
# script located at src/ci/github-actions/calculate-job-matrix.py, 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-
101
name: CI
2+
113
on:
124
push:
13-
branches:
14-
- auto
15-
- try
16-
- try-perf
17-
- automation/bors/try
5+
branches: [ risc0 ]
186
pull_request:
19-
branches:
20-
- "**"
21-
22-
permissions:
23-
contents: read
24-
packages: write
25-
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
7+
branches: [ risc0 ]
8+
workflow_call:
9+
workflow_dispatch:
3210

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 }}
4311
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-latest
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-
- name: Calculate the CI job matrix
57-
env:
58-
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
59-
run: python3 src/ci/github-actions/calculate-job-matrix.py >> $GITHUB_OUTPUT
60-
id: jobs
61-
job:
62-
name: ${{ matrix.name }}
63-
needs: [ calculate_matrix ]
64-
runs-on: "${{ matrix.os }}"
65-
defaults:
66-
run:
67-
shell: ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}
68-
timeout-minutes: 240
69-
env:
70-
CI_JOB_NAME: ${{ matrix.image }}
71-
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
72-
# commit of PR sha or commit sha. `GITHUB_SHA` is not accurate for PRs.
73-
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
74-
DOCKER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75-
SCCACHE_BUCKET: rust-lang-ci-sccache2
76-
CACHE_DOMAIN: ci-caches.rust-lang.org
77-
continue-on-error: ${{ matrix.continue_on_error || false }}
12+
build:
7813
strategy:
14+
fail-fast: false
7915
matrix:
80-
# Check the `calculate_matrix` job to see how is the matrix defined.
81-
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 }}" ]
8224
steps:
83-
- if: contains(matrix.os, 'windows')
84-
uses: msys2/setup-msys2@v2.22.0
25+
- name: Install Rust
26+
uses: risc0/actions-rs-toolchain@v1
8527
with:
86-
# i686 jobs use mingw32. x86_64 and cross-compile jobs use mingw64.
87-
msystem: ${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}
88-
# don't try to download updates for already installed packages
89-
update: false
90-
# don't try to use the msys that comes built-in to the github runner,
91-
# so we can control what is installed (i.e. not python)
92-
release: true
93-
# Inherit the full path from the Windows environment, with MSYS2's */bin/
94-
# dirs placed in front. This lets us run Windows-native Python etc.
95-
path-type: inherit
96-
install: >
97-
make
98-
99-
- name: disable git crlf conversion
100-
run: git config --global core.autocrlf false
28+
toolchain: stable
29+
- uses: lukka/get-cmake@v3.27.4
10130

102-
- name: checkout the source code
103-
uses: actions/checkout@v4
31+
- name: Check out risc0/rust
32+
uses: actions/checkout@v3
10433
with:
105-
fetch-depth: 2
106-
107-
# Rust Log Analyzer can't currently detect the PR number of a GitHub
108-
# Actions build on its own, so a hint in the log message is needed to
109-
# point it in the right direction.
110-
- name: configure the PR in which the error message will be posted
111-
run: echo "[CI_PR_NUMBER=$num]"
112-
env:
113-
num: ${{ github.event.number }}
114-
if: needs.calculate_matrix.outputs.run_type == 'pr'
115-
116-
- name: add extra environment variables
117-
run: src/ci/scripts/setup-environment.sh
118-
env:
119-
# Since it's not possible to merge `${{ matrix.env }}` with the other
120-
# variables in `job.<name>.env`, the variables defined in the matrix
121-
# are passed to the `setup-environment.sh` script encoded in JSON,
122-
# which then uses log commands to actually set them.
123-
EXTRA_VARIABLES: ${{ toJson(matrix.env) }}
124-
125-
- name: ensure the channel matches the target branch
126-
run: src/ci/scripts/verify-channel.sh
127-
128-
- name: collect CPU statistics
129-
run: src/ci/scripts/collect-cpu-stats.sh
130-
131-
- name: show the current environment
132-
run: src/ci/scripts/dump-environment.sh
133-
134-
- name: install awscli
135-
run: src/ci/scripts/install-awscli.sh
136-
137-
- name: install sccache
138-
run: src/ci/scripts/install-sccache.sh
139-
140-
- name: select Xcode
141-
run: src/ci/scripts/select-xcode.sh
142-
143-
- name: install clang
144-
run: src/ci/scripts/install-clang.sh
145-
146-
- name: install tidy
147-
run: src/ci/scripts/install-tidy.sh
34+
submodules: 'recursive'
35+
path: rust
36+
fetch-depth: 0
14837

149-
- name: install WIX
150-
run: src/ci/scripts/install-wix.sh
151-
152-
- name: disable git crlf conversion
153-
run: src/ci/scripts/disable-git-crlf-conversion.sh
154-
155-
- name: checkout submodules
156-
run: src/ci/scripts/checkout-submodules.sh
157-
158-
- name: install MinGW
159-
run: src/ci/scripts/install-mingw.sh
160-
161-
- name: install ninja
162-
run: src/ci/scripts/install-ninja.sh
163-
164-
- name: enable ipv6 on Docker
165-
run: src/ci/scripts/enable-docker-ipv6.sh
166-
167-
# Disable automatic line ending conversion (again). On Windows, when we're
168-
# installing dependencies, something switches the git configuration directory or
169-
# re-enables autocrlf. We've not tracked down the exact cause -- and there may
170-
# be multiple -- but this should ensure submodules are checked out with the
171-
# appropriate line endings.
172-
- name: disable git crlf conversion
173-
run: src/ci/scripts/disable-git-crlf-conversion.sh
174-
175-
- name: ensure line endings are correct
176-
run: src/ci/scripts/verify-line-endings.sh
177-
178-
- name: ensure backported commits are in upstream branches
179-
run: src/ci/scripts/verify-backported-commits.sh
180-
181-
- name: ensure the stable version number is correct
182-
run: src/ci/scripts/verify-stable-version-number.sh
183-
184-
- name: run the build
185-
# Redirect stderr to stdout to avoid reordering the two streams in the GHA logs.
186-
run: src/ci/scripts/run-build-from-ci.sh 2>&1
187-
env:
188-
AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }}
189-
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}
190-
191-
- name: create github artifacts
192-
run: src/ci/scripts/create-doc-artifacts.sh
193-
194-
- name: upload artifacts to github
195-
uses: actions/upload-artifact@v4
38+
- name: Check out risc0/risc0
39+
uses: actions/checkout@v3
19640
with:
197-
# name is set in previous step
198-
name: ${{ env.DOC_ARTIFACT_NAME }}
199-
path: obj/artifacts/doc
200-
if-no-files-found: ignore
201-
retention-days: 5
202-
203-
- name: upload artifacts to S3
204-
run: src/ci/scripts/upload-artifacts.sh
205-
env:
206-
AWS_ACCESS_KEY_ID: ${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}
207-
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}
208-
# Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy
209-
# builders *should* have the AWS credentials available. Still, explicitly
210-
# adding the condition is helpful as this way CI will not silently skip
211-
# deploying artifacts from a dist builder if the variables are misconfigured,
212-
# erroring about invalid credentials instead.
213-
if: github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1'
214-
215-
# This job isused to tell bors the final status of the build, as there is no practical way to detect
216-
# when a workflow is successful listening to webhooks only in our current bors implementation (homu).
217-
outcome:
218-
name: bors build finished
219-
runs-on: ubuntu-latest
220-
needs: [ calculate_matrix, job ]
221-
# !cancelled() executes the job regardless of whether the previous jobs passed or failed
222-
if: ${{ !cancelled() && contains(fromJSON('["auto", "try"]'), needs.calculate_matrix.outputs.run_type) }}
223-
steps:
224-
- name: checkout the source code
225-
uses: actions/checkout@v4
41+
repository: risc0/risc0
42+
ref: main
43+
path: risc0
44+
45+
- name: Build
46+
run: GITHUB_ACTIONS=false RISC0_BUILD_DIR=$GITHUB_WORKSPACE cargo run --bin cargo-risczero -- risczero build-toolchain
47+
working-directory: risc0
48+
49+
- name: "Archive toolchain"
50+
run: |
51+
tar \
52+
--exclude lib/rustlib/src \
53+
--exclude lib/rustlib/rustc-src \
54+
-hczvf \
55+
./rust-toolchain-${{ matrix.triple }}.tar.gz \
56+
-C ./build/${{ matrix.triple }}/stage2/ \
57+
.
58+
working-directory: rust
59+
60+
- name: "Upload workflow artifact"
61+
uses: "actions/upload-artifact@v4"
22662
with:
227-
fetch-depth: 2
228-
# Calculate the exit status of the whole CI workflow.
229-
# If all dependent jobs were successful, this exits with 0 (and the outcome job continues successfully).
230-
# If a some dependent job has failed, this exits with 1.
231-
- name: calculate the correct exit status
232-
run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'
233-
# Publish the toolstate if an auto build succeeds (just before push to master)
234-
- name: publish toolstate
235-
run: src/ci/publish_toolstate.sh
236-
shell: bash
237-
if: needs.calculate_matrix.outputs.run_type == 'auto'
238-
env:
239-
TOOLSTATE_ISSUES_API_URL: https://api.github.com/repos/rust-lang/rust/issues
240-
TOOLSTATE_PUBLISH: 1
63+
name: "rust-toolchain-${{ matrix.triple }}.tar.gz"
64+
path: "rust/rust-toolchain-${{ matrix.triple }}.tar.gz"

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
7+
jobs:
8+
build:
9+
uses: ./.github/workflows/ci.yml
10+
11+
release:
12+
needs: build
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
steps:
17+
- name: Download artifacts
18+
uses: actions/download-artifact@v4
19+
with:
20+
path: artifacts
21+
merge-multiple: true
22+
- name: Display structure of downloaded artifacts
23+
run: ls -R ./artifacts
24+
- name: Create release
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
run: |
28+
echo "Installing gh CLI..."
29+
curl -L https://github.com/cli/cli/releases/download/v2.17.0/gh_2.17.0_linux_amd64.tar.gz | \
30+
tar xvz --strip-components=2 --exclude=man
31+
chmod +x ./gh
32+
33+
./gh release create --repo "$GITHUB_REPOSITORY" "$GITHUB_REF_NAME" ./artifacts/* || \
34+
./gh release upload --repo "$GITHUB_REPOSITORY" "$GITHUB_REF_NAME" ./artifacts/*

0 commit comments

Comments
 (0)