Skip to content

Commit 1729d45

Browse files
committed
GHA: Add Lint workflow that uses pants
1 parent d3cdb87 commit 1729d45

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

.github/workflows/lint.yaml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
# NOTE: We always want to run job on master since we run some additional checks there (code
29+
# coverage, etc)
30+
if: ${{ github.ref == 'refs/heads/master' }}
31+
name: 'Lint Checks (pants runs: shellcheck)'
32+
runs-on: ubuntu-latest
33+
34+
env:
35+
COLUMNS: '120'
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v2
40+
with:
41+
# a test uses a submodule, and pants needs access to it to calculate deps.
42+
submodules: 'true'
43+
44+
#- name: Cache APT Dependencies
45+
# id: cache-apt-deps
46+
# uses: actions/cache@v2
47+
# with:
48+
# path: |
49+
# ~/apt_cache
50+
# key: ${{ runner.os }}-apt-v7-${{ hashFiles('scripts/github/apt-packages.txt') }}
51+
# restore-keys: |
52+
# ${{ runner.os }}-apt-v7-
53+
- name: Install APT Depedencies
54+
env:
55+
CACHE_HIT: 'false' # cache doesn't work
56+
#CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
57+
run: |
58+
# install dev dependencies for Python YAML and LDAP packages
59+
# https://github.com/StackStorm/st2-auth-ldap
60+
./scripts/github/install-apt-packages-use-cache.sh
61+
62+
- name: Initialize Pants and its GHA caches
63+
uses: pantsbuild/actions/init-pants@c0ce05ee4ba288bb2a729a2b77294e9cb6ab66f7
64+
# This action adds an env var to make pants use both pants.ci.toml & pants.toml.
65+
# This action also creates 3 GHA caches (1 is optional).
66+
# - `pants-setup` has the bootsrapped pants install
67+
# - `pants-named-caches` has pip/wheel and PEX caches
68+
# - `pants-lmdb-store` has the fine-grained process cache.
69+
# If we ever use a remote cache, then we can drop this.
70+
# Otherwise, we may need an additional workflow or job to delete old caches
71+
# if they are not expiring fast enough, and we hit the GHA 10GB per repo max.
72+
with:
73+
base-branch: master
74+
# To ignore a bad cache, bump the cache* integer.
75+
gha-cache-key: cache0
76+
# This hash should include all of our lockfiles so that the pip/pex caches
77+
# get invalidated on any transitive dependency update.
78+
named-caches-hash: ${{ hashFiles('requirements.txt') }}
79+
# enable the optional lmdb_store cache since we're not using remote caching.
80+
cache-lmdb-store: 'true'
81+
82+
- name: Lint
83+
run: |
84+
./pants lint ::
85+
86+
- name: Upload pants log
87+
uses: actions/upload-artifact@v2
88+
with:
89+
name: pants-log-py${{ matrix.python-version }}
90+
path: .pants.d/pants.log
91+
if: always() # We want the log even on failures.

0 commit comments

Comments
 (0)