• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: ci
2on:
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
26permissions:
27  # to fetch code (actions/checkout)
28  contents: read
29
30jobs:
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      TARGET:
39    runs-on: ${{ matrix.os }}
40    strategy:
41      matrix:
42        build:
43        - pinned
44        - stable
45        - stable-32
46        - stable-mips
47        - beta
48        - nightly
49        - macos
50        - win-msvc
51        - win-gnu
52        include:
53        - build: pinned
54          os: ubuntu-latest
55          rust: 1.41.1
56        - build: stable
57          os: ubuntu-latest
58          rust: stable
59        - build: stable-32
60          os: ubuntu-latest
61          rust: stable
62          target: i686-unknown-linux-gnu
63        - build: stable-mips
64          os: ubuntu-latest
65          rust: stable
66          target: mips64-unknown-linux-gnuabi64
67        - build: beta
68          os: ubuntu-latest
69          rust: beta
70        - build: nightly
71          os: ubuntu-latest
72          rust: nightly
73        - build: macos
74          os: macos-latest
75          rust: stable
76        - build: win-msvc
77          os: windows-latest
78          rust: stable
79        - build: win-gnu
80          os: windows-latest
81          rust: stable-x86_64-gnu
82    steps:
83
84    - name: Checkout repository
85      uses: actions/checkout@v3
86
87    - name: Install Rust
88      uses: dtolnay/rust-toolchain@v1
89      with:
90        toolchain: ${{ matrix.rust }}
91
92    - name: Install and configure Cross
93      if: matrix.target != ''
94      run: |
95        # We used to install 'cross' from master, but it kept failing. So now
96        # we build from a known-good version until 'cross' becomes more stable
97        # or we find an alternative. Notably, between v0.2.1 and current
98        # master (2022-06-14), the number of Cross's dependencies has doubled.
99        cargo install --bins --git https://github.com/rust-embedded/cross --tag v0.2.1
100        echo "CARGO=cross" >> $GITHUB_ENV
101        echo "TARGET=--target ${{ matrix.target }}" >> $GITHUB_ENV
102
103    - name: Show command used for Cargo
104      run: |
105        echo "cargo command is: ${{ env.CARGO }}"
106        echo "target flag is: ${{ env.TARGET }}"
107
108    - name: Show CPU info for debugging
109      if: matrix.os == 'ubuntu-latest'
110      run: lscpu
111
112    - name: Basic build
113      run: ${{ env.CARGO }} build --verbose $TARGET
114
115    - name: Build docs
116      run: ${{ env.CARGO }} doc --verbose $TARGET
117
118    # Our dev dependencies evolve more rapidly than we'd like, so only run
119    # tests when we aren't pinning the Rust version.
120    #
121    # Also, our "full" test suite does quite a lot of work, so we only run it
122    # on one build. Otherwise, we just run the "default" set of tests.
123    - name: Run subset of tests
124      if: matrix.build != 'pinned' && matrix.build != 'stable'
125      run: ${{ env.CARGO }} test --verbose --test default $TARGET
126
127    - name: Run full test suite
128      if: matrix.build == 'stable'
129      # 'stable' is Linux only, so we have bash.
130      run: ./test
131
132    - name: Run randomized tests against regexes from the wild
133      if: matrix.build == 'stable'
134      run: |
135        # We run the tests in release mode since it winds up being faster.
136        RUST_REGEX_RANDOM_TEST=1 ${{ env.CARGO }} test --release --verbose --test crates-regex $TARGET
137
138    - name: Build regex-syntax docs
139      if: matrix.build != 'pinned'
140      run: |
141        ${{ env.CARGO }} doc --verbose --manifest-path regex-syntax/Cargo.toml $TARGET
142
143    - name: Run subset of regex-syntax tests
144      if: matrix.build != 'pinned' && matrix.build != 'stable'
145      run: |
146        ${{ env.CARGO }} test --verbose --manifest-path regex-syntax/Cargo.toml $TARGET
147
148    - name: Run full regex-syntax test suite
149      if: matrix.build == 'stable'
150      run: |
151        # 'stable' is Linux only, so we have bash.
152        cd regex-syntax
153        ./test
154
155    - name: Run regex-capi tests
156      if: matrix.build == 'stable'
157      run: |
158        # 'stable' is Linux only, so we have bash.
159        cd regex-capi
160        ./test
161
162    - if: matrix.build == 'nightly'
163      name: Compile regex-debug
164      run: |
165        ${{ env.CARGO }} build --verbose --manifest-path regex-debug/Cargo.toml $TARGET
166
167    - if: matrix.build == 'nightly'
168      name: Run benchmarks as tests
169      run: |
170        cd bench
171        ./run rust --no-run --verbose
172
173    - if: matrix.build == 'nightly'
174      name: Run tests with pattern feature
175      run: |
176        cargo test --test default --no-default-features --features 'std pattern unicode-perl'
177
178  rustfmt:
179    name: rustfmt
180    runs-on: ubuntu-18.04
181    steps:
182    - name: Checkout repository
183      uses: actions/checkout@v3
184    - name: Install Rust
185      uses: dtolnay/rust-toolchain@v1
186      with:
187        toolchain: stable
188        components: rustfmt
189    - name: Check formatting
190      run: |
191        cargo fmt --all -- --check
192