File: ci.yml

package info (click to toggle)
jujutsu 0.30.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 9,756 kB
  • sloc: sh: 283; makefile: 31
file content (341 lines) | stat: -rw-r--r-- 11,258 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
name: ci

on:
  pull_request:
  merge_group:

concurrency:
  group: >-
    ${{ github.workflow }}-${{
      github.event.pull_request.number
      || github.event.merge_group.head_ref
    }}
  cancel-in-progress: true

permissions: {}

jobs:
  test:
    strategy:
      fail-fast: ${{ github.event_name == 'merge_group' }}
      matrix:
        build: [linux-x86_64-gnu, linux-aarch64-gnu, macos-x86_64, macos-aarch64, windows-x86_64]
        include:
        - build: linux-x86_64-gnu
          os: ubuntu-24.04
          cargo_flags: "--all-features"
        - build: linux-aarch64-gnu
          os: ubuntu-24.04-arm
          cargo_flags: "--all-features"
        - build: macos-x86_64
          os: macos-13
          cargo_flags: ""
        - build: macos-aarch64
          os: macos-14
          cargo_flags: ""
        - build: windows-x86_64
          os: windows-2022
          cargo_flags: ""
    runs-on: ${{ matrix.os }}

    # TODO FIXME (aseipp): keep the timeout limit to ~20 minutes. this is long
    # enough to give us runway for the future, but also once we hit it, we're at
    # the "builds are taking too long" stage and we should start looking at ways
    # to optimize the CI, or the CI is flaking out on some weird spiked machine
    #
    # at the same time, this avoids some issues where some flaky, bugged tests
    # seem to be causing multi-hour runs on Windows (GPG signing issues), which
    # is a problem we should fix. in the mean time, this will make these flakes
    # less harmful, as it won't cause builds to spin for multiple hours, requiring
    # manual cancellation.
    timeout-minutes: 20

    steps:
    - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        persist-credentials: false
    - name: Set up Windows Builders
      if: startswith(matrix.os, 'windows')
      uses: ./.github/actions/setup-windows
    - name: Install Rust
      uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
      with:
        toolchain: 1.84
    - uses: taiki-e/install-action@735e5933943122c5ac182670a935f54a949265c1
      with:
        tool: nextest,taplo-cli
    - name: Install mold
      uses: rui314/setup-mold@67424c1b3680e35255d95971cbd5de0047bf31c3
      with:
        make-default: false
    - name: Build
      run: >-
        cargo build
        --config .cargo/config-ci.toml
        --workspace
        --all-targets
        --verbose
        ${{ matrix.cargo_flags }}
    - name: Test
      run: >-
        cargo nextest run
        --config .cargo/config-ci.toml
        --workspace
        --all-targets
        --verbose
        --profile ci
        ${{ matrix.cargo_flags }}
      env:
        RUST_BACKTRACE: 1
        CARGO_TERM_COLOR: always

  no-git:
    name: build (no git)
    runs-on: ubuntu-24.04
    steps:
    - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        persist-credentials: false
    - name: Install Rust
      uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
      with:
        toolchain: 1.84
    - name: Build
      run: cargo build -p jj-cli --no-default-features --verbose

  build-nix:
    name: nix flake
    strategy:
      fail-fast: ${{ github.event_name == 'merge_group' }}
      matrix:
        os: [ubuntu-24.04, ubuntu-24.04-arm, macos-14]
    runs-on: ${{ matrix.os }}
    timeout-minutes: 15

    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          fetch-depth: 0
          persist-credentials: false
      - uses: DeterminateSystems/nix-installer-action@21a544727d0c62386e78b4befe52d19ad12692e3
      - run: nix flake check -L --show-trace

  check-protos:
    name: check (protos)
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
        with:
          toolchain: stable
      - run: sudo apt update && sudo apt-get -y install protobuf-compiler
      - name: Generate Rust code from .proto files
        run: cargo run -p gen-protos
      - name: Check for uncommitted changes
        run: git diff --exit-code

  check-rustfmt:
    name: check (rustfmt)
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
        with:
          toolchain: nightly
          components: rustfmt
      - run: cargo +nightly fmt --all -- --check

  check-clippy:
    name: check (clippy)
    permissions:
      checks: write
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
        with:
          toolchain: stable
          components: clippy
      - run: cargo +stable clippy --all-features --workspace --all-targets -- -D warnings

  check-cargo-deny:
    runs-on: ubuntu-24.04
    strategy:
      matrix:
        checks:
          - advisories
          - bans
          - licenses
          - sources

    # Prevent sudden announcement of a new advisory from failing ci:
    continue-on-error: ${{ matrix.checks == 'advisories' }}

    name: check (cargo-deny, ${{ matrix.checks }})
    steps:
    - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        persist-credentials: false
    - uses: EmbarkStudios/cargo-deny-action@34899fc7ba81ca6268d5947a7a16b4649013fea1
      with:
        command: check ${{ matrix.checks }}

  check-codespell:
    name: check (codespell)
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          persist-credentials: false
      - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
        with:
          python-version: 3.11
      - name: Install uv
        uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb
        with:
          # If you bump the version, also update docs/contributing.md
          # and all other workflows that install uv
          version: "0.5.1"
      - name: Run Codespell
        run: uv run -- codespell && echo Codespell exited successfully

  check-doctests:
    name: check (doctests)
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
        with:
          toolchain: 1.84
      # NOTE: We need to run `cargo test --doc` separately from normal tests:
      # - `cargo build --all-targets` specifies: "Build all targets"
      # - `cargo test --all-targets` specifies: "Test all targets (does not include doctests)"
      - name: Run doctests
        run: cargo test --workspace --doc
        env:
          RUST_BACKTRACE: 1
      - name: Check `cargo doc` for lint issues
        env:
          RUSTDOCFLAGS: "--deny warnings"
        run: cargo doc --workspace --no-deps

  check-mkdocs:
    name: check (mkdocs)
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          persist-credentials: false
      - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
        with:
          python-version: 3.11
      - name: Install uv
        uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb
        with:
          # If you bump the version, also update docs/contributing.md
          # and all other workflows that install uv
          version: "0.5.1"
      - name: Check that `mkdocs` can build the docs
        run: uv run -- mkdocs build --strict

  # An optional job to alert us when uv updates break the build
  check-mkdocs-latest:
    name: check (latest mkdocs, optional)
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          persist-credentials: false
      - name: Install uv
        uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb
      # 'only-managed' means that uv will always download Python, even
      # if the runner happens to provide a compatible version
      - name: Check that `mkdocs` can build the docs
        run: uv run --python-preference=only-managed -- mkdocs build --strict

  check-zizmor:
    name: check (zizmor)
    runs-on: ubuntu-latest
    permissions:
      security-events: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          persist-credentials: false

      - name: Install the latest version of uv
        uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb

      - name: Run zizmor
        run: uvx zizmor --format sarif . > results.sarif
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Upload SARIF file
        uses: github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f
        with:
          sarif_file: results.sarif
          category: zizmor

  # Count the (very approximate) number of dependencies in Cargo.lock and bail at a certain limit.
  check-cargo-lock-bloat:
    name: check (Cargo.lock dependency count)
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          persist-credentials: false
      - name: Check total dependency count in Cargo.lock
        run: |
          total_deps=$(./.github/scripts/count-cargo-lock-packages)
          if [ "$total_deps" -gt "${TOTAL_DEP_LIMIT}" ]; then
            ./.github/scripts/dragon-bureaucrat \
              "Cargo.lock has too many dependencies ($total_deps > ${TOTAL_DEP_LIMIT}). The Dragon banishes thee!

                 You can raise the limit in \`.github/workflows/ci.yml\` if necessary, but
                 consider whether it’s possible to trim things down first."
          else
            echo "Counted $total_deps Cargo.lock dependencies." \
                 "This is within the allowed limit of ${TOTAL_DEP_LIMIT}."
          fi
        env:
          # This limit *can* be raised, we just want to be aware if we exceed it
          TOTAL_DEP_LIMIT: 500

  # Block the merge if required checks fail, but only in the merge
  # queue. See also `required-checks-hack.yml`.
  required-checks:
    name: required checks (merge queue)
    if: ${{ always() && github.event_name == 'merge_group' }}
    needs:
    - test
    - no-git
    - build-nix
    - check-protos
    - check-rustfmt
    - check-clippy
    - check-cargo-deny
    - check-codespell
    - check-doctests
    - check-mkdocs
    # - check-mkdocs-latest
    # - check-zizmor
    - check-cargo-lock-bloat
    runs-on: ubuntu-latest
    steps:
    - name: Block merge if required checks fail
      if: >-
        ${{
          contains(needs.*.result, 'failure')
          || contains(needs.*.result, 'cancelled')
        }}
      run: exit 1