Skip to content

Commit 9f45f91

Browse files
committed
add gha workflow to validate pants BUILD files
1 parent 309f487 commit 9f45f91

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.github/workflows/pants.yaml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
name: Validate Pants Metadata
3+
4+
on:
5+
# temporarily only allow manual runs until we have BUILD files and lockfiles
6+
workflow_dispatch:
7+
#push:
8+
# branches:
9+
# # only on merges to master branch
10+
# - master
11+
# # and version branches, which only include minor versions (eg: v3.4)
12+
# - v[0-9]+.[0-9]+
13+
# tags:
14+
# # also version tags, which include bugfix releases (eg: v3.4.0)
15+
# - v[0-9]+.[0-9]+.[0-9]+
16+
#pull_request:
17+
# type: [opened, reopened, edited]
18+
# branches:
19+
# # Only for PRs targeting those branches
20+
# - master
21+
# - v[0-9]+.[0-9]+
22+
23+
jobs:
24+
pants-tailor:
25+
name: Make sure pants BUILD files are up-to-date
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v2
30+
with:
31+
# a test uses a submodule, and pants needs access to it to calculate deps.
32+
submodules: 'true'
33+
34+
- name: Initialize Pants and its GHA caches
35+
uses: pantsbuild/actions/init-pants@c0ce05ee4ba288bb2a729a2b77294e9cb6ab66f7
36+
# This action adds an env var to make pants use both pants.ci.toml & pants.toml.
37+
# This action also creates 3 GHA caches (1 is optional).
38+
# - `pants-setup` has the bootsrapped pants install
39+
# - `pants-named-caches` has pip/wheel and PEX caches
40+
# - `pants-lmdb-store` has the fine-grained process cache.
41+
# If we ever use a remote cache, then we can drop this.
42+
# Otherwise, we may need an additional workflow or job to delete old caches
43+
# if they are not expiring fast enough, and we hit the GHA 10GB per repo max.
44+
with:
45+
# To ignore a bad cache, bump the cache* integer.
46+
gha-cache-key: cache0-BUILD
47+
# This hash should include all of our lockfiles so that the pip/pex caches
48+
# get invalidated on any transitive dependency update.
49+
named-caches-hash: ${{ hashFiles('requirements.txt' }}
50+
# enable the optional lmdb_store cache since we're not using remote caching.
51+
cache-lmdb-store: 'true'
52+
53+
- name: Check BUILD files
54+
run: |
55+
./pants tailor --check update-build-files --check ::
56+
57+
- name: Upload pants log
58+
uses: actions/upload-artifact@v2
59+
with:
60+
name: pants-log-py${{ matrix.python-version }}
61+
path: .pants.d/pants.log
62+
if: always() # We want the log even on failures.

0 commit comments

Comments
 (0)