Skip to content

Commit 63f66b9

Browse files
authored
Merge pull request #5848: GHA workflow to run (some) tests via pantsbuild
2 parents c1f5a13 + 0e6dc46 commit 63f66b9

File tree

4 files changed

+111
-3
lines changed

4 files changed

+111
-3
lines changed

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
./scripts/github/install-apt-packages-use-cache.sh
5858
5959
- name: Initialize Pants and its GHA caches
60-
uses: pantsbuild/actions/init-pants@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb
60+
uses: pantsbuild/actions/init-pants@v2
6161
# This action adds an env var to make pants use both pants.ci.toml & pants.toml.
6262
# This action also creates 3 GHA caches (1 is optional).
6363
# - `pants-setup` has the bootsrapped pants install

.github/workflows/pants.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
submodules: 'true'
3131

3232
- name: Initialize Pants and its GHA caches
33-
uses: pantsbuild/actions/init-pants@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb
33+
uses: pantsbuild/actions/init-pants@v2
3434
# This action adds an env var to make pants use both pants.ci.toml & pants.toml.
3535
# This action also creates 3 GHA caches (1 is optional).
3636
# - `pants-setup` has the bootsrapped pants install

.github/workflows/test.yaml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
# This Test workflow uses pants
3+
name: Test
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+
test:
27+
name: '${{ matrix.name }} - Python ${{ matrix.python-version-short }}'
28+
runs-on: ubuntu-20.04
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
# NOTE: We need to use full Python version as part of Python deps cache key otherwise
33+
# setup virtualenv step will fail.
34+
include:
35+
- name: 'Test (pants runs: pytest)'
36+
python-version-short: '3.6'
37+
python-version: '3.6.13'
38+
- name: 'Test (pants runs: pytest)'
39+
python-version-short: '3.8'
40+
python-version: '3.8.10'
41+
42+
env:
43+
COLUMNS: '120'
44+
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v2
48+
with:
49+
# a test uses a submodule, and pants needs access to it to calculate deps.
50+
submodules: 'true'
51+
52+
- name: 'Set up Python (${{ matrix.python-version }})'
53+
uses: actions/setup-python@v2
54+
with:
55+
python-version: '${{ matrix.python-version }}'
56+
57+
58+
#- name: Cache APT Dependencies
59+
# id: cache-apt-deps
60+
# uses: actions/cache@v2
61+
# with:
62+
# path: |
63+
# ~/apt_cache
64+
# key: ${{ runner.os }}-apt-v7-${{ hashFiles('scripts/github/apt-packages.txt') }}
65+
# restore-keys: |
66+
# ${{ runner.os }}-apt-v7-
67+
- name: Install APT Depedencies
68+
env:
69+
CACHE_HIT: 'false' # cache doesn't work
70+
#CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
71+
run: |
72+
# install dev dependencies for Python YAML and LDAP packages
73+
# https://github.com/StackStorm/st2-auth-ldap
74+
./scripts/github/install-apt-packages-use-cache.sh
75+
76+
- name: Initialize Pants and its GHA caches
77+
uses: pantsbuild/actions/init-pants@v2
78+
# This action adds an env var to make pants use both pants.ci.toml & pants.toml.
79+
# This action also creates 3 GHA caches (1 is optional).
80+
# - `pants-setup` has the bootsrapped pants install
81+
# - `pants-named-caches` has pip/wheel and PEX caches
82+
# - `pants-lmdb-store` has the fine-grained process cache.
83+
# If we ever use a remote cache, then we can drop this.
84+
# Otherwise, we may need an additional workflow or job to delete old caches
85+
# if they are not expiring fast enough, and we hit the GHA 10GB per repo max.
86+
with:
87+
base-branch: master
88+
# To ignore a bad cache, bump the cache* integer.
89+
gha-cache-key: cache0-py${{ matrix.python-version }}
90+
# This hash should include all of our lockfiles so that the pip/pex caches
91+
# get invalidated on any transitive dependency update.
92+
named-caches-hash: ${{ hashFiles('requirements.txt') }}
93+
# enable the optional lmdb_store cache since we're not using remote caching.
94+
cache-lmdb-store: 'true'
95+
96+
- name: Test
97+
# We do not support running pytest everywhere yet. When we do it will be simply:
98+
# ./pants test ::
99+
# Until then, we need to manually adjust this command line to test what we can.
100+
run: |
101+
./pants test pylint_plugins/:: pants-plugins/::
102+
103+
- name: Upload pants log
104+
uses: actions/upload-artifact@v2
105+
with:
106+
name: pants-log-py${{ matrix.python-version }}
107+
path: .pants.d/pants.log
108+
if: always() # We want the log even on failures.

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Added
1414
working on StackStorm, improve our security posture, and improve CI reliability thanks in part
1515
to pants' use of PEX lockfiles. This is not a user-facing addition.
1616
#5778 #5789 #5817 #5795 #5830 #5833 #5834 #5841 #5840 #5838 #5842 #5837 #5849 #5850
17-
#5846 #5853
17+
#5846 #5853 #5848
1818
Contributed by @cognifloyd
1919

2020
* Added a joint index to solve the problem of slow mongo queries for scheduled executions. #5805

0 commit comments

Comments
 (0)