-
-
Notifications
You must be signed in to change notification settings - Fork 779
GHA: Refactor repetitive action inputs into in-repo composite actions #6199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ee9c74f
GHA: factor out init-pants action call
cognifloyd d8f06b9
GHA: factor out apt cache and install actions
cognifloyd 0035395
GHA: factor out python setup and cache actions
cognifloyd 033bb85
GHA: misc cleanups missed in previuos PRs
cognifloyd 8eef358
GHA: correct composite action reference
cognifloyd 735e926
GHA: composite actions require explicitly setting shell
cognifloyd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -75,36 +75,12 @@ jobs: | |
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: 'Set up Python (${{ matrix.python-version }})' | ||
| uses: actions/setup-python@v5 | ||
| - name: 'Set up Python (${{ matrix.python-version }}) and Cache Deps' | ||
| uses: ./.github/actions/setup-python | ||
| with: | ||
| python-version: '${{ matrix.python-version }}' | ||
| - name: Cache Python Dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cache/pip | ||
| virtualenv | ||
| ~/virtualenv | ||
| key: ${{ runner.os }}-v5-python-${{ matrix.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-${{ matrix.python }}- | ||
| - 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 Dependencies | ||
| env: | ||
| CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}} | ||
| run: | | ||
| ./scripts/github/install-apt-packages-use-cache.sh | ||
| - name: Cache and Install APT Dependencies | ||
| uses: ./.github/actions/apt-packages | ||
| - name: Install virtualenv | ||
| run: | | ||
| ./scripts/github/install-virtualenv.sh | ||
|
|
@@ -122,7 +98,7 @@ jobs: | |
| - name: Upload Histograms | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: benchmark_histograms | ||
| name: benchmark_histograms-py${{ matrix.python-version }} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the line that was causing the microbenchmarks workflow failures. All other instances of |
||
| path: benchmark_histograms/ | ||
| retention-days: 30 | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that the slack notification can happen before self-check finishes. It turns out, this was missing.