fork/cargo

git clone https://git.julia.blue/fork/cargo

Ed Pagechore(ci): report-timings to upload HTML report (#16416)1f5feecdf

master
11.8 KiB347 linesraw
1name: CI
2on:
3  merge_group:
4  pull_request:
5    branches:
6      - "**"
7
8defaults:
9  run:
10    shell: bash
11
12permissions:
13  contents: read
14
15concurrency:
16  group: "${{ github.workflow }}-${{ github.ref }}"
17  cancel-in-progress: true
18
19env:
20  MDBOOK_VERSION: 0.5.1
21
22jobs:
23  conclusion:
24    needs:
25      - build_std
26      - clippy
27      - msrv
28      - docs
29      - lint-docs
30      - lockfile
31      - resolver
32      - report-timings
33      - rustfmt
34      - schema
35      - spellcheck
36      - test
37      - test_gitoxide
38    permissions:
39      contents: none
40    # We need to ensure this job does *not* get skipped if its dependencies fail,
41    # because a skipped job is considered a success by GitHub. So we have to
42    # overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
43    # when the workflow is canceled manually.
44    #
45    # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
46    if: ${{ !cancelled() }}
47    runs-on: ubuntu-latest
48    steps:
49      # Manually check the status of all dependencies. `if: failure()` does not work.
50      - name: Conclusion
51        run: |
52          # Print the dependent jobs to see them in the CI log
53          jq -C <<< '${{ toJson(needs) }}'
54          # Check if all jobs that we depend on (in the needs array) were successful.
55          jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
56
57  # Check Code style quickly by running `rustfmt` over all code
58  rustfmt:
59    runs-on: ubuntu-latest
60    steps:
61    - uses: actions/checkout@v5
62    - run: rustup update stable && rustup default stable
63    - run: rustup component add rustfmt
64    - run: cargo fmt --all --check
65
66  # Ensure there are no clippy warnings
67  clippy:
68    strategy:
69      matrix:
70        include:
71        - name: Linux x86_64
72          os: ubuntu-latest
73        - name: macOS aarch64
74          os: macos-14
75        - name: Windows x86_64 MSVC
76          os: windows-latest
77    name: Clippy ${{ matrix.name }}
78    runs-on: ${{ matrix.os }}
79    steps:
80      - uses: actions/checkout@v5
81      - run: rustup update stable && rustup default stable
82      - run: rustup component add clippy
83      - run: cargo clippy --workspace --all-targets --no-deps -- -D warnings
84
85  stale-label:
86    runs-on: ubuntu-latest
87    steps:
88      - uses: actions/checkout@v5
89      - run: rustup update stable && rustup default stable
90      - run: cargo stale-label
91
92  lint-docs:
93    runs-on: ubuntu-latest
94    steps:
95      - uses: actions/checkout@v5
96      - run: rustup update stable && rustup default stable
97      - run: cargo lint-docs --check
98
99  # Ensure Cargo.lock is up-to-date
100  lockfile:
101    runs-on: ubuntu-latest
102    steps:
103      - uses: actions/checkout@v5
104      - run: rustup update stable && rustup default stable
105      - run: cargo update -p cargo --locked
106
107  check-version-bump:
108    runs-on: ubuntu-latest
109    if: github.repository_owner == 'rust-lang'
110    env:
111      BASE_SHA: ${{ github.event.pull_request.base.sha }}
112      HEAD_SHA: ${{ github.event.pull_request.head.sha != '' && github.event.pull_request.head.sha || github.sha  }}
113    steps:
114      - uses: actions/checkout@v5
115        with:
116          fetch-depth: 0
117      - run: rustup update stable && rustup default stable
118      - name: Install cargo-semver-checks
119        run: |
120          mkdir installed-bins
121          curl -Lf https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.45.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz \
122            | tar -xz --directory=./installed-bins
123          echo `pwd`/installed-bins >> $GITHUB_PATH
124      - run: ci/validate-version-bump.sh
125
126  test:
127    runs-on: ${{ matrix.os }}
128    env:
129      CARGO_PROFILE_DEV_DEBUG: 1
130      CARGO_PROFILE_TEST_DEBUG: 1
131      CARGO_INCREMENTAL: 0
132      CARGO_PUBLIC_NETWORK_TESTS: 1
133      # Workaround for https://github.com/rust-lang/rustup/issues/3036
134      RUSTUP_WINDOWS_PATH_ADD_BIN: 0
135    strategy:
136      matrix:
137        include:
138        - name: Linux x86_64 stable
139          os: ubuntu-latest
140          rust: stable
141          other: i686-unknown-linux-gnu
142        - name: Linux x86_64 beta
143          os: ubuntu-latest
144          rust: beta
145          other: i686-unknown-linux-gnu
146        - name: Linux x86_64 nightly
147          os: ubuntu-latest
148          rust: nightly
149          other: i686-unknown-linux-gnu
150        - name: Linux aarch64 stable
151          os: ubuntu-24.04-arm
152          rust: stable
153          other: TODO # cross-compile tests are disabled, this shouldn't matter.
154        - name: Linux aarch64 nightly
155          os: ubuntu-24.04-arm
156          rust: nightly
157          other: TODO # cross-compile tests are disabled, this shouldn't matter.
158        - name: macOS aarch64 stable
159          os: macos-14
160          rust: stable
161          other: x86_64-apple-darwin
162        - name: macOS aarch64 nightly
163          os: macos-14
164          rust: nightly
165          other: x86_64-apple-darwin
166        - name: Windows x86_64 MSVC stable
167          os: windows-latest
168          rust: stable-msvc
169          other: i686-pc-windows-msvc
170        - name: Windows x86_64 MSVC nightly
171          os: windows-latest
172          rust: nightly-msvc
173          other: i686-pc-windows-msvc
174        - name: Windows aarch64 MSVC stable
175          os: windows-11-arm
176          rust: stable-msvc
177          other: i686-pc-windows-msvc
178        - name: Windows aarch64 MSVC nightly
179          os: windows-11-arm
180          rust: nightly-msvc
181          other: i686-pc-windows-msvc
182        - name: Windows x86_64 gnu nightly # runs out of space while trying to link the test suite
183          os: windows-latest
184          rust: nightly-gnu
185          other: i686-pc-windows-gnu
186    name: Tests ${{ matrix.name }}
187    steps:
188    - uses: actions/checkout@v5
189    - name: Dump Environment
190      run: ci/dump-environment.sh
191    # Some tests require stable. Make sure it is set to the most recent stable
192    # so that we can predictably handle updates if necessary (and not randomly
193    # when GitHub updates its image).
194    - run: rustup update --no-self-update stable
195    - run: rustup update --no-self-update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
196    - run: rustup target add ${{ matrix.other }}
197      if: matrix.os != 'ubuntu-24.04-arm' # cross-compile tests are disabled on ARM machines
198    - run: rustup target add wasm32-unknown-unknown
199    - run: rustup target add aarch64-unknown-none # need this for build-std mock tests
200      if: startsWith(matrix.rust, 'nightly')
201    - run: rustup component add rustc-dev llvm-tools-preview rust-docs
202      if: startsWith(matrix.rust, 'nightly')
203    - run: sudo apt update -y && sudo apt install lldb gcc-multilib libsecret-1-0 libsecret-1-dev -y
204      if: matrix.os == 'ubuntu-latest'
205    - run: rustup component add rustfmt || echo "rustfmt not available"
206    - name: Add Windows debuggers bin to PATH
207      shell: pwsh
208      run: Add-Content $env:GITHUB_PATH "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64"
209      if: matrix.os == 'windows-latest'
210    - name: Add Windows debuggers bin to PATH
211      shell: pwsh
212      run: Add-Content $env:GITHUB_PATH "C:\Program Files (x86)\Windows Kits\10\Debuggers\arm64"
213      if: matrix.os == 'windows-11-arm'
214    - name: Configure extra test environment
215      run: echo CARGO_CONTAINER_TESTS=1 >> $GITHUB_ENV
216      if: matrix.os == 'ubuntu-latest'
217    - run: cargo test -p cargo
218    - name: Clear intermediate test output
219      run: ci/clean-test-output.sh
220
221    - name: gitoxide tests (all git-related tests)
222      run: cargo test -p cargo git
223      env:
224        __CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2: 1
225      # The testsuite generates a huge amount of data, and fetch-smoke-test was
226    # running out of disk space.
227    - name: Clear test output
228      run: ci/clean-test-output.sh
229
230    # This only tests `cargo fix` because fix-proxy-mode is one of the most
231    # complicated subprocess management in Cargo.
232    - name: Check operability of rustc invocation with argfile
233      run: 'cargo test -p cargo --test testsuite -- fix::'
234      env:
235        __CARGO_TEST_FORCE_ARGFILE: 1
236    - run: cargo test --workspace --exclude cargo --exclude benchsuite --exclude resolver-tests
237    - name: Check benchmarks
238      run: |
239        # This only tests one benchmark since it can take over 10 minutes to
240        # download all workspaces.
241        cargo test -p benchsuite --all-targets -- cargo
242        cargo check -p capture
243    # The testsuite generates a huge amount of data, and fetch-smoke-test was
244    # running out of disk space.
245    - name: Clear benchmark output
246      run: ci/clean-test-output.sh
247
248    - name: Fetch smoke test
249      run: ci/fetch-smoke-test.sh
250
251  schema:
252    runs-on: ubuntu-latest
253    steps:
254    - uses: actions/checkout@v5
255    - run: rustup update stable && rustup default stable
256    - run: cargo test -p cargo-util-schemas -F unstable-schema
257
258  resolver:
259    runs-on: ubuntu-latest
260    steps:
261    - uses: actions/checkout@v5
262    - run: rustup update stable && rustup default stable
263    - run: cargo test -p resolver-tests
264
265  test_gitoxide:
266    runs-on: ubuntu-latest
267    steps:
268      - uses: actions/checkout@v5
269      - run: rustup update --no-self-update stable && rustup default stable
270      - run: rustup target add i686-unknown-linux-gnu
271      - run: rustup target add wasm32-unknown-unknown
272      - run: sudo apt update -y && sudo apt install gcc-multilib libsecret-1-0 libsecret-1-dev -y
273      - run: rustup component add rustfmt || echo "rustfmt not available"
274      - run: cargo test -p cargo
275        env:
276          __CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2: 1
277
278  build_std:
279    runs-on: ubuntu-latest
280    steps:
281    - uses: actions/checkout@v5
282    - run: rustup update nightly && rustup default nightly
283    - run: rustup component add rust-src
284    - run: cargo build
285    - run: cargo test -p cargo --test build-std
286      env:
287        CARGO_RUN_BUILD_STD_TESTS: 1
288  docs:
289    runs-on: ubuntu-latest
290    steps:
291    - uses: actions/checkout@v5
292    - run: rustup update nightly && rustup default nightly
293    - run: rustup update stable
294    - run: rustup component add rust-docs
295    - run: rustup component add rustfmt --toolchain stable
296    - run: ci/validate-man.sh
297    # This requires rustfmt, use stable.
298    - name: Run semver-check
299      run: cargo +stable run -p semver-check
300    - name: Ensure intradoc links are valid
301      run: cargo doc --workspace --document-private-items --no-deps
302      env:
303        RUSTDOCFLAGS: -D warnings
304    - name: Install mdbook
305      run: |
306        mkdir mdbook
307        curl -Lf https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
308        echo `pwd`/mdbook >> $GITHUB_PATH
309    - run: cd src/doc && mdbook build --dest-dir ../../target/doc
310    - name: Run linkchecker.sh
311      run: |
312        cd target
313        curl -sSLO https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh
314        sh linkcheck.sh --all --path ../src/doc cargo
315
316  msrv:
317    runs-on: ubuntu-latest
318    steps:
319    - uses: actions/checkout@v5
320    - uses: taiki-e/install-action@cargo-hack
321    - run: cargo hack check --all-targets --rust-version --workspace --ignore-private --locked
322
323  spellcheck:
324    name: Spell Check with Typos
325    runs-on: ubuntu-latest
326    steps:
327    - name: Checkout Actions Repository
328      uses: actions/checkout@v5
329    - name: Spell Check Repo
330      uses: crate-ci/typos@v1.40.0
331
332  report-timings:
333    name: Timing HTML report
334    runs-on: ubuntu-latest
335    steps:
336    - uses: actions/checkout@v5
337    - run: rustup update nightly && rustup default nightly
338    - run: cargo build
339    - name: Generate timing report for rustfix
340      run: |
341        cargo run -- build -p rustfix -Zbuild-analysis -Zsection-timings --config build.analysis.enabled=true --config 'build.build-dir="tmp"'
342        cargo run -- report timings -Zbuild-analysis
343    - uses: actions/upload-artifact@v6
344      with:
345        name: timing-report
346        path: target/cargo-timings/*.html
347        if-no-files-found: error