|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + release: |
| 9 | + types: [ published ] |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +defaults: |
| 13 | + run: |
| 14 | + shell: bash |
| 15 | + |
| 16 | +env: |
| 17 | + CARGO_TERM_COLOR: always |
| 18 | + |
| 19 | +jobs: |
| 20 | + test: |
| 21 | + name: Test |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + os: [ ubuntu-latest, macos-15 ] |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + - if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' |
| 29 | + uses: Swatinem/rust-cache@v2 |
| 30 | + - uses: dtolnay/rust-toolchain@stable |
| 31 | + - uses: taiki-e/install-action@v2 |
| 32 | + with: { tool: just } |
| 33 | + - run: just ci-test |
| 34 | + |
| 35 | + test-msrv: |
| 36 | + name: Test MSRV |
| 37 | + runs-on: ${{ matrix.os }} |
| 38 | + strategy: |
| 39 | + matrix: |
| 40 | + os: [ ubuntu-latest, macos-15 ] |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + - if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' |
| 44 | + uses: Swatinem/rust-cache@v2 |
| 45 | + - uses: taiki-e/install-action@v2 |
| 46 | + with: { tool: just } |
| 47 | + - name: Read MSRV |
| 48 | + id: msrv |
| 49 | + run: echo "value=$(just get-msrv)" >> $GITHUB_OUTPUT |
| 50 | + - name: Install MSRV Rust ${{ steps.msrv.outputs.value }} |
| 51 | + uses: dtolnay/rust-toolchain@stable |
| 52 | + with: |
| 53 | + toolchain: ${{ steps.msrv.outputs.value }} |
| 54 | + - run: just ci_mode=0 ci-test-msrv # Ignore warnings in MSRV |
| 55 | + |
| 56 | + coverage: |
| 57 | + name: Code Coverage |
| 58 | + if: github.event_name != 'release' |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + - uses: Swatinem/rust-cache@v2 |
| 63 | + - uses: taiki-e/install-action@v2 |
| 64 | + with: { tool: 'just,cargo-llvm-cov' } |
| 65 | + - name: Generate code coverage |
| 66 | + run: just ci-coverage |
| 67 | + - name: Upload coverage to Codecov |
| 68 | + uses: codecov/codecov-action@v5 |
| 69 | + with: |
| 70 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 71 | + files: target/llvm-cov/codecov.info |
| 72 | + fail_ci_if_error: false |
| 73 | + |
| 74 | + # This job checks if any of the previous jobs failed or were canceled. |
| 75 | + # This approach also allows some jobs to be skipped if they are not needed. |
| 76 | + ci-passed: |
| 77 | + needs: [ test, test-msrv ] |
| 78 | + if: always() |
| 79 | + runs-on: ubuntu-latest |
| 80 | + steps: |
| 81 | + - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} |
| 82 | + run: exit 1 |
| 83 | + |
| 84 | + # Release unpublished packages or create a PR with changes |
| 85 | + release-plz: |
| 86 | + needs: [ ci-passed ] |
| 87 | + if: | |
| 88 | + always() |
| 89 | + && needs.ci-passed.result == 'success' |
| 90 | + && github.event_name == 'push' |
| 91 | + && github.ref == 'refs/heads/main' |
| 92 | + && github.repository_owner == 'harfbuzz' |
| 93 | + runs-on: ubuntu-latest |
| 94 | + permissions: |
| 95 | + contents: write |
| 96 | + pull-requests: write |
| 97 | + concurrency: |
| 98 | + group: release-plz-${{ github.ref }} |
| 99 | + cancel-in-progress: false |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@v4 |
| 102 | + with: { fetch-depth: 0 } |
| 103 | + - uses: dtolnay/rust-toolchain@stable |
| 104 | + - name: Publish to crates.io if crate's version is newer |
| 105 | + uses: release-plz/[email protected] |
| 106 | + id: release |
| 107 | + with: { command: release } |
| 108 | + env: |
| 109 | + GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} |
| 110 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 111 | + - name: If version is the same, create a PR proposing new version and changelog for the next release |
| 112 | + uses: release-plz/[email protected] |
| 113 | + if: ${{ steps.release.outputs.releases_created == 'false' }} |
| 114 | + with: { command: release-pr } |
| 115 | + env: |
| 116 | + GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} |
0 commit comments