|
| 1 | +name: Rust CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + test: |
| 12 | + name: Test |
| 13 | + runs-on: ubuntu-latest |
| 14 | + defaults: |
| 15 | + run: { working-directory: ./rust/mlt } |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v5 |
| 18 | + - if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' |
| 19 | + uses: Swatinem/rust-cache@v2 |
| 20 | + - uses: taiki-e/install-action@v2 |
| 21 | + with: { tool: 'just,cargo-binstall' } |
| 22 | + - uses: ./.github/actions/mlt-setup-java |
| 23 | + - name: Install protoc |
| 24 | + run: sudo apt-get update && sudo apt-get install -y protobuf-compiler |
| 25 | + - run: just -v ci-test |
| 26 | + |
| 27 | + test-msrv: |
| 28 | + name: Test MSRV |
| 29 | + runs-on: ubuntu-latest |
| 30 | + defaults: |
| 31 | + run: { working-directory: ./rust/mlt } |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v5 |
| 34 | + - if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' |
| 35 | + uses: Swatinem/rust-cache@v2 |
| 36 | + - uses: taiki-e/install-action@v2 |
| 37 | + with: { tool: 'just' } |
| 38 | + - uses: ./.github/actions/mlt-setup-java |
| 39 | + - name: Install protoc |
| 40 | + run: sudo apt-get update && sudo apt-get install -y protobuf-compiler |
| 41 | + - name: Read MSRV |
| 42 | + id: msrv |
| 43 | + run: echo "value=$(just get-msrv)" >> $GITHUB_OUTPUT |
| 44 | + - name: Install MSRV Rust ${{ steps.msrv.outputs.value }} |
| 45 | + uses: dtolnay/rust-toolchain@stable |
| 46 | + with: |
| 47 | + toolchain: ${{ steps.msrv.outputs.value }} |
| 48 | + - run: just -v ci_mode=0 ci-test-msrv # Ignore warnings in MSRV |
| 49 | + |
| 50 | + coverage: |
| 51 | + name: Code Coverage |
| 52 | + if: github.event_name != 'release' && github.repository_owner == 'maplibre' |
| 53 | + runs-on: ubuntu-latest |
| 54 | + defaults: |
| 55 | + run: { working-directory: ./rust/mlt } |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v5 |
| 58 | + - uses: Swatinem/rust-cache@v2 |
| 59 | + - uses: taiki-e/install-action@v2 |
| 60 | + with: { tool: 'just,cargo-llvm-cov' } |
| 61 | + - uses: ./.github/actions/mlt-setup-java |
| 62 | + - name: Install protoc |
| 63 | + run: sudo apt-get update && sudo apt-get install -y protobuf-compiler |
| 64 | + - name: Generate code coverage |
| 65 | + run: just -v ci-coverage |
| 66 | + - name: Upload coverage to Codecov |
| 67 | + uses: codecov/codecov-action@v5 |
| 68 | + with: |
| 69 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 70 | + files: target/llvm-cov/codecov.info |
| 71 | + |
| 72 | + # This job checks if any of the previous jobs failed or were canceled. |
| 73 | + # This approach also allows some jobs to be skipped if they are not needed. |
| 74 | + ci-passed: |
| 75 | + needs: [ test, test-msrv ] |
| 76 | + if: always() |
| 77 | + runs-on: ubuntu-latest |
| 78 | + steps: |
| 79 | + - name: Result of the needed steps |
| 80 | + run: echo "${{ toJSON(needs) }}" |
| 81 | + - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} |
| 82 | + run: exit 1 |
0 commit comments