|
| 1 | +# See https://www.pantsbuild.org/stable/docs/using-pants/using-pants-in-ci for tips on how to set up your CI with Pants. |
| 2 | + |
| 3 | +name: Pants |
| 4 | + |
| 5 | +on: [push, pull_request] |
| 6 | + |
| 7 | +jobs: |
| 8 | + org-check: |
| 9 | + name: Check GitHub Organization |
| 10 | + if: ${{ github.repository_owner == 'pantsbuild' }} |
| 11 | + runs-on: ubuntu-20.04 |
| 12 | + steps: |
| 13 | + - name: Noop |
| 14 | + run: "true" |
| 15 | + build: |
| 16 | + name: Perform CI Checks |
| 17 | + needs: org-check |
| 18 | + env: |
| 19 | + PANTS_CONFIG_FILES: pants.ci.toml |
| 20 | + runs-on: ubuntu-20.04 |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + python-version: [3.9] |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + - uses: actions/setup-python@v4 |
| 27 | + with: |
| 28 | + python-version: ${{ matrix.python-version }} |
| 29 | + - uses: pantsbuild/actions/init-pants@v5-scie-pants |
| 30 | + # This action bootstraps pants and manages 2-3 GHA caches. |
| 31 | + # See: github.com/pantsbuild/actions/tree/main/init-pants/ |
| 32 | + with: |
| 33 | + # v0 makes it easy to bust the cache if needed |
| 34 | + # just increase the integer to start with a fresh cache |
| 35 | + gha-cache-key: v0 |
| 36 | + # The Python backend uses named_caches for Pip/PEX state, |
| 37 | + # so it is appropriate to invalidate on lockfile changes. |
| 38 | + named-caches-hash: ${{ hashFiles('lockfiles/*') }} |
| 39 | + # If you're not using a fine-grained remote caching service (see https://www.pantsbuild.org/docs/remote-caching), |
| 40 | + # then you may also want to preserve the local Pants cache (lmdb_store). However this must invalidate for |
| 41 | + # changes to any file that can affect the build, so may not be practical in larger repos. |
| 42 | + # A remote cache service integrates with Pants's fine-grained invalidation and avoids these problems. |
| 43 | + cache-lmdb-store: 'true' # defaults to 'false' |
| 44 | + # Note that named_caches and lmdb_store falls back to partial restore keys which |
| 45 | + # may give a useful partial result that will save time over completely clean state, |
| 46 | + # but will cause the cache entry to grow without bound over time. |
| 47 | + # See https://www.pantsbuild.org/stable/docs/using-pants/using-pants-in-ci for tips on how to periodically clean it up. |
| 48 | + # Alternatively you change gha-cache-key to ignore old caches. |
| 49 | + - name: Bootstrap Pants |
| 50 | + run: | |
| 51 | + pants --version |
| 52 | + - name: Check BUILD files |
| 53 | + run: | |
| 54 | + pants tailor --check update-build-files --check :: |
| 55 | + - name: Lint and typecheck |
| 56 | + run: | |
| 57 | + pants lint check :: |
| 58 | + - name: Test |
| 59 | + run: | |
| 60 | + pants test :: |
| 61 | + - name: Package / Run |
| 62 | + run: | |
| 63 | + # We also smoke test that our release process will work by running `package`. |
| 64 | + pants package :: |
| 65 | + - name: Upload pants log |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: pants-log |
| 69 | + path: .pants.d/pants.log |
| 70 | + if: always() # We want the log even on failures. |
0 commit comments