⬆ Bump actions/cache from 3 to 4 (#94) #191
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Python package | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
id: cache | |
with: | |
path: | | |
~/.cache/pants/setup | |
~/.cache/pants/lmdb_store | |
~/.cache/pants/named_caches | |
key: ${{ runner.os }}- | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: pantsbuild/actions/init-pants@v5-scie-pants | |
# This action bootstraps pants and manages 2-3 GHA caches. | |
# See: github.com/pantsbuild/actions/tree/main/init-pants/ | |
with: | |
# v0 makes it easy to bust the cache if needed | |
# just increase the integer to start with a fresh cache | |
gha-cache-key: v0 | |
# The Python backend uses named_caches for Pip/PEX state, | |
# so it is appropriate to invalidate on lockfile changes. | |
named-caches-hash: ${{ hashFiles('python-default.lock') }} | |
# If you're not using a fine-grained remote caching service (see https://www.pantsbuild.org/docs/remote-caching), | |
# then you may also want to preserve the local Pants cache (lmdb_store). However this must invalidate for | |
# changes to any file that can affect the build, so may not be practical in larger repos. | |
# A remote cache service integrates with Pants's fine-grained invalidation and avoids these problems. | |
cache-lmdb-store: 'true' # defaults to 'false' | |
# Note that named_caches and lmdb_store falls back to partial restore keys which | |
# may give a useful partial result that will save time over completely clean state, | |
# but will cause the cache entry to grow without bound over time. | |
# See https://pants.readme.io/docs/using-pants-in-ci for tips on how to periodically clean it up. | |
# Alternatively you change gha-cache-key to ignore old caches. | |
- name: Check BUILD files | |
run: | | |
pants tailor --check update-build-files --check :: | |
- name: Lint | |
run: | | |
make lint | |
- name: Test | |
run: | | |
make test | |
- name: Package | |
run: | | |
make build | |
- name: Validate package | |
run: | | |
ls dist | |
PACKAGE=`ls dist/jsf-*.tar.gz` | |
# Validate the CLI works | |
pip3 install $PACKAGE\[cli\] | |
jsf --help | |
# Validate the sdist tests work for conda | |
tar -xvf $PACKAGE | |
cd jsf-* | |
pip install . | |
PACKAGE_DIR=`pip show jsf | grep "Location" | sed 's/^.*: //'` | |
cd $PACKAGE_DIR/jsf | |
pip install pytest pyjwt | |
pytest | |
- name: Upload coverage | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./dist/coverage/python/coverage.xml | |
- name: Upload pants log | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pants-log | |
path: .pants.d/pants.log | |
if: always() # We want the log even on failures. |