|
| 1 | +name: CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [main] |
| 5 | + pull_request: |
| 6 | + branches: [main] |
| 7 | + workflow_dispatch: |
| 8 | +concurrency: |
| 9 | + # Cancel previous actions from the same PR or branch except 'main' branch. |
| 10 | + # See https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts for more info. |
| 11 | + group: concurrency-group::${{ github.workflow }}::${{ github.event.pull_request.number > 0 && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}${{ github.ref_name == 'main' && format('::{0}', github.run_id) || ''}} |
| 12 | + cancel-in-progress: ${{ github.ref_name != 'main' }} |
| 13 | +jobs: |
| 14 | + buildifier: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
| 18 | + - uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0 |
| 19 | + with: |
| 20 | + # Avoid downloading Bazel every time. |
| 21 | + bazelisk-cache: true |
| 22 | + # Store build cache per workflow. |
| 23 | + disk-cache: ${{ github.workflow }} |
| 24 | + # Share repository cache between workflows. |
| 25 | + repository-cache: true |
| 26 | + # Don't save cache on pull requests to avoid polluting it |
| 27 | + cache-save: ${{ github.event_name != 'pull_request' }} |
| 28 | + - run: bazel run //tools/format:format.check --config=ci |
| 29 | + gazelle: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
| 33 | + - uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0 |
| 34 | + with: |
| 35 | + # Avoid downloading Bazel every time. |
| 36 | + bazelisk-cache: true |
| 37 | + # Store build cache per workflow. |
| 38 | + disk-cache: ${{ github.workflow }} |
| 39 | + # Share repository cache between workflows. |
| 40 | + repository-cache: true |
| 41 | + # Don't save cache on pull requests to avoid polluting it |
| 42 | + cache-save: ${{ github.event_name != 'pull_request' }} |
| 43 | + - run: bazel run //:gazelle.check --config=ci |
| 44 | + format: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
| 48 | + - uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0 |
| 49 | + with: |
| 50 | + # Avoid downloading Bazel every time. |
| 51 | + bazelisk-cache: true |
| 52 | + # Store build cache per workflow. |
| 53 | + disk-cache: ${{ github.workflow }} |
| 54 | + # Share repository cache between workflows. |
| 55 | + repository-cache: true |
| 56 | + # Don't save cache on pull requests to avoid polluting it |
| 57 | + cache-save: ${{ github.event_name != 'pull_request' }} |
| 58 | + - run: bazel run //tools/format:format.check --config=ci |
| 59 | + test: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
| 63 | + - uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0 |
| 64 | + with: |
| 65 | + # Avoid downloading Bazel every time. |
| 66 | + bazelisk-cache: true |
| 67 | + # Store build cache per workflow. |
| 68 | + disk-cache: ${{ github.workflow }} |
| 69 | + # Share repository cache between workflows. |
| 70 | + repository-cache: true |
| 71 | + # Don't save cache on pull requests to avoid polluting it |
| 72 | + cache-save: ${{ github.event_name != 'pull_request' }} |
| 73 | + - run: bazel test //... --config=ci |
0 commit comments