From 43514c254c3ccc4c551d60b2ce42d9d7153f4936 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Fri, 5 Apr 2024 15:26:51 +0200 Subject: [PATCH] Test on latest K8s and align Github Workflow Actions (#151) --- .../workflows/{pr.yaml => integration.yaml} | 32 ++++++++------ .github/workflows/master.yaml | 43 ------------------- .github/workflows/release-drafter.yaml | 15 +++++++ Makefile | 12 ++++-- control-plane/kind.yaml | 1 - 5 files changed, 44 insertions(+), 59 deletions(-) rename .github/workflows/{pr.yaml => integration.yaml} (57%) delete mode 100644 .github/workflows/master.yaml create mode 100644 .github/workflows/release-drafter.yaml diff --git a/.github/workflows/pr.yaml b/.github/workflows/integration.yaml similarity index 57% rename from .github/workflows/pr.yaml rename to .github/workflows/integration.yaml index e060dd59..c01b942a 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/integration.yaml @@ -1,31 +1,40 @@ -name: Integration tests for PR - +--- +name: Integration Test on: pull_request: branches: - master + push: + branches: + - master + +env: + REGISTRY: ghcr.io jobs: test: - name: Integration tests for PR + name: Run tests runs-on: self-hosted + steps: - name: Gain back workspace permissions # https://github.com/actions/checkout/issues/211 run: | [ -d "${GITHUB_WORKSPACE}" ] && sudo chown -R $USER:$USER ${GITHUB_WORKSPACE} - - name: Checkout - uses: actions/checkout@v3 - - - name: Docker Login - uses: docker/login-action@v2 + - name: Log in to the container registry + uses: docker/login-action@v3 with: - registry: ${{ secrets.DOCKER_REGISTRY }} + registry: ${{ env.REGISTRY }} username: ${{ secrets.DOCKER_REGISTRY_USER }} password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - name: Set image name - run: echo "MINI_LAB_VM_IMAGE=ghcr.io/metal-stack/mini-lab-vms:pr-${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV + - name: Checkout + uses: actions/checkout@v4 + + - name: Make tag + run: | + [ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "MINI_LAB_VM_IMAGE=ghcr.io/metal-stack/mini-lab-vms:${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true + [ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "MINI_LAB_VM_IMAGE=ghcr.io/metal-stack/mini-lab-vms:latest" >> $GITHUB_ENV || true - name: Build Docker image run: | @@ -35,7 +44,6 @@ jobs: - name: Run integration tests shell: bash run: | - export MINI_LAB_VM_IMAGE=ghcr.io/metal-stack/mini-lab-vms:pr-${GITHUB_HEAD_REF##*/} ./test/ci-cleanup.sh ./test/integration.sh env: diff --git a/.github/workflows/master.yaml b/.github/workflows/master.yaml deleted file mode 100644 index 9b1fd396..00000000 --- a/.github/workflows/master.yaml +++ /dev/null @@ -1,43 +0,0 @@ -name: Integration tests - -on: - push: - branches: - - master - -jobs: - test: - name: Integration tests - runs-on: self-hosted - steps: - - name: Gain back workspace permissions # https://github.com/actions/checkout/issues/211 - run: | - [ -d "${GITHUB_WORKSPACE}" ] && sudo chown -R $USER:$USER ${GITHUB_WORKSPACE} - - - name: Checkout - uses: actions/checkout@v3 - - - name: Docker Login - uses: docker/login-action@v2 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - - name: Build Docker image - run: | - make build-vms-image - docker push ghcr.io/metal-stack/mini-lab-vms:latest - - - name: Run integration tests - shell: bash - run: | - ./test/ci-cleanup.sh - ./test/integration.sh - env: - DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} - DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} - - - uses: release-drafter/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml new file mode 100644 index 00000000..f0e8eae2 --- /dev/null +++ b/.github/workflows/release-drafter.yaml @@ -0,0 +1,15 @@ +--- +name: Release Drafter Action + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index c7f96d01..dda0fff1 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,11 @@ else $(error Unknown flavor $(MINI_LAB_FLAVOR)) endif +KIND_ARGS= +ifneq ($(K8S_VERSION),) +KIND_ARGS=--image kindest/node:v$(K8S_VERSION) +endif + ifeq ($(CI),true) DOCKER_COMPOSE_TTY_ARG=-T else @@ -67,8 +72,8 @@ control-plane: control-plane-bake env control-plane-bake: @if ! which kind > /dev/null; then echo "kind needs to be installed"; exit 1; fi @if ! kind get clusters | grep metal-control-plane > /dev/null; then \ - kind create cluster \ - --name metal-control-plane \ + kind create cluster $(KIND_ARGS) \ + --name metal-control-plane \ --config $(KINDCONFIG) \ --kubeconfig $(KUBECONFIG); fi @@ -79,7 +84,7 @@ partition: partition-bake .PHONY: partition-bake partition-bake: # docker pull $(MINI_LAB_VM_IMAGE) - @if ! sudo $(CONTAINERLAB) --topo $(LAB_TOPOLOGY) inspect | grep -i running > /dev/null; then \ + @if ! sudo $(CONTAINERLAB) --topo $(LAB_TOPOLOGY) inspect | grep -i leaf01 > /dev/null; then \ sudo --preserve-env $(CONTAINERLAB) deploy --topo $(LAB_TOPOLOGY) --reconfigure && \ ./scripts/deactivate_offloading.sh; fi @@ -119,6 +124,7 @@ cleanup-control-plane: .PHONY: cleanup-partition cleanup-partition: + mkdir -p clab-mini-lab sudo $(CONTAINERLAB) destroy --topo $(LAB_TOPOLOGY) .PHONY: _privatenet diff --git a/control-plane/kind.yaml b/control-plane/kind.yaml index 370af0e2..6e4c9842 100644 --- a/control-plane/kind.yaml +++ b/control-plane/kind.yaml @@ -5,7 +5,6 @@ networking: apiServerAddress: 0.0.0.0 nodes: - role: control-plane - image: kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8 extraPortMappings: - containerPort: 4443 hostPort: 4443