update integration CI to preserve charmcraft's cache between builds #6
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
# reusable workflow triggered by other actions | ||
name: CI | ||
on: | ||
workflow_call: | ||
secrets: | ||
CHARMCRAFT_CREDENTIALS: | ||
required: true | ||
jobs: | ||
lib-check: | ||
name: Check libraries | ||
strategy: | ||
matrix: | ||
charm: | ||
- istio-gateway | ||
- istio-pilot | ||
uses: canonical/charmed-kubeflow-workflows/.github/workflows/_quality-checks.yaml@main | ||
secrets: inherit | ||
with: | ||
charm-path: ./charms/${{ matrix.charm }} | ||
lint: | ||
name: Lint Code | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
charm: [pilot, gateway] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: sudo apt update && sudo apt install tox | ||
- run: tox -e ${{ matrix.charm }}-lint | ||
unit: | ||
name: Unit Test | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
charm: [pilot, gateway] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: sudo apt update && sudo apt install tox | ||
- run: tox -e ${{ matrix.charm }}-unit | ||
integration: | ||
name: Integration Test | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
microk8s-versions: | ||
- 1.25-strict/stable | ||
- 1.26-strict/stable | ||
integration-types: | ||
- integration | ||
- integration-tls-provider | ||
- integration-tls-secret | ||
env: | ||
CRAFT_SHARED_CACHE: /home/runner/.cache/shared_charmcraft_cache | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
- name: Setup operator environment | ||
uses: charmed-kubernetes/actions-operator@main | ||
with: | ||
provider: microk8s | ||
channel: ${{ matrix.microk8s-versions }} | ||
microk8s-addons: "dns hostpath-storage rbac metallb:10.64.140.43-10.64.140.49" | ||
juju-channel: 3.1/stable | ||
charmcraft-channel: latest/candidate | ||
- name: Setup Charmcraft's cache | ||
id: cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.CRAFT_SHARED_CACHE }} | ||
# Cache keys must be unique - there is no overwrite mechanic. Add IDs to avoid this (is there a better set of IDs?) | ||
# partial ref: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache | ||
# To match the most recent previous cache, use restore-keys with the craft-shared-cache prefix. This will hit the | ||
# "first" match, which will be from the most recent run. | ||
# ref: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key | ||
key: craft-shared-cache-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}-${{ strategy.job-index }} | ||
restore-keys: craft-shared-cache | ||
# DEBUG: remove this | ||
- name: emit charmcraft cache directory contents | ||
run: | | ||
find $CRAFT_SHARED_CACHE | wc -l | ||
find $CRAFT_SHARED_CACHE/wheels | wc -l | ||
- name: Run integration tests | ||
run: | | ||
juju add-model test-istio | ||
tox -e ${{ matrix.integration-types }} -- --model test-istio | ||
timeout-minutes: 80 | ||
# DEBUG: remove this | ||
- name: emit charmcraft cache directory contents | ||
run: | | ||
find $CRAFT_SHARED_CACHE | wc -l | ||
find $CRAFT_SHARED_CACHE/wheels | wc -l | ||
- name: Setup Debug Artifact Collection | ||
run: mkdir tmp | ||
if: failure() | ||
- name: Collect charmcraft logs | ||
if: failure() | ||
run: | | ||
cat /home/runner/.local/state/charmcraft/log/charmcraft-*.log | tee tmp/charmcraft.log | ||
- name: Collect Juju status | ||
if: failure() | ||
run: juju status | tee tmp/juju-status.txt | ||
- name: Collect Juju log | ||
if: failure() | ||
run: juju debug-log --replay --no-tail | tee tmp/juju-status.txt | ||
- name: Collect Kube status | ||
if: failure() | ||
run: | | ||
kubectl get all -A | tee tmp/kube-summary.txt | ||
kubectl describe virtualservices -A | tee tmp/kube-virtualservices.txt | ||
kubectl describe gateways -A | tee tmp/kube-gateways.txt | ||
kubectl describe deployments -A | tee tmp/kube-deployments.txt | ||
kubectl describe replicasets -A | tee tmp/kubectl-replicasets.txt | ||
kubectl exec -n test-istio istio-pilot-0 --container charm -- agents/unit-istio-pilot-0/charm/istioctl analyze -n test-istio | tee tmp/istioctl-analyze.txt | ||
- name: Collect Kube logs | ||
if: failure() | ||
run: | | ||
kubectl logs -n test-istio --tail 1000 -lapp.kubernetes.io/name=istio-pilot -c charm | tee tmp/istio-pilot.log | ||
kubectl logs -n test-istio --tail 1000 -lapp.kubernetes.io/name=istio-ingressgateway-operator -c charm | tee tmp/istio-ingressgateway-operator.log | ||
- name: Upload debug artifacts | ||
if: failure() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: test-run-artifacts | ||
path: tmp | ||
integration-observability: | ||
name: Observability Integration Test | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
microk8s-versions: | ||
- 1.25-strict/stable | ||
- 1.26-strict/stable | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
- name: Setup operator environment | ||
uses: charmed-kubernetes/actions-operator@main | ||
with: | ||
provider: microk8s | ||
channel: ${{ matrix.microk8s-versions }} | ||
microk8s-addons: "dns hostpath-storage rbac metallb:10.64.140.43-10.64.140.49" | ||
juju-channel: 3.1/stable | ||
charmcraft-channel: latest/candidate | ||
- name: Run observability integration tests | ||
run: | | ||
juju add-model cos-test | ||
tox -vve cos-integration -- --model cos-test | ||
- run: kubectl get pod/prometheus-k8s-0 -n knative-test -o=jsonpath='{.status}' | ||
if: failure() |