| 1 | name: Test |
| 2 | |
| 3 | on: |
| 4 | - push |
| 5 | - pull_request |
| 6 | |
| 7 | jobs: |
| 8 | |
| 9 | lint: |
| 10 | runs-on: ubuntu-latest |
| 11 | steps: |
| 12 | - name: Checkout code |
| 13 | uses: actions/checkout@v3 |
| 14 | - name: Setup Rust stable |
| 15 | uses: actions-rs/toolchain@v1 |
| 16 | with: |
| 17 | profile: minimal |
| 18 | toolchain: stable |
| 19 | override: true |
| 20 | components: rustfmt |
| 21 | - name: Check code format |
| 22 | uses: actions-rs/cargo@v1 |
| 23 | with: |
| 24 | command: fmt |
| 25 | args: --all -- --check |
| 26 | |
| 27 | test: |
| 28 | needs: lint |
| 29 | runs-on: ubuntu-latest |
| 30 | strategy: |
| 31 | matrix: |
| 32 | rust-toolchain: |
| 33 | - stable |
| 34 | - beta |
| 35 | - nightly |
| 36 | steps: |
| 37 | - name: Checkout code |
| 38 | uses: actions/checkout@v3 |
| 39 | - name: Setup Rust ${{ matrix.rust-toolchain }} |
| 40 | uses: actions-rs/toolchain@v1 |
| 41 | with: |
| 42 | profile: minimal |
| 43 | toolchain: ${{ matrix.rust-toolchain }} |
| 44 | override: true |
| 45 | - name: Check code |
| 46 | uses: actions-rs/cargo@v1 |
| 47 | with: |
| 48 | command: check |
| 49 | args: '--tests' |
| 50 | - name: Run tests |
| 51 | if: "${{ matrix.rust-toolchain == 'nightly' }}" |
| 52 | uses: actions-rs/cargo@v1 |
| 53 | with: |
| 54 | command: test |
| 55 | - name: Measure code coverage of unit tests |
| 56 | uses: actions-rs/[email protected] |
| 57 | with: |
| 58 | version: '0.19.0' |
| 59 | args: '-v --lib --out Xml --ciserver github-actions' |
| 60 | - name: Upload to Codecov |
| 61 | uses: codecov/codecov-action@v3 |
| 62 | with: |
| 63 | flags: ${{ matrix.rust-toolchain }} |
| 64 | name: test-${{ matrix.rust-toolchain }} |
| 65 | fail_ci_if_error: false |
| 66 | token: ${{ secrets.CODECOV_TOKEN }} |
| 67 | codecov_curl_args: "--globoff" |
| 68 | verbose: true |
| 69 | |
| 70 | publish: |
| 71 | needs: test |
| 72 | runs-on: ubuntu-latest |
| 73 | if: "startsWith(github.ref, 'refs/tags/v')" |
| 74 | environment: Crates.io |
| 75 | name: Publish crates |
| 76 | steps: |
| 77 | - name: Checkout code |
| 78 | uses: actions/checkout@v3 |
| 79 | - name: Setup Rust ${{ matrix.rust-toolchain }} |
| 80 | uses: actions-rs/toolchain@v1 |
| 81 | with: |
| 82 | profile: minimal |
| 83 | toolchain: stable |
| 84 | override: true |
| 85 | - name: Package and publish crate |
| 86 | uses: actions-rs/cargo@v1 |
| 87 | with: |
| 88 | command: publish |
| 89 | args: --token ${{ secrets.CRATES_IO_TOKEN }} |
| 90 | |
| 91 | release: |
| 92 | needs: publish |
| 93 | environment: GitHub Releases |
| 94 | runs-on: ubuntu-latest |
| 95 | if: "startsWith(github.ref, 'refs/tags/v')" |
| 96 | name: Release |
| 97 | permissions: |
| 98 | contents: write |
| 99 | pull-requests: read |
| 100 | steps: |
| 101 | - name: Checkout code |
| 102 | uses: actions/checkout@v3 |
| 103 | - name: Release a Changelog |
| 104 | uses: rasmus-saks/[email protected] |
| 105 | with: |
| 106 | github-token: '${{ secrets.GITHUB_TOKEN }}' |
| 107 | |
| 108 | |
| 109 |