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