Skip to content

Commit 8fb4d28

Browse files
authored
Add GHA workflow to lint with pantsbuild (#5758)
* GHA: Add Lint workflow that uses pants * update changelog entry * disable scheduled pants lint until it provides value
1 parent eeddc49 commit 8fb4d28

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

.github/workflows/lint.yaml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
# This Lint workflow uses pants
3+
name: Lint
4+
5+
on:
6+
push:
7+
branches:
8+
# only on merges to master branch
9+
- master
10+
# and version branches, which only include minor versions (eg: v3.4)
11+
- v[0-9]+.[0-9]+
12+
tags:
13+
# also version tags, which include bugfix releases (eg: v3.4.0)
14+
- v[0-9]+.[0-9]+.[0-9]+
15+
pull_request:
16+
type: [opened, reopened, edited]
17+
branches:
18+
# Only for PRs targeting those branches
19+
- master
20+
- v[0-9]+.[0-9]+
21+
#schedule:
22+
# # run every night at midnight
23+
# - cron: '0 0 * * *'
24+
25+
jobs:
26+
# Lint checks which don't depend on any service containes, etc. to be running.
27+
lint-checks:
28+
name: 'Lint Checks (pants runs: shellcheck)'
29+
runs-on: ubuntu-latest
30+
31+
env:
32+
COLUMNS: '120'
33+
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v2
37+
with:
38+
# a test uses a submodule, and pants needs access to it to calculate deps.
39+
submodules: 'true'
40+
41+
#- name: Cache APT Dependencies
42+
# id: cache-apt-deps
43+
# uses: actions/cache@v2
44+
# with:
45+
# path: |
46+
# ~/apt_cache
47+
# key: ${{ runner.os }}-apt-v7-${{ hashFiles('scripts/github/apt-packages.txt') }}
48+
# restore-keys: |
49+
# ${{ runner.os }}-apt-v7-
50+
- name: Install APT Depedencies
51+
env:
52+
CACHE_HIT: 'false' # cache doesn't work
53+
#CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
54+
run: |
55+
# install dev dependencies for Python YAML and LDAP packages
56+
# https://github.com/StackStorm/st2-auth-ldap
57+
./scripts/github/install-apt-packages-use-cache.sh
58+
59+
- name: Initialize Pants and its GHA caches
60+
uses: pantsbuild/actions/init-pants@c0ce05ee4ba288bb2a729a2b77294e9cb6ab66f7
61+
# This action adds an env var to make pants use both pants.ci.toml & pants.toml.
62+
# This action also creates 3 GHA caches (1 is optional).
63+
# - `pants-setup` has the bootsrapped pants install
64+
# - `pants-named-caches` has pip/wheel and PEX caches
65+
# - `pants-lmdb-store` has the fine-grained process cache.
66+
# If we ever use a remote cache, then we can drop this.
67+
# Otherwise, we may need an additional workflow or job to delete old caches
68+
# if they are not expiring fast enough, and we hit the GHA 10GB per repo max.
69+
with:
70+
base-branch: master
71+
# To ignore a bad cache, bump the cache* integer.
72+
gha-cache-key: cache0
73+
# This hash should include all of our lockfiles so that the pip/pex caches
74+
# get invalidated on any transitive dependency update.
75+
named-caches-hash: ${{ hashFiles('requirements.txt') }}
76+
# enable the optional lmdb_store cache since we're not using remote caching.
77+
cache-lmdb-store: 'true'
78+
79+
- name: Lint
80+
run: |
81+
./pants lint ::
82+
83+
- name: Upload pants log
84+
uses: actions/upload-artifact@v2
85+
with:
86+
name: pants-log-py${{ matrix.python-version }}
87+
path: .pants.d/pants.log
88+
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 #5732 #5733 #5737 #5738
56+
to pants' use of PEX lockfiles. This is not a user-facing addition. #5713 #5724 #5726 #5725 #5732 #5733 #5737 #5738 #5758
5757
Contributed by @cognifloyd
5858

5959
Changed

0 commit comments

Comments
 (0)