Skip to content

Commit 4ebd7fd

Browse files
authored
Add GHA workflow to validate pants BUILD files (#5732)
* Add CI-specific pants config file * add gha workflow to validate pants BUILD files * update changelog entry
1 parent 2ee0533 commit 4ebd7fd

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
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.

CHANGELOG.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Added
5353

5454
* Begin introducing `pants <https://www.pantsbuild.org/docs>`_ to improve DX (Developer Experience)
5555
working on StackStorm, improve our security posture, and improve CI reliability thanks in part
56-
to pants' use of PEX lockfiles. This is not a user-facing addition. #5713 #5724 #5726 #5725
56+
to pants' use of PEX lockfiles. This is not a user-facing addition. #5713 #5724 #5726 #5725 #5732
5757
Contributed by @cognifloyd
5858

5959
Changed

pants.ci.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This config is for CI. It extends the config in pants.toml.
2+
# See https://www.pantsbuild.org/docs/using-pants-in-ci
3+
4+
[GLOBAL]
5+
# Colors often work in CI, but the shell is usually not a TTY so Pants
6+
# doesn't attempt to use them by default.
7+
colors = true
8+
9+
[stats]
10+
# "print metrics of your cache's performance at the end of the run,
11+
# including the number of cache hits and the total time saved thanks
12+
# to caching"
13+
log = true

0 commit comments

Comments
 (0)