Merge pull request #146 from kcl-lang/dependabot/github_actions/ci-fd… #336
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: test | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
- test* | |
jobs: | |
unit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 | |
- name: Setup Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1 | |
- name: Cache Docker layers | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
id: cache | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-ghcache-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx-ghcache- | |
- name: Setup Go | |
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | |
with: | |
go-version: 1.23 | |
cache-dependency-path: | | |
**/go.sum | |
**/go.mod | |
- name: Setup Kubernetes | |
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0 | |
with: | |
version: v0.20.0 | |
cluster_name: kind | |
node_image: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72 | |
- name: Setup Kustomize | |
uses: fluxcd/pkg/actions/kustomize@main | |
- name: Enable integration tests | |
# Only run integration tests for main branch | |
if: github.ref == 'refs/heads/main' | |
run: | | |
echo 'GO_TEST_ARGS=-tags integration' >> $GITHUB_ENV | |
- name: Run tests | |
run: make test | |
- name: Build container image | |
run: | | |
make docker-build IMG=test/flux-kcl-controller:latest \ | |
BUILD_PLATFORMS=linux/amd64 \ | |
BUILD_ARGS="--cache-from=type=local,src=/tmp/.buildx-cache \ | |
--cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max \ | |
--load" | |
- # Temp fix | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
- name: Load test image | |
run: kind load docker-image test/flux-kcl-controller:latest | |
- name: Install CRDs | |
run: make install | |
- name: Run default status test | |
run: | | |
kubectl apply -f config/testdata/status-defaults | |
RESULT=$(kubectl get kclrun status-defaults -o go-template={{.status}}) | |
EXPECTED='map[observedGeneration:-1]' | |
if [ "${RESULT}" != "${EXPECTED}" ] ; then | |
echo -e "${RESULT}\n\ndoes not equal\n\n${EXPECTED}" | |
exit 1 | |
fi | |
kubectl delete -f config/testdata/status-defaults | |
- name: Deploy Flux KCL controllers | |
run: | | |
make dev-deploy IMG=test/flux-kcl-controller:latest | |
kubectl -n source-system rollout status deploy/source-controller --timeout=1m | |
kubectl -n source-system rollout status deploy/kcl-controller --timeout=1m |