• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: bindgen
2
3on:
4  push:
5    branches:
6      - main
7  pull_request:
8    branches:
9      - main
10  merge_group:
11    branches:
12      - main
13
14jobs:
15  rustfmt-clippy:
16    runs-on: ubuntu-latest
17
18    steps:
19      - uses: actions/checkout@v4
20
21      - name: Install stable
22        uses: dtolnay/rust-toolchain@master
23        with:
24          # TODO: Should ideally be stable, but we use some nightly-only
25          # features.
26          toolchain: nightly
27          components: rustfmt, clippy
28
29      - name: Run rustfmt
30        run: cargo fmt -- --check
31
32      - name: Run clippy
33        run: cargo clippy --tests
34
35  msrv:
36    runs-on: ubuntu-latest
37    steps:
38      - uses: actions/checkout@v4
39
40      - name: Install msrv for lib
41        uses: dtolnay/rust-toolchain@master
42        with:
43          # MSRV below is documented in Cargo.toml and README.md, please update those if you
44          # change this.
45          toolchain: 1.70.0
46
47      - name: Test lib with msrv
48        run: cargo +1.70.0 test --package bindgen
49
50      - name: Install msrv for cli
51        uses: dtolnay/rust-toolchain@master
52        with:
53          # MSRV below is documented in Cargo.toml and README.md, please update those if you
54          # change this.
55          toolchain: 1.70.0
56
57      - name: Test cli with msrv
58        run: cargo +1.70.0 build --package bindgen-cli
59
60  minimal:
61    runs-on: ubuntu-latest
62    env:
63      RUSTFLAGS: -D warnings
64    steps:
65      - uses: actions/checkout@v4
66
67      - name: Install stable
68        uses: dtolnay/rust-toolchain@master
69        with:
70          toolchain: stable
71
72      - name: Check without default features
73        run: cargo check -p bindgen --no-default-features --features=runtime
74
75  docs:
76    runs-on: ubuntu-latest
77    env:
78      RUSTDOCFLAGS: -D warnings
79    steps:
80      - uses: actions/checkout@v4
81
82      - name: Install stable
83        uses: dtolnay/rust-toolchain@master
84        with:
85          toolchain: stable
86
87      - name: Generate documentation for `bindgen`
88        run: cargo doc --document-private-items --no-deps -p bindgen
89
90      - name: Generate documentation for `bindgen-cli`
91        run: cargo doc --document-private-items --no-deps -p bindgen-cli
92
93  quickchecking:
94    runs-on: ubuntu-latest
95    steps:
96      - uses: actions/checkout@v4
97
98      - name: Install stable
99        uses: dtolnay/rust-toolchain@master
100        with:
101          toolchain: stable
102
103      # TODO: Actually run quickchecks once `bindgen` is reliable enough.
104      - name: Build quickcheck tests
105        run: cd bindgen-tests/tests/quickchecking && cargo test
106
107  test-expectations:
108    runs-on: ${{matrix.os}}
109    strategy:
110      matrix:
111        os: [ubuntu-latest, macos-12]
112    steps:
113      - uses: actions/checkout@v4
114
115      - name: Install stable
116        uses: dtolnay/rust-toolchain@master
117        with:
118          toolchain: stable
119
120      - name: Test expectations
121        run: cd bindgen-tests/tests/expectations && cargo test
122
123  test:
124    runs-on: ${{matrix.os}}
125    strategy:
126      matrix:
127        os: [ubuntu-latest]
128        target:
129          - debian: null
130            cross: null
131            rust: null
132        llvm_version: ["9.0", "16.0"]
133        main_tests: [1]
134        release_build: [0, 1]
135        no_default_features: [0, 1]
136        # FIXME: There are no pre-built static libclang libraries, so the
137        # `static` feature is not testable atm.
138        feature_runtime: [0, 1]
139        feature_extra_asserts: [0]
140
141        include:
142          # Test with extra asserts + docs just with latest llvm versions to
143          # prevent explosion
144          - os: ubuntu-latest
145            llvm_version: "16.0"
146            release_build: 0
147            no_default_features: 0
148            feature_extra_asserts: 1
149
150          # FIXME: Seems installing multiarch packages fails:
151          #
152          #   https://github.com/rust-lang/rust-bindgen/pull/2037/checks?check_run_id=2441799333
153          #
154          # - os: ubuntu-latest
155          #   target:
156          #     debian: arm64
157          #     cross: aarch64-linux-gnu
158          #     rust: aarch64-unknown-linux-gnu
159          #   llvm_version: "16.0"
160          #   main_tests: 0
161          #   release_build: 0
162          #   feature_extra_asserts: 0
163
164          # Ensure stuff works on macos too
165          # FIXME: Ideally should use the latest llvm version, but llvm doesn't
166          # provide releases for x86-64 macOS anymore which is what the runner uses.
167          #
168          - os: macos-12
169            llvm_version: "9.0"
170            release_build: 0
171            no_default_features: 0
172            feature_extra_asserts: 0
173    steps:
174      - uses: actions/checkout@v4
175
176      - name: Install multiarch packages
177        if: matrix.target.debian
178        run: |
179          sudo apt-get install binfmt-support qemu-user-static gcc-${{matrix.target.cross}} g++-${{matrix.target.cross}}
180          source /etc/lsb-release
181          sudo tee /etc/apt/sources.list <<EOF >/dev/null
182          deb [arch=${{matrix.target.debian}}] http://ports.ubuntu.com/ubuntu-ports/ $DISTRIB_CODENAME main
183          deb [arch=${{matrix.target.debian}}] http://ports.ubuntu.com/ubuntu-ports/ $DISTRIB_CODENAME-updates main
184          deb [arch=${{matrix.target.debian}}] http://ports.ubuntu.com/ubuntu-ports/ $DISTRIB_CODENAME-backports main
185          deb [arch=${{matrix.target.debian}}] http://ports.ubuntu.com/ubuntu-ports/ $DISTRIB_CODENAME-security main
186          EOF
187          sudo dpkg --add-architecture ${{matrix.target.debian}}
188          sudo apt-get update
189          sudo apt-get install libc6:${{matrix.target.debian}} libstdc++6:${{matrix.target.debian}}
190
191      - name: Install stable
192        uses: dtolnay/rust-toolchain@master
193        with:
194          toolchain: stable
195          target: ${{matrix.target.rust}}
196      - name: Install libtinfo
197        if: matrix.os == 'ubuntu-latest'
198        run: |
199          sudo apt-get update
200          sudo apt-get install libtinfo5
201      - name: Run all the tests
202        env:
203          GITHUB_ACTIONS_OS: ${{matrix.os}}
204          RUST_CROSS_COMPILER: ${{matrix.target.cross}}
205          RUST_TARGET: ${{matrix.target.rust}}
206          LLVM_VERSION: ${{matrix.llvm_version}}
207          BINDGEN_MAIN_TESTS: ${{matrix.main_tests}}
208          BINDGEN_RELEASE_BUILD: ${{matrix.release_build}}
209          BINDGEN_FEATURE_RUNTIME: ${{matrix.feature_runtime}}
210          BINDGEN_FEATURE_EXTRA_ASSERTS: ${{matrix.feature_extra_asserts}}
211          BINDGEN_NO_DEFAULT_FEATURES: ${{matrix.no_default_features}}
212        run: ./ci/test.sh
213
214  check-cfg:
215    runs-on: ubuntu-latest
216    env:
217      RUSTFLAGS: -D warnings
218    steps:
219      - uses: actions/checkout@v4
220
221      - name: Install nightly
222        uses: dtolnay/rust-toolchain@master
223        with:
224          toolchain: nightly
225
226      - name: Check cfg
227        run: cargo check -Z unstable-options -Z check-cfg
228
229  test-book:
230    runs-on: ubuntu-latest
231    steps:
232      - uses: actions/checkout@v4
233
234      # NOTE(emilio): Change deploy-book as well if you change this.
235      - name: Test book
236        run: |
237          curl -L https://github.com/rust-lang/mdBook/releases/download/v0.4.5/mdbook-v0.4.5-x86_64-unknown-linux-gnu.tar.gz | tar xz
238          ./mdbook build book
239          ./mdbook test book
240
241  # One job that "summarizes" the success state of this pipeline. This can then
242  # be added to branch protection, rather than having to add each job
243  # separately.
244  success:
245    runs-on: ubuntu-latest
246    needs: [rustfmt-clippy, msrv, minimal, docs, quickchecking, test-expectations, test, check-cfg, test-book]
247    # GitHub branch protection is exceedingly silly and treats "jobs skipped
248    # because a dependency failed" as success. So we have to do some
249    # contortions to ensure the job fails if any of its dependencies fails.
250    if: always() # make sure this is never "skipped"
251    steps:
252      # Manually check the status of all dependencies. `if: failure()` does not work.
253      - name: check if any dependency failed
254        run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
255