diff --git a/.github/workflows/build-charm.yaml b/.github/workflows/build-charm.yaml index 79713534..655d2040 100644 --- a/.github/workflows/build-charm.yaml +++ b/.github/workflows/build-charm.yaml @@ -22,16 +22,37 @@ jobs: steps: - uses: actions/checkout@v4.1.3 - uses: canonical/setup-lxd@v0.1.1 + + - 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 diff --git a/charms/worker/k8s/requirements.txt b/charms/worker/k8s/requirements.txt index 9acee428..eb134dd4 100644 --- a/charms/worker/k8s/requirements.txt +++ b/charms/worker/k8s/requirements.txt @@ -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