Skip to content
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

Cache Charm Builds #78

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions .github/workflows/build-charm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions charms/worker/k8s/requirements.txt
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
Loading