|
1 |
| -name: Continuous integration |
2 |
| - |
| 1 | +# Adapted from https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/ci.yml |
| 2 | +# |
| 3 | +name: ci |
3 | 4 | on:
|
4 | 5 | pull_request:
|
5 |
| - types: [push, synchronize, opened, reopened] |
6 | 6 | push:
|
7 |
| - branches: [main] |
| 7 | + branches: |
| 8 | + - main |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
8 | 12 |
|
9 | 13 | jobs:
|
10 |
| - clippy_check: |
11 |
| - name: Lint |
| 14 | + test: |
| 15 | + name: test |
| 16 | + env: |
| 17 | + # For some builds, we use cross to test on 32-bit and big-endian |
| 18 | + # systems. |
| 19 | + CARGO: cargo |
| 20 | + # When CARGO is set to CROSS, this is set to `--target matrix.target`. |
| 21 | + # Note that we only use cross on Linux, so setting a target on a |
| 22 | + # different OS will just use normal cargo. |
| 23 | + TARGET_FLAGS: |
| 24 | + # When CARGO is set to CROSS, TARGET_DIR includes matrix.target. |
| 25 | + TARGET_DIR: ./target |
| 26 | + # Bump this as appropriate. We pin to a version to make sure CI |
| 27 | + # continues to work as cross releases in the past have broken things |
| 28 | + # in subtle ways. |
| 29 | + CROSS_VERSION: v0.2.5 |
| 30 | + # Emit backtraces on panics. |
| 31 | + RUST_BACKTRACE: 1 |
| 32 | + # To ensure openssl is static linked |
| 33 | + OPENSSL_STATIC: 1 |
| 34 | + runs-on: ${{ matrix.os }} |
| 35 | + strategy: |
| 36 | + fail-fast: false |
| 37 | + matrix: |
| 38 | + include: |
| 39 | + - build: pinned |
| 40 | + os: ubuntu-latest |
| 41 | + rust: 1.74.0 |
| 42 | + - build: stable |
| 43 | + os: ubuntu-latest |
| 44 | + rust: stable |
| 45 | + - build: beta |
| 46 | + os: ubuntu-latest |
| 47 | + rust: beta |
| 48 | + - build: nightly |
| 49 | + os: ubuntu-latest |
| 50 | + rust: nightly |
| 51 | + - build: stable-musl |
| 52 | + os: ubuntu-latest |
| 53 | + rust: stable |
| 54 | + target: x86_64-unknown-linux-musl |
| 55 | + - build: stable-x86 |
| 56 | + os: ubuntu-latest |
| 57 | + rust: stable |
| 58 | + target: i686-unknown-linux-gnu |
| 59 | + - build: stable-aarch64 |
| 60 | + os: ubuntu-latest |
| 61 | + rust: stable |
| 62 | + target: aarch64-unknown-linux-gnu |
| 63 | + - build: stable-powerpc64 |
| 64 | + os: ubuntu-latest |
| 65 | + rust: stable |
| 66 | + target: powerpc64-unknown-linux-gnu |
| 67 | + - build: stable-s390x |
| 68 | + os: ubuntu-latest |
| 69 | + rust: stable |
| 70 | + target: s390x-unknown-linux-gnu |
| 71 | + - build: macos |
| 72 | + os: macos-latest |
| 73 | + rust: nightly |
| 74 | + - build: win-msvc |
| 75 | + os: windows-2022 |
| 76 | + rust: nightly |
| 77 | + - build: win-gnu |
| 78 | + os: windows-2022 |
| 79 | + rust: nightly-x86_64-gnu |
| 80 | + steps: |
| 81 | + - name: Checkout repository |
| 82 | + uses: actions/checkout@v4 |
| 83 | + |
| 84 | + - name: Install Rust |
| 85 | + uses: dtolnay/rust-toolchain@master |
| 86 | + with: |
| 87 | + toolchain: ${{ matrix.rust }} |
| 88 | + |
| 89 | + - name: Use Cross |
| 90 | + if: matrix.os == 'ubuntu-latest' && matrix.target != '' |
| 91 | + run: | |
| 92 | + # In the past, new releases of 'cross' have broken CI. So for now, we |
| 93 | + # pin it. We also use their pre-compiled binary releases because cross |
| 94 | + # has over 100 dependencies and takes a bit to compile. |
| 95 | + dir="$RUNNER_TEMP/cross-download" |
| 96 | + mkdir "$dir" |
| 97 | + echo "$dir" >> $GITHUB_PATH |
| 98 | + cd "$dir" |
| 99 | + curl -LO "https://github.com/cross-rs/cross/releases/download/$CROSS_VERSION/cross-x86_64-unknown-linux-musl.tar.gz" |
| 100 | + tar xf cross-x86_64-unknown-linux-musl.tar.gz |
| 101 | + echo "CARGO=cross" >> $GITHUB_ENV |
| 102 | + echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV |
| 103 | + echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV |
| 104 | + echo "CROSS_CONTAINER_OPTS=${{matrix.flags}}" >> $GITHUB_ENV |
| 105 | +
|
| 106 | + - name: Show command used for Cargo |
| 107 | + run: | |
| 108 | + echo "cargo command is: ${{ env.CARGO }}" |
| 109 | + echo "target flag is: ${{ env.TARGET_FLAGS }}" |
| 110 | + echo "target dir is: ${{ env.TARGET_DIR }}" |
| 111 | + echo "flags are: ${{ env.CROSS_CONTAINER_OPTS }}" |
| 112 | +
|
| 113 | + - name: Build lib |
| 114 | + run: ${{ env.CARGO }} build --verbose --workspace ${{ env.TARGET_FLAGS }} |
| 115 | + |
| 116 | + # This is useful for debugging problems when the expected build artifacts |
| 117 | + # (like shell completions and man pages) aren't generated. |
| 118 | + - name: Show build.rs stderr |
| 119 | + shell: bash |
| 120 | + run: | |
| 121 | + set +x |
| 122 | + stderr="$(find "${{ env.TARGET_DIR }}/debug" -name stderr -print0 | xargs -0 ls -t | head -n1)" |
| 123 | + if [ -s "$stderr" ]; then |
| 124 | + echo "===== $stderr ===== " |
| 125 | + cat "$stderr" |
| 126 | + echo "=====" |
| 127 | + fi |
| 128 | + set -x |
| 129 | +
|
| 130 | + - name: Run tests (with cross) |
| 131 | + if: matrix.target != '' |
| 132 | + run: ${{ env.CARGO }} test --verbose --workspace ${{ env.TARGET_FLAGS }} |
| 133 | + |
| 134 | + rustfmt: |
12 | 135 | runs-on: ubuntu-latest
|
13 | 136 | steps:
|
14 |
| - - uses: actions/checkout@v2 |
15 |
| - - uses: actions-rs/toolchain@v1 |
16 |
| - with: |
17 |
| - toolchain: stable |
18 |
| - components: clippy |
19 |
| - - uses: actions-rs/clippy-check@v1 |
20 |
| - with: |
21 |
| - token: ${{ secrets.GITHUB_TOKEN }} |
22 |
| - args: --features compression,tokio-comp |
23 |
| - build_and_test: |
24 |
| - name: Build CI |
| 137 | + - name: Checkout repository |
| 138 | + uses: actions/checkout@v4 |
| 139 | + - name: Install Rust |
| 140 | + uses: dtolnay/rust-toolchain@master |
| 141 | + with: |
| 142 | + toolchain: stable |
| 143 | + components: rustfmt |
| 144 | + - name: Check formatting |
| 145 | + run: cargo fmt --all --check |
| 146 | + |
| 147 | + clippy: |
| 148 | + runs-on: ubuntu-latest |
| 149 | + steps: |
| 150 | + - name: Checkout repository |
| 151 | + uses: actions/checkout@v4 |
| 152 | + - name: Install Rust |
| 153 | + uses: dtolnay/rust-toolchain@master |
| 154 | + with: |
| 155 | + toolchain: stable |
| 156 | + components: rustfmt |
| 157 | + - name: Clippy |
| 158 | + run: cargo clippy -- -D warnings |
| 159 | + |
| 160 | + docs: |
25 | 161 | runs-on: ubuntu-latest
|
26 | 162 | steps:
|
27 |
| - - uses: actions/checkout@v2 |
28 |
| - - uses: actions-rs/toolchain@v1 |
| 163 | + - name: Checkout repository |
| 164 | + uses: actions/checkout@v4 |
| 165 | + - name: Install Rust |
| 166 | + uses: dtolnay/rust-toolchain@master |
29 | 167 | with:
|
30 | 168 | toolchain: stable
|
31 |
| - - name: Check with tokio-comp |
32 |
| - run: cargo check --features tokio-comp |
33 |
| - - name: Check with async-std-comp |
34 |
| - run: cargo check --features async-std-comp |
35 |
| - - name: Check with async-std-comp and compression |
36 |
| - run: cargo check --features async-std-comp,compression |
37 |
| - - name: Check with tokio-comp and compression |
38 |
| - run: cargo check --features tokio-comp,compression |
39 |
| - - name: Test with tokio-comp |
40 |
| - run: cargo test --features tokio-comp |
41 |
| - - name: Test with async-std-comp |
42 |
| - run: cargo test --features async-std-comp |
43 |
| - - name: Test with async-std-comp and compression |
44 |
| - run: cargo test --features async-std-comp,compression |
45 |
| - - name: Test with tokio-comp and compression |
46 |
| - run: cargo test --features tokio-comp,compression |
47 |
| - - name: Clean |
48 |
| - run: cargo clean |
| 169 | + - name: Check documentation |
| 170 | + env: |
| 171 | + RUSTDOCFLAGS: -D warnings |
| 172 | + run: cargo doc --no-deps --document-private-items --workspace |
0 commit comments