1name: CI 2 3on: 4 push: 5 pull_request: 6 workflow_dispatch: 7 schedule: [cron: "40 1 * * *"] 8 9permissions: 10 contents: read 11 12jobs: 13 pre_ci: 14 uses: dtolnay/.github/.github/workflows/pre_ci.yml@master 15 16 test: 17 name: ${{matrix.name || format('Rust {0}', matrix.rust)}} 18 needs: pre_ci 19 if: needs.pre_ci.outputs.continue 20 runs-on: ${{matrix.os || 'ubuntu'}}-latest 21 strategy: 22 fail-fast: false 23 matrix: 24 include: 25 - rust: nightly 26 - rust: beta 27 - rust: stable 28 - rust: 1.60.0 29 - rust: 1.70.0 30 - rust: 1.74.0 31 - name: Cargo on macOS 32 rust: nightly 33 os: macos 34 - name: Cargo on Windows (msvc) 35 rust: nightly-x86_64-pc-windows-msvc 36 os: windows 37 flags: /EHsc 38 env: 39 CXXFLAGS: ${{matrix.flags}} 40 RUSTFLAGS: --cfg deny_warnings -Dwarnings 41 timeout-minutes: 45 42 steps: 43 - name: Enable symlinks (windows) 44 if: matrix.os == 'windows' 45 run: git config --global core.symlinks true 46 - uses: actions/checkout@v4 47 - uses: dtolnay/rust-toolchain@master 48 with: 49 toolchain: ${{matrix.rust}} 50 components: rust-src 51 - name: Determine test suite subset 52 # Our Windows and macOS jobs are the longest running, so exclude the 53 # relatively slow compiletest from them to speed up end-to-end CI time, 54 # except during cron builds when no human is presumably waiting on the 55 # build. The extra coverage is not particularly valuable and we can 56 # still ensure the test is kept passing on the basis of the scheduled 57 # builds. 58 run: | 59 echo RUSTFLAGS=$RUSTFLAGS >> $GITHUB_ENV 60 echo exclude=--exclude cxx-test-suite ${{matrix.rust == '1.70.0' && '--exclude cxxbridge-cmd' || ''}} >> $GITHUB_OUTPUT 61 env: 62 RUSTFLAGS: ${{env.RUSTFLAGS}} ${{matrix.os && github.event_name != 'schedule' && '--cfg skip_ui_tests' || ''}} 63 id: testsuite 64 shell: bash 65 - run: cargo run --manifest-path demo/Cargo.toml 66 - run: cargo test --workspace ${{steps.testsuite.outputs.exclude}} 67 if: matrix.rust != '1.60.0' 68 - run: cargo check --no-default-features --features alloc 69 env: 70 RUSTFLAGS: --cfg compile_error_if_std ${{env.RUSTFLAGS}} 71 - run: cargo check --no-default-features 72 env: 73 RUSTFLAGS: --cfg compile_error_if_alloc --cfg cxx_experimental_no_alloc ${{env.RUSTFLAGS}} 74 75 reindeer: 76 name: Reindeer 77 runs-on: ubuntu-latest 78 if: github.event_name != 'pull_request' 79 timeout-minutes: 45 80 steps: 81 - uses: actions/checkout@v4 82 - uses: dtolnay/rust-toolchain@stable 83 with: 84 components: rust-src 85 - uses: dtolnay/install@reindeer 86 - run: reindeer buckify 87 working-directory: third-party 88 - name: Check reindeer-generated BUCK file up to date 89 run: git diff --exit-code 90 91 bazel: 92 name: Bazel on ${{matrix.os == 'ubuntu' && 'Linux' || matrix.os == 'macos' && 'macOS' || matrix.os == 'windows' && 'Windows' || '???'}} 93 runs-on: ${{matrix.os}}-latest 94 if: github.event_name != 'pull_request' 95 strategy: 96 fail-fast: false 97 matrix: 98 os: [ubuntu, macos, windows] 99 timeout-minutes: 45 100 steps: 101 - uses: actions/checkout@v4 102 - name: Install lld 103 run: sudo apt-get install lld 104 if: matrix.os == 'ubuntu' 105 - run: bazel --version 106 - run: bazel run demo --verbose_failures --noshow_progress ${{matrix.os == 'macos' && '--xcode_version_config=tools/bazel:github_actions_xcodes' || ''}} 107 continue-on-error: ${{matrix.os == 'windows'}} # https://github.com/bazelbuild/bazel/issues/18592 108 - run: bazel test ... --verbose_failures --noshow_progress ${{matrix.os == 'macos' && '--xcode_version_config=tools/bazel:github_actions_xcodes' || ''}} 109 continue-on-error: ${{matrix.os == 'windows'}} # https://github.com/bazelbuild/bazel/issues/18592 110 111 minimal: 112 name: Minimal versions 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@nightly 120 - run: cargo generate-lockfile -Z minimal-versions 121 - run: cargo check --locked --workspace 122 123 doc: 124 name: Documentation 125 needs: pre_ci 126 if: needs.pre_ci.outputs.continue 127 runs-on: ubuntu-latest 128 timeout-minutes: 45 129 env: 130 RUSTDOCFLAGS: -Dwarnings 131 steps: 132 - uses: actions/checkout@v4 133 - uses: dtolnay/rust-toolchain@nightly 134 with: 135 components: rust-src 136 - uses: dtolnay/install@cargo-docs-rs 137 - run: cargo docs-rs 138 - run: cargo docs-rs -p cxx-build 139 - run: cargo docs-rs -p cxx-gen 140 - run: cargo docs-rs -p cxxbridge-flags 141 - run: cargo docs-rs -p cxxbridge-macro 142 143 clippy: 144 name: Clippy 145 runs-on: ubuntu-latest 146 if: github.event_name != 'pull_request' 147 timeout-minutes: 45 148 steps: 149 - uses: actions/checkout@v4 150 - uses: dtolnay/rust-toolchain@nightly 151 with: 152 components: clippy, rust-src 153 - run: cargo clippy --workspace --tests --exclude demo -- -Dclippy::all -Dclippy::pedantic 154 - run: cargo clippy --manifest-path demo/Cargo.toml -- -Dclippy::all 155 156 clang-tidy: 157 name: Clang Tidy 158 runs-on: ubuntu-latest 159 if: github.event_name != 'pull_request' 160 timeout-minutes: 45 161 steps: 162 - uses: actions/checkout@v4 163 - name: Install clang-tidy 164 run: sudo apt-get install clang-tidy-11 165 - name: Run clang-tidy 166 run: clang-tidy-11 src/cxx.cc --warnings-as-errors=* 167 168 outdated: 169 name: Outdated 170 runs-on: ubuntu-latest 171 if: github.event_name != 'pull_request' 172 timeout-minutes: 45 173 steps: 174 - uses: actions/checkout@v4 175 - uses: dtolnay/install@cargo-outdated 176 - run: cargo outdated --workspace --exit-code 1 177