|
| 1 | +name: ci |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + schedule: |
| 8 | + - cron: '00 01 * * *' |
| 9 | + |
| 10 | +# The section is needed to drop write-all permissions that are granted on |
| 11 | +# `schedule` event. By specifying any permission explicitly all others are set |
| 12 | +# to none. By using the principle of least privilege the damage a compromised |
| 13 | +# workflow can do (because of an injection or compromised third party tool or |
| 14 | +# action) is restricted. Currently the worklow doesn't need any additional |
| 15 | +# permission except for pulling the code. Adding labels to issues, commenting |
| 16 | +# on pull-requests, etc. may need additional permissions: |
| 17 | +# |
| 18 | +# Syntax for this section: |
| 19 | +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions |
| 20 | +# |
| 21 | +# Reference for how to assign permissions on a job-by-job basis: |
| 22 | +# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs |
| 23 | +# |
| 24 | +# Reference for available permissions that we can enable if needed: |
| 25 | +# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token |
| 26 | +permissions: |
| 27 | + # to fetch code (actions/checkout) |
| 28 | + contents: read |
| 29 | + |
| 30 | +jobs: |
| 31 | + test: |
| 32 | + name: test |
| 33 | + env: |
| 34 | + # For some builds, we use cross to test on 32-bit and big-endian |
| 35 | + # systems. |
| 36 | + CARGO: cargo |
| 37 | + # When CARGO is set to CROSS, TARGET is set to `--target matrix.target`. |
| 38 | + # Note that we only use cross on Linux, so setting a target on a |
| 39 | + # different OS will just use normal cargo. |
| 40 | + TARGET: |
| 41 | + # Bump this as appropriate. We pin to a version to make sure CI |
| 42 | + # continues to work as cross releases in the past have broken things |
| 43 | + # in subtle ways. |
| 44 | + CROSS_VERSION: v0.2.5 |
| 45 | + runs-on: ${{ matrix.os }} |
| 46 | + strategy: |
| 47 | + fail-fast: false |
| 48 | + matrix: |
| 49 | + include: |
| 50 | + - build: pinned |
| 51 | + os: ubuntu-latest |
| 52 | + rust: 1.60.0 |
| 53 | + - build: stable |
| 54 | + os: ubuntu-latest |
| 55 | + rust: stable |
| 56 | + - build: stable-x86 |
| 57 | + os: ubuntu-latest |
| 58 | + rust: stable |
| 59 | + target: i686-unknown-linux-gnu |
| 60 | + - build: stable-aarch64 |
| 61 | + os: ubuntu-latest |
| 62 | + rust: stable |
| 63 | + target: aarch64-unknown-linux-gnu |
| 64 | + - build: stable-powerpc64 |
| 65 | + os: ubuntu-latest |
| 66 | + rust: stable |
| 67 | + target: powerpc64-unknown-linux-gnu |
| 68 | + - build: stable-s390x |
| 69 | + os: ubuntu-latest |
| 70 | + rust: stable |
| 71 | + target: s390x-unknown-linux-gnu |
| 72 | + - build: beta |
| 73 | + os: ubuntu-latest |
| 74 | + rust: beta |
| 75 | + - build: nightly |
| 76 | + os: ubuntu-latest |
| 77 | + rust: nightly |
| 78 | + - build: macos |
| 79 | + os: macos-latest |
| 80 | + rust: stable |
| 81 | + - build: win-msvc |
| 82 | + os: windows-latest |
| 83 | + rust: stable |
| 84 | + - build: win-gnu |
| 85 | + os: windows-latest |
| 86 | + rust: stable-x86_64-gnu |
| 87 | + steps: |
| 88 | + - name: Checkout repository |
| 89 | + uses: actions/checkout@v3 |
| 90 | + - name: Install Rust |
| 91 | + uses: dtolnay/rust-toolchain@master |
| 92 | + with: |
| 93 | + toolchain: ${{ matrix.rust }} |
| 94 | + - name: Install and configure Cross |
| 95 | + if: matrix.os == 'ubuntu-latest' && matrix.target != '' |
| 96 | + run: | |
| 97 | + # In the past, new releases of 'cross' have broken CI. So for now, we |
| 98 | + # pin it. We also use their pre-compiled binary releases because cross |
| 99 | + # has over 100 dependencies and takes a bit to compile. |
| 100 | + dir="$RUNNER_TEMP/cross-download" |
| 101 | + mkdir "$dir" |
| 102 | + echo "$dir" >> $GITHUB_PATH |
| 103 | + cd "$dir" |
| 104 | + curl -LO "https://github.com/cross-rs/cross/releases/download/$CROSS_VERSION/cross-x86_64-unknown-linux-musl.tar.gz" |
| 105 | + tar xf cross-x86_64-unknown-linux-musl.tar.gz |
| 106 | +
|
| 107 | + # We used to install 'cross' from master, but it kept failing. So now |
| 108 | + # we build from a known-good version until 'cross' becomes more stable |
| 109 | + # or we find an alternative. Notably, between v0.2.1 and current |
| 110 | + # master (2022-06-14), the number of Cross's dependencies has doubled. |
| 111 | + echo "CARGO=cross" >> $GITHUB_ENV |
| 112 | + echo "TARGET=--target ${{ matrix.target }}" >> $GITHUB_ENV |
| 113 | + - name: Show command used for Cargo |
| 114 | + run: | |
| 115 | + echo "cargo command is: ${{ env.CARGO }}" |
| 116 | + echo "target flag is: ${{ env.TARGET }}" |
| 117 | + - name: Show CPU info for debugging |
| 118 | + if: matrix.os == 'ubuntu-latest' |
| 119 | + run: lscpu |
| 120 | + # See: https://github.com/rust-lang/regex/blob/a2887636930156023172e4b376a6febad4e49120/.github/workflows/ci.yml#L145-L163 |
| 121 | + - name: Pin memchr to 2.6.2 |
| 122 | + if: matrix.build == 'pinned' |
| 123 | + run: cargo update -p memchr --precise 2.6.2 |
| 124 | + - run: ${{ env.CARGO }} build --verbose $TARGET |
| 125 | + - run: ${{ env.CARGO }} doc --verbose $TARGET |
| 126 | + - run: ${{ env.CARGO }} test --verbose $TARGET |
| 127 | + - run: ${{ env.CARGO }} test --lib --verbose --no-default-features --features std,perf-literal $TARGET |
| 128 | + - run: ${{ env.CARGO }} test --lib --verbose --no-default-features $TARGET |
| 129 | + - run: ${{ env.CARGO }} test --lib --verbose --no-default-features --features std $TARGET |
| 130 | + - run: ${{ env.CARGO }} test --lib --verbose --no-default-features --features perf-literal $TARGET |
| 131 | + - run: ${{ env.CARGO }} test --lib --verbose --no-default-features --features std,perf-literal,logging $TARGET |
| 132 | + - if: matrix.build == 'nightly' |
| 133 | + run: ${{ env.CARGO }} build --manifest-path aho-corasick-debug/Cargo.toml $TARGET |
| 134 | + |
| 135 | + rustfmt: |
| 136 | + name: rustfmt |
| 137 | + runs-on: ubuntu-latest |
| 138 | + steps: |
| 139 | + - name: Checkout repository |
| 140 | + uses: actions/checkout@v3 |
| 141 | + - name: Install Rust |
| 142 | + uses: dtolnay/rust-toolchain@master |
| 143 | + with: |
| 144 | + toolchain: stable |
| 145 | + components: rustfmt |
| 146 | + - name: Check formatting |
| 147 | + run: | |
| 148 | + cargo fmt --all -- --check |
0 commit comments