1name: CI
2
3on:
4  push:
5  pull_request:
6  workflow_dispatch:
7  schedule: [cron: "40 1 * * *"]
8
9permissions:
10  contents: read
11
12env:
13  RUSTFLAGS: -Dwarnings
14
15jobs:
16  pre_ci:
17    uses: dtolnay/.github/.github/workflows/pre_ci.yml@master
18
19  test:
20    name: Tests
21    needs: pre_ci
22    if: needs.pre_ci.outputs.continue
23    runs-on: ubuntu-latest
24    timeout-minutes: 45
25    steps:
26      - uses: actions/checkout@v4
27      - uses: dtolnay/rust-toolchain@nightly
28        with:
29          components: llvm-tools, rustc-dev
30      - run: cargo test --all-features --release --tests
31
32  build:
33    name: ${{matrix.name || format('Rust {0}', matrix.rust)}}
34    needs: pre_ci
35    if: needs.pre_ci.outputs.continue
36    runs-on: ${{matrix.os || 'ubuntu'}}-latest
37    strategy:
38      fail-fast: false
39      matrix:
40        rust: [stable, beta, 1.56.0]
41        include:
42          - rust: nightly
43            components: rustc-dev
44          - rust: nightly
45            name: WebAssembly
46            target: wasm32-unknown-unknown
47          - rust: nightly
48            name: WASI
49            target: wasm32-wasi
50          - rust: nightly
51            name: Windows
52            os: windows
53    env:
54      target: ${{matrix.target && format('--target={0}', matrix.target)}}
55    timeout-minutes: 45
56    steps:
57      - uses: actions/checkout@v4
58      - uses: dtolnay/rust-toolchain@master
59        with:
60          toolchain: ${{matrix.rust}}
61          targets: ${{matrix.target}}
62          components: ${{matrix.components}}
63      - run: cargo check ${{env.target}} --no-default-features
64      - run: cargo check ${{env.target}}
65      - run: cargo check ${{env.target}} --features full
66      - run: cargo check ${{env.target}} --features 'fold visit visit-mut'
67      - run: cargo check ${{env.target}} --features 'full fold visit visit-mut'
68      - run: cargo check ${{env.target}} --no-default-features --features derive
69      - run: cargo check ${{env.target}} --no-default-features --features 'derive parsing'
70      - run: cargo check ${{env.target}} --no-default-features --features 'derive printing'
71      - run: cargo check ${{env.target}} --no-default-features --features 'proc-macro parsing printing'
72      - run: cargo check ${{env.target}} --no-default-features --features full
73      - run: cargo check ${{env.target}} --no-default-features --features 'full parsing'
74      - run: cargo check ${{env.target}} --no-default-features --features 'full printing'
75      - run: cargo check ${{env.target}} --no-default-features --features 'full parsing printing'
76      - run: cargo check ${{env.target}} --no-default-features --features 'fold visit visit-mut parsing printing'
77      - run: cargo check ${{env.target}} --no-default-features --features 'full fold visit visit-mut parsing printing'
78      - if: matrix.components == 'rustc-dev'
79        run: cargo check --benches --all-features --release
80
81  examples:
82    name: Examples
83    needs: pre_ci
84    if: needs.pre_ci.outputs.continue
85    runs-on: ubuntu-latest
86    timeout-minutes: 45
87    steps:
88      - uses: actions/checkout@v4
89      - uses: dtolnay/rust-toolchain@nightly
90      - run: cargo check --manifest-path examples/dump-syntax/Cargo.toml
91      - run: cargo check --manifest-path examples/heapsize/example/Cargo.toml
92      - run: cargo check --manifest-path examples/lazy-static/example/Cargo.toml
93      - run: cargo check --manifest-path examples/trace-var/example/Cargo.toml
94
95  doc:
96    name: Documentation
97    needs: pre_ci
98    if: needs.pre_ci.outputs.continue
99    runs-on: ubuntu-latest
100    timeout-minutes: 45
101    env:
102      RUSTDOCFLAGS: -Dwarnings
103    steps:
104      - uses: actions/checkout@v4
105      - uses: dtolnay/rust-toolchain@nightly
106      - uses: dtolnay/install@cargo-docs-rs
107      - run: cargo docs-rs
108      - run: cargo docs-rs --manifest-path json/Cargo.toml
109      - run: cargo test --all-features --doc
110
111  codegen:
112    name: Codegen
113    needs: pre_ci
114    if: needs.pre_ci.outputs.continue
115    runs-on: ubuntu-latest
116    timeout-minutes: 45
117    steps:
118      - uses: actions/checkout@v4
119      - uses: dtolnay/rust-toolchain@stable
120      - run: cargo run --manifest-path codegen/Cargo.toml
121      - run: git diff --exit-code
122
123  minimal:
124    name: Minimal versions
125    needs: pre_ci
126    if: needs.pre_ci.outputs.continue
127    runs-on: ubuntu-latest
128    timeout-minutes: 45
129    steps:
130      - uses: actions/checkout@v4
131      - uses: dtolnay/rust-toolchain@nightly
132      - run: cargo generate-lockfile -Z minimal-versions
133      - run: cargo check --all-features --locked
134
135  fuzz:
136    name: Fuzz
137    needs: pre_ci
138    if: needs.pre_ci.outputs.continue
139    runs-on: ubuntu-latest
140    timeout-minutes: 45
141    steps:
142      - uses: actions/checkout@v4
143      - uses: dtolnay/rust-toolchain@nightly
144      - uses: dtolnay/install@cargo-fuzz
145      - run: cargo fuzz check
146
147  miri:
148    name: Miri
149    needs: pre_ci
150    if: needs.pre_ci.outputs.continue
151    runs-on: ubuntu-latest
152    timeout-minutes: 45
153    steps:
154      - uses: actions/checkout@v4
155      - uses: dtolnay/rust-toolchain@miri
156      - run: cargo miri setup
157      - run: cargo miri test --all-features
158        env:
159          MIRIFLAGS: -Zmiri-strict-provenance
160
161  clippy:
162    name: Clippy
163    runs-on: ubuntu-latest
164    if: github.event_name != 'pull_request'
165    timeout-minutes: 45
166    steps:
167      - uses: actions/checkout@v4
168      - uses: dtolnay/rust-toolchain@nightly
169        with:
170          components: clippy,rustc-dev
171      - run: cargo clippy --all-features --tests --benches -- -Dclippy::all -Dclippy::pedantic
172      - run: cargo clippy --manifest-path codegen/Cargo.toml -- -Dclippy::all -Dclippy::pedantic
173
174  outdated:
175    name: Outdated
176    runs-on: ubuntu-latest
177    if: github.event_name != 'pull_request'
178    timeout-minutes: 45
179    steps:
180      - uses: actions/checkout@v4
181      - uses: dtolnay/install@cargo-outdated
182      - run: cargo outdated --workspace --exit-code 1
183      - run: cargo outdated --manifest-path fuzz/Cargo.toml --exit-code 1
184