forked from StackStorm/st2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GHA: Refactor repetitive action inputs into in-repo composite actions (…
- Loading branch information
Showing
9 changed files
with
131 additions
and
278 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
name: Cache and Install APT Dependencies | ||
description: | ||
Light wrapper around the actions/cache action and our script | ||
to maintain the input vars in only one place for all workflows. | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Cache APT Dependencies | ||
id: cache-apt-deps | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/apt_cache | ||
key: ${{ runner.os }}-v8-apt-${{ hashFiles('scripts/github/apt-packages.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-v8-apt- | ||
- name: Install APT Depedencies | ||
shell: bash | ||
env: | ||
CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}} | ||
run: | | ||
# install dev dependencies for Python YAML and LDAP packages | ||
# https://github.com/StackStorm/st2-auth-ldap | ||
./scripts/github/install-apt-packages-use-cache.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
name: Initialize Pants and its GHA caches | ||
description: | ||
Light wrapper around the pantsbuild/actions/init-pants action | ||
to maintain the input vars in only one place for all workflows. | ||
|
||
inputs: | ||
gha-cache-key: | ||
description: Qualify all cache keys with this string. Useful for invalidating everything. | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Initialize Pants and its GHA caches | ||
uses: pantsbuild/actions/init-pants@v8 | ||
# This action adds an env var to make pants use both pants.ci.toml & pants.toml. | ||
# This action also creates 3 GHA caches (1 is optional). | ||
# - `pants-setup` has the bootsrapped pants install | ||
# - `pants-named-caches` has pip/wheel and PEX caches | ||
# - `pants-lmdb-store` has the fine-grained process cache. | ||
# If we ever use a remote cache, then we can drop this. | ||
# Otherwise, we may need an additional workflow or job to delete old caches | ||
# if they are not expiring fast enough, and we hit the GHA 10GB per repo max. | ||
with: | ||
base-branch: master | ||
# To ignore a bad cache, bump the cache* integer. | ||
gha-cache-key: ${{ inputs.gha-cache-key }} | ||
# This hash should include all of our lockfiles so that the pip/pex caches | ||
# get invalidated on any transitive dependency update. | ||
named-caches-hash: ${{ hashFiles('lockfiles/*.lock') }} | ||
# enable the optional lmdb_store cache since we're not using remote caching. | ||
cache-lmdb-store: 'true' | ||
# install whatever version of python we need for our in-repo pants-plugins | ||
setup-python-for-plugins: 'true' | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
name: Install Python and Cache Deps | ||
description: | ||
Light wrapper around the actions/setup-python and actions/cache actions | ||
to maintain the input vars in only one place for all workflows. | ||
|
||
input: | ||
python-version: | ||
description: Which version of python to install. | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: 'Set up Python (${{ inputs.python-version }})' | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '${{ inputs.python-version }}' | ||
|
||
- name: Cache Python Dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cache/pip | ||
virtualenv | ||
~/virtualenv | ||
# TODO: maybe make the virtualenv a partial cache to exclude st2*? | ||
# !virtualenv/lib/python*/site-packages/st2* | ||
# !virtualenv/bin/st2* | ||
key: ${{ runner.os }}-v5-python-${{ inputs.python-version }}-${{ hashFiles('requirements.txt', 'test-requirements.txt', 'lockfiles/*.lock') }} | ||
# Don't use alternative key as if requirements.txt has altered we | ||
# don't want to retrieve previous cache | ||
#restore-keys: | | ||
# ${{ runner.os }}-v5-python-${{ inputs.python }}- |
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 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 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
Oops, something went wrong.