generated from canonical/is-charms-template-repo
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a caching step in the build charms action to speed up the testing process.
- Loading branch information
1 parent
81caac3
commit d5ddc02
Showing
2 changed files
with
33 additions
and
9 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 |
---|---|---|
|
@@ -22,16 +22,37 @@ jobs: | |
steps: | ||
- uses: actions/[email protected] | ||
- uses: canonical/[email protected] | ||
|
||
- name: Get hash of the source | ||
run: echo "SRC_HASH=${{ hashFiles('**/charms/**/*.yaml', '**/charms/**/*.py', '**/charms/**/requirements.txt') }}" >> $GITHUB_ENV | ||
|
||
- name: Extract charm name | ||
working-directory: ${{ inputs.working-directory }} | ||
run: echo "CHARM_NAME=$([ -f charmcraft.yaml ] && yq '.name' charmcraft.yaml || echo UNKNOWN)" >> $GITHUB_ENV | ||
|
||
- name: Cache charm output | ||
id: cache-charm | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ inputs.working-directory }}packed/ | ||
key: ${{ runner.os}}-${{ env.CHARM_NAME }}-charm-${{ env.SRC_HASH }} | ||
|
||
- name: Use cached charm | ||
if: ${{ env.CHARM_NAME != 'UNKNOWN' && steps.cache-charm.outputs.cache-hit == 'true' }} | ||
working-directory: ${{ inputs.working-directory }}/${{ matrix.path }} | ||
run: | | ||
echo "CHARM_FILE=$(ls packed/${{env.CHARM_NAME}}_*.charm)" >> $GITHUB_ENV | ||
- name: Pack charm | ||
if: ${{ env.CHARM_NAME != 'UNKNOWN' && !cancelled() }} | ||
if: ${{ env.CHARM_NAME != 'UNKNOWN' && !cancelled() && steps.cache-charm.outputs.cache-hit != 'true' }} | ||
working-directory: ${{ inputs.working-directory }}/${{ matrix.path }} | ||
run: | | ||
sudo snap install charmcraft --classic --channel latest/stable | ||
charmcraft pack -v | ||
echo "CHARM_FILE=$(ls ${{env.CHARM_NAME}}_*.charm)" >> $GITHUB_ENV | ||
mkdir -p packed | ||
mv *.charm packed/ | ||
echo "CHARM_FILE=$(ls packed/${{env.CHARM_NAME}}_*.charm)" >> $GITHUB_ENV | ||
- name: Upload charm artifact | ||
if: ${{ env.CHARM_FILE != '' && !cancelled() }} | ||
uses: actions/upload-artifact@v4 | ||
|
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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
ops >= 2.2.0 | ||
cosl == 0.0.8 | ||
pydantic == 1.* | ||
charm-lib-reconciler @ git+https://github.com/charmed-kubernetes/charm-lib-reconciler@main | ||
charm-lib-contextual-status @ git+https://github.com/charmed-kubernetes/charm-lib-contextual-status@main | ||
charm-lib-node-base @ git+https://github.com/charmed-kubernetes/layer-kubernetes-node-base@main#subdirectory=ops | ||
charm-lib-interface-external-cloud-provider @ git+https://github.com/charmed-kubernetes/charm-lib-interface-external-cloud-provider@main | ||
charm-lib-contextual-status @ git+https://github.com/charmed-kubernetes/charm-lib-contextual-status@255dd4a23defc16dcdac832306e5f460a0f1200c | ||
charm-lib-interface-external-cloud-provider @ git+https://github.com/charmed-kubernetes/charm-lib-interface-external-cloud-provider@e1c5fc69e98100a7d43c0ad5a7969bba1ecbcd40 | ||
charm-lib-node-base @ git+https://github.com/charmed-kubernetes/layer-kubernetes-node-base@9b212854e768f13c26cc907bed51444e97e51b50#subdirectory=ops | ||
charm-lib-reconciler @ git+https://github.com/charmed-kubernetes/charm-lib-reconciler@f818cc30d1a22be43ffdfecf7fbd9c3fd2967502 | ||
cosl==0.0.8 | ||
ops==2.12.0 | ||
pydantic==1.10.15 | ||
PyYAML==6.0.1 | ||
typing_extensions==4.11.0 | ||
websocket-client==1.8.0 |