fork/cargo

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

Weihang LoMove the changelog to the cargo book (#15119)5a882c1f2

0.87.0
9.4 KiB278 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
19jobs:
20  conclusion:
21    needs:
22      - build_std
23      - clippy
24      - msrv
25      - docs
26      - lint-docs
27      - lockfile
28      - resolver
29      - rustfmt
30      - test
31      - test_gitoxide
32    permissions:
33      contents: none
34    # We need to ensure this job does *not* get skipped if its dependencies fail,
35    # because a skipped job is considered a success by GitHub. So we have to
36    # overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
37    # when the workflow is canceled manually.
38    #
39    # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
40    if: ${{ !cancelled() }}
41    runs-on: ubuntu-latest
42    steps:
43      # Manually check the status of all dependencies. `if: failure()` does not work.
44      - name: Conclusion
45        run: |
46          # Print the dependent jobs to see them in the CI log
47          jq -C <<< '${{ toJson(needs) }}'
48          # Check if all jobs that we depend on (in the needs array) were successful.
49          jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
50
51  # Check Code style quickly by running `rustfmt` over all code
52  rustfmt:
53    runs-on: ubuntu-latest
54    steps:
55    - uses: actions/checkout@v4
56    - run: rustup update stable && rustup default stable
57    - run: rustup component add rustfmt
58    - run: cargo fmt --all --check
59
60  # Ensure there are no clippy warnings
61  clippy:
62    runs-on: ubuntu-latest
63    steps:
64      - uses: actions/checkout@v4
65      - run: rustup update stable && rustup default stable
66      - run: rustup component add clippy
67      - run: cargo clippy --workspace --all-targets --no-deps -- -D warnings
68
69  stale-label:
70    runs-on: ubuntu-latest
71    steps:
72      - uses: actions/checkout@v4
73      - run: rustup update stable && rustup default stable
74      - run: cargo stale-label
75
76  lint-docs:
77    runs-on: ubuntu-latest
78    steps:
79      - uses: actions/checkout@v4
80      - run: rustup update stable && rustup default stable
81      - run: cargo lint-docs --check
82
83  # Ensure Cargo.lock is up-to-date
84  lockfile:
85    runs-on: ubuntu-latest
86    steps:
87      - uses: actions/checkout@v4
88      - run: rustup update stable && rustup default stable
89      - run: cargo update -p cargo --locked
90
91  check-version-bump:
92    runs-on: ubuntu-latest
93    env:
94      BASE_SHA: ${{ github.event.pull_request.base.sha }}
95      HEAD_SHA: ${{ github.event.pull_request.head.sha != '' && github.event.pull_request.head.sha || github.sha  }}
96    steps:
97      - uses: actions/checkout@v4
98        with:
99          fetch-depth: 0
100      - run: rustup update stable && rustup default stable
101      - name: Install cargo-semver-checks
102        run: |
103          mkdir installed-bins
104          curl -Lf https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.36.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz \
105            | tar -xz --directory=./installed-bins
106          echo `pwd`/installed-bins >> $GITHUB_PATH
107      - run: ci/validate-version-bump.sh
108
109  test:
110    runs-on: ${{ matrix.os }}
111    env:
112      CARGO_PROFILE_DEV_DEBUG: 1
113      CARGO_PROFILE_TEST_DEBUG: 1
114      CARGO_INCREMENTAL: 0
115      CARGO_PUBLIC_NETWORK_TESTS: 1
116      # Workaround for https://github.com/rust-lang/rustup/issues/3036
117      RUSTUP_WINDOWS_PATH_ADD_BIN: 0
118    strategy:
119      matrix:
120        include:
121        - name: Linux x86_64 stable
122          os: ubuntu-latest
123          rust: stable
124          other: i686-unknown-linux-gnu
125        - name: Linux x86_64 beta
126          os: ubuntu-latest
127          rust: beta
128          other: i686-unknown-linux-gnu
129        - name: Linux x86_64 nightly
130          os: ubuntu-latest
131          rust: nightly
132          other: i686-unknown-linux-gnu
133        - name: macOS aarch64 stable
134          os: macos-14
135          rust: stable
136          other: x86_64-apple-darwin
137        - name: macOS x86_64 nightly
138          os: macos-13
139          rust: nightly
140          other: x86_64-apple-ios
141        - name: macOS aarch64 nightly
142          os: macos-14
143          rust: nightly
144          other: x86_64-apple-darwin
145        - name: Windows x86_64 MSVC stable
146          os: windows-latest
147          rust: stable-msvc
148          other: i686-pc-windows-msvc
149        - name: Windows x86_64 gnu nightly # runs out of space while trying to link the test suite
150          os: windows-latest
151          rust: nightly-gnu
152          other: i686-pc-windows-gnu
153    name: Tests ${{ matrix.name }}
154    steps:
155    - uses: actions/checkout@v4
156    - name: Dump Environment
157      run: ci/dump-environment.sh
158    # Some tests require stable. Make sure it is set to the most recent stable
159    # so that we can predictably handle updates if necessary (and not randomly
160    # when GitHub updates its image).
161    - run: rustup update --no-self-update stable
162    - run: rustup update --no-self-update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
163    - run: rustup target add ${{ matrix.other }}
164    - run: rustup target add wasm32-unknown-unknown
165    - run: rustup target add aarch64-unknown-none # need this for build-std mock tests
166      if: startsWith(matrix.rust, 'nightly')
167    - run: rustup component add rustc-dev llvm-tools-preview rust-docs
168      if: startsWith(matrix.rust, 'nightly')
169    - run: sudo apt update -y && sudo apt install lldb gcc-multilib libsecret-1-0 libsecret-1-dev -y
170      if: matrix.os == 'ubuntu-latest'
171    - run: rustup component add rustfmt || echo "rustfmt not available"
172    - name: Configure extra test environment
173      run: echo CARGO_CONTAINER_TESTS=1 >> $GITHUB_ENV
174      if: matrix.os == 'ubuntu-latest'
175    - run: cargo test -p cargo
176    - name: Clear intermediate test output
177      run: ci/clean-test-output.sh
178
179    - name: gitoxide tests (all git-related tests)
180      run: cargo test -p cargo git
181      env:
182        __CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2: 1
183      # The testsuite generates a huge amount of data, and fetch-smoke-test was
184    # running out of disk space.
185    - name: Clear test output
186      run: ci/clean-test-output.sh
187
188    # This only tests `cargo fix` because fix-proxy-mode is one of the most
189    # complicated subprocess management in Cargo.
190    - name: Check operability of rustc invocation with argfile
191      run: 'cargo test -p cargo --test testsuite -- fix::'
192      env:
193        __CARGO_TEST_FORCE_ARGFILE: 1
194    - run: cargo test --workspace --exclude cargo --exclude benchsuite --exclude resolver-tests
195    - name: Check benchmarks
196      run: |
197        # This only tests one benchmark since it can take over 10 minutes to
198        # download all workspaces.
199        cargo test -p benchsuite --all-targets -- cargo
200        cargo check -p capture
201    # The testsuite generates a huge amount of data, and fetch-smoke-test was
202    # running out of disk space.
203    - name: Clear benchmark output
204      run: ci/clean-test-output.sh
205
206    - name: Fetch smoke test
207      run: ci/fetch-smoke-test.sh
208
209  schema:
210    runs-on: ubuntu-latest
211    steps:
212    - uses: actions/checkout@v4
213    - run: rustup update stable && rustup default stable
214    - run: cargo test -p cargo-util-schemas -F unstable-schema
215
216  resolver:
217    runs-on: ubuntu-latest
218    steps:
219    - uses: actions/checkout@v4
220    - run: rustup update stable && rustup default stable
221    - run: cargo test -p resolver-tests
222
223  test_gitoxide:
224    runs-on: ubuntu-latest
225    steps:
226      - uses: actions/checkout@v4
227      - run: rustup update --no-self-update stable && rustup default stable
228      - run: rustup target add i686-unknown-linux-gnu
229      - run: rustup target add wasm32-unknown-unknown
230      - run: sudo apt update -y && sudo apt install gcc-multilib libsecret-1-0 libsecret-1-dev -y
231      - run: rustup component add rustfmt || echo "rustfmt not available"
232      - run: cargo test -p cargo
233        env:
234          __CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2: 1
235
236  build_std:
237    runs-on: ubuntu-latest
238    steps:
239    - uses: actions/checkout@v4
240    - run: rustup update nightly && rustup default nightly
241    - run: rustup component add rust-src
242    - run: cargo build
243    - run: cargo test -p cargo --test build-std
244      env:
245        CARGO_RUN_BUILD_STD_TESTS: 1
246  docs:
247    runs-on: ubuntu-latest
248    steps:
249    - uses: actions/checkout@v4
250    - run: rustup update nightly && rustup default nightly
251    - run: rustup update stable
252    - run: rustup component add rust-docs
253    - run: ci/validate-man.sh
254    # This requires rustfmt, use stable.
255    - name: Run semver-check
256      run: cargo +stable run -p semver-check
257    - name: Ensure intradoc links are valid
258      run: cargo doc --workspace --document-private-items --no-deps
259      env:
260        RUSTDOCFLAGS: -D warnings
261    - name: Install mdbook
262      run: |
263        mkdir mdbook
264        curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.44/mdbook-v0.4.44-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
265        echo `pwd`/mdbook >> $GITHUB_PATH
266    - run: cd src/doc && mdbook build --dest-dir ../../target/doc
267    - name: Run linkchecker.sh
268      run: |
269        cd target
270        curl -sSLO https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh
271        sh linkcheck.sh --all --path ../src/doc cargo
272
273  msrv:
274    runs-on: ubuntu-latest
275    steps:
276    - uses: actions/checkout@v4
277    - uses: taiki-e/install-action@cargo-hack
278    - run: cargo hack check --all-targets --rust-version --workspace --ignore-private --locked