feat: Cache CI-built cloud-provider-kind
Docker image
#272
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
name: integration | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
single-trust-zone: | |
name: single trust zone | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install just | |
uses: taiki-e/install-action@just | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Build and run tests | |
run: just build | |
- name: Get cloud-provider-kind repo and generate cache key | |
id: cloud-provider-kind-cache-key | |
run: | | |
git clone https://github.com/kubernetes-sigs/cloud-provider-kind | |
echo "hash=$(cd cloud-provider-kind && git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- name: Cache cloud-provider-kind image | |
id: cloud-provider-kind-cache | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/cloud-provider-kind-image | |
key: cloud-provider-kind-${{ steps.cloud-provider-kind-cache-key.outputs.hash }} | |
- name: Load cached image | |
if: steps.cloud-provider-kind-cache.outputs.cache-hit == 'true' | |
run: docker load < /tmp/cloud-provider-kind-image | |
- name: Set up Docker Buildx | |
if: steps.cloud-provider-kind-cache.outputs.cache-hit != 'true' | |
uses: docker/setup-buildx-action@v3 | |
- name: Build cloud-provider-kind image | |
if: steps.cloud-provider-kind-cache.outputs.cache-hit != 'true' | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./cloud-provider-kind | |
push: false | |
tags: cloud-provider-kind-cloud-provider:latest | |
load: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
outputs: type=docker,dest=/tmp/cloud-provider-kind-image | |
- name: Install kind | |
run: just install-kind | |
- name: Install ko | |
uses: ko-build/[email protected] | |
env: | |
KO_DOCKER_REPO: kind.local | |
- name: Create a kind cluster | |
run: just create-kind-cluster | |
- name: Test | |
run: just integration-test single-trust-zone | |
federation: | |
name: federation | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# Repeat the test with in-process plugins and the test gRPC plugin. | |
plugin: | |
- "" | |
- "cofidectl-test-plugin" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install just | |
uses: taiki-e/install-action@just | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Build and run tests | |
run: just build | |
- name: Get cloud-provider-kind repo and generate cache key | |
id: cloud-provider-kind-cache-key | |
run: | | |
git clone https://github.com/kubernetes-sigs/cloud-provider-kind | |
echo "hash=$(cd cloud-provider-kind && git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- name: Cache cloud-provider-kind image | |
id: cloud-provider-kind-cache | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/cloud-provider-kind-image | |
key: cloud-provider-kind-${{ steps.cloud-provider-kind-cache-key.outputs.hash }} | |
- name: Load cached image | |
if: steps.cloud-provider-kind-cache.outputs.cache-hit == 'true' | |
run: docker load < /tmp/cloud-provider-kind-image | |
- name: Set up Docker Buildx | |
if: steps.cloud-provider-kind-cache.outputs.cache-hit != 'true' | |
uses: docker/setup-buildx-action@v3 | |
- name: Build cloud-provider-kind image | |
if: steps.cloud-provider-kind-cache.outputs.cache-hit != 'true' | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./cloud-provider-kind | |
push: false | |
tags: cloud-provider-kind-cloud-provider:latest | |
load: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
outputs: type=docker,dest=/tmp/cloud-provider-kind-image | |
- name: Build and install test plugin | |
run: just install-test-plugin | |
if: ${{ matrix.plugin == 'cofidectl-test-plugin' }} | |
- name: Install kind | |
run: just install-kind | |
- name: Install ko | |
uses: ko-build/[email protected] | |
env: | |
KO_DOCKER_REPO: kind.local | |
- name: Create kind clusters | |
run: just create-kind-clusters 2 | |
- name: Test | |
run: just integration-test federation | |
env: | |
DATA_SOURCE_PLUGIN: ${{ matrix.plugin }} | |
PROVISION_PLUGIN: ${{ matrix.plugin }} |