• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: bindgen
2
3on:
4  push:
5    branches:
6      - main
7  pull_request:
8    branches:
9      - main
10
11jobs:
12  rustfmt-clippy:
13    runs-on: ubuntu-latest
14
15    steps:
16      - uses: actions/checkout@v3
17
18      - name: Install stable
19        uses: actions-rs/toolchain@v1
20        with:
21          profile: minimal
22          # TODO: Should ideally be stable, but we use some nightly-only
23          # features.
24          toolchain: nightly
25          override: true
26          components: rustfmt, clippy
27
28      - name: Run rustfmt
29        uses: actions-rs/cargo@v1
30        with:
31          command: fmt
32          args: -- --check
33
34      - name: Run clippy
35        uses: actions-rs/cargo@v1
36        with:
37          command: clippy
38          args: --tests
39
40  msrv:
41    runs-on: ubuntu-latest
42    steps:
43      - uses: actions/checkout@v3
44
45      - name: Install msrv
46        uses: actions-rs/toolchain@v1
47        with:
48          profile: minimal
49          # MSRV below is documented in Cargo.toml and README.md, please update those if you
50          # change this.
51          toolchain: 1.60.0
52          override: true
53
54      - name: Build with msrv
55        run: rm Cargo.lock && cargo +1.60.0 build --lib
56
57  quickchecking:
58    runs-on: ubuntu-latest
59    steps:
60      - uses: actions/checkout@v3
61
62      - name: Install stable
63        uses: actions-rs/toolchain@v1
64        with:
65          profile: minimal
66          toolchain: stable
67          override: true
68
69      # TODO: Actually run quickchecks once `bindgen` is reliable enough.
70      - name: Build quickcheck tests
71        run: cd bindgen-tests/tests/quickchecking && cargo test
72
73  test-expectations:
74    runs-on: ${{matrix.os}}
75    strategy:
76      matrix:
77        # TODO(#1954): These should be run on mac too, but turns out they're
78        # broken.
79        os: [ubuntu-latest, macos-latest]
80    steps:
81      - uses: actions/checkout@v3
82
83      - name: Install stable
84        uses: actions-rs/toolchain@v1
85        with:
86          profile: minimal
87          toolchain: stable
88          override: true
89
90      - name: Test expectations
91        run: cd bindgen-tests/tests/expectations && cargo test
92
93  test:
94    runs-on: ${{matrix.os}}
95    strategy:
96      matrix:
97        os: [ubuntu-latest]
98        target:
99          - debian: null
100            cross: null
101            rust: null
102        llvm_version: ["5.0", "9.0"]
103        main_tests: [1]
104        release_build: [0, 1]
105        no_default_features: [0, 1]
106        # FIXME: There are no pre-built static libclang libraries, so the
107        # `static` feature is not testable atm.
108        feature_runtime: [0, 1]
109        feature_extra_asserts: [0]
110        feature_testing_only_docs: [0]
111
112        include:
113          # Test with extra asserts + docs just with latest llvm versions to
114          # prevent explosion
115          - os: ubuntu-latest
116            llvm_version: "9.0"
117            release_build: 0
118            no_default_features: 0
119            feature_extra_asserts: 1
120            feature_testing_only_docs: 1
121
122          # FIXME: Seems installing multiarch packages fails:
123          #
124          #   https://github.com/rust-lang/rust-bindgen/pull/2037/checks?check_run_id=2441799333
125          #
126          # - os: ubuntu-latest
127          #   target:
128          #     debian: arm64
129          #     cross: aarch64-linux-gnu
130          #     rust: aarch64-unknown-linux-gnu
131          #   llvm_version: "9.0"
132          #   main_tests: 0
133          #   release_build: 0
134          #   feature_extra_asserts: 0
135          #   feature_testing_only_docs: 0
136
137          # Ensure stuff works on macos too
138          - os: macos-latest
139            llvm_version: "9.0"
140            release_build: 0
141            no_default_features: 0
142            feature_extra_asserts: 0
143            feature_testing_only_docs: 0
144    steps:
145      - uses: actions/checkout@v3
146
147      - name: Install multiarch packages
148        if: matrix.target.debian
149        run: |
150          sudo apt-get install binfmt-support qemu-user-static gcc-${{matrix.target.cross}} g++-${{matrix.target.cross}}
151          source /etc/lsb-release
152          sudo tee /etc/apt/sources.list <<EOF >/dev/null
153          deb [arch=${{matrix.target.debian}}] http://ports.ubuntu.com/ubuntu-ports/ $DISTRIB_CODENAME main
154          deb [arch=${{matrix.target.debian}}] http://ports.ubuntu.com/ubuntu-ports/ $DISTRIB_CODENAME-updates main
155          deb [arch=${{matrix.target.debian}}] http://ports.ubuntu.com/ubuntu-ports/ $DISTRIB_CODENAME-backports main
156          deb [arch=${{matrix.target.debian}}] http://ports.ubuntu.com/ubuntu-ports/ $DISTRIB_CODENAME-security main
157          EOF
158          sudo dpkg --add-architecture ${{matrix.target.debian}}
159          sudo apt-get update
160          sudo apt-get install libc6:${{matrix.target.debian}} libstdc++6:${{matrix.target.debian}}
161
162      - name: Install stable
163        uses: actions-rs/toolchain@v1
164        with:
165          profile: minimal
166          toolchain: stable
167          target: ${{matrix.target.rust}}
168          override: true
169      - name: Install libtinfo
170        if: matrix.os == 'ubuntu-latest'
171        run: |
172          sudo apt-get update
173          sudo apt-get install libtinfo5
174      - name: Run all the tests
175        env:
176          GITHUB_ACTIONS_OS: ${{matrix.os}}
177          RUST_CROSS_COMPILER: ${{matrix.target.cross}}
178          RUST_TARGET: ${{matrix.target.rust}}
179          LLVM_VERSION: ${{matrix.llvm_version}}
180          BINDGEN_MAIN_TESTS: ${{matrix.main_tests}}
181          BINDGEN_RELEASE_BUILD: ${{matrix.release_build}}
182          BINDGEN_FEATURE_RUNTIME: ${{matrix.feature_runtime}}
183          BINDGEN_FEATURE_EXTRA_ASSERTS: ${{matrix.feature_extra_asserts}}
184          BINDGEN_FEATURE_TESTING_ONLY_DOCS: ${{matrix.feature_testing_only_docs}}
185          BINDGEN_NO_DEFAULT_FEATURES: ${{matrix.no_default_features}}
186        run: ./ci/test.sh
187
188  test-book:
189    runs-on: ubuntu-latest
190    steps:
191      - uses: actions/checkout@v3
192
193      - name: Install stable
194        uses: actions-rs/toolchain@v1
195        with:
196          profile: minimal
197          toolchain: stable
198          override: true
199
200      # NOTE(emilio): Change deploy-book as well if you change this.
201      - name: Test book
202        run: |
203          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
204          ./mdbook build book
205          ./mdbook test book
206