| 1 | name: Lint Code / Run Tests |
| 2 | |
| 3 | on: |
| 4 | workflow_call: |
| 5 | workflow_dispatch: |
| 6 | push: |
| 7 | branches: |
| 8 | - "*" |
| 9 | pull_request: |
| 10 | branches: ["main"] |
| 11 | |
| 12 | concurrency: |
| 13 | group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} |
| 14 | cancel-in-progress: true |
| 15 | |
| 16 | env: |
| 17 | CARGO_TERM_COLOR: always |
| 18 | |
| 19 | jobs: |
| 20 | tests: |
| 21 | name: Run Unit Tests |
| 22 | runs-on: ${{ matrix.os }} |
| 23 | |
| 24 | continue-on-error: ${{ matrix.rust == 'nightly' }} |
| 25 | |
| 26 | strategy: |
| 27 | matrix: |
| 28 | os: [ubuntu-latest, macos-latest, windows-latest] |
| 29 | rust: [1.70.0, stable, beta, nightly] |
| 30 | |
| 31 | steps: |
| 32 | - name: Checkout repository |
| 33 | uses: actions/checkout@v4 |
| 34 | - run: rustup toolchain install ${{ matrix.rust }} --profile minimal |
| 35 | - uses: Swatinem/rust-cache@v2 |
| 36 | |
| 37 | - uses: actions/setup-python@v3 |
| 38 | |
| 39 | - name: Set up Ruby on Windows |
| 40 | if: runner.os == 'Windows' |
| 41 | uses: ruby/setup-ruby@v1 |
| 42 | with: |
| 43 | ruby-version: '3.1' |
| 44 | msys2: true |
| 45 | |
| 46 | - name: Install pre-commit dependencies |
| 47 | run: python -m pip install pre-commit |
| 48 | |
| 49 | - uses: pre-commit/[email protected] |
| 50 | name: Run pre-commit hooks |
| 51 | |
| 52 | - name: Run Rust tests |
| 53 | run: cargo test |