diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..544c33c --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,90 @@ +name: PR test run + +on: + pull_request: + types: [opened, synchronize, reopened, labeled] + workflow_dispatch: + +concurrency: + group: test-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 30 + env: + METAL_LAB_REF: main + ENABLE_KVM: "false" + KVM_DEVICE: /dev/null + KUBECONFIG: ${{ github.workspace }}/metal-lab/kubeconfig.yaml + COMPATIBILITY_VALUES: ${{ github.workspace }}/metal-lab/values-containerlab-node1.yaml + steps: + - name: Checkout test framework + uses: actions/checkout@v4 + - name: Checkout metal-lab + uses: actions/checkout@v4 + with: + repository: simontesar/metal-lab + ref: ${{ env.METAL_LAB_REF }} + path: metal-lab + + - name: Install kubectl + uses: azure/setup-kubectl@v4 + - name: Install kustomize + run: | + curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash + sudo mv kustomize /usr/local/bin/ + - name: Install the latest version of kind + run: | + curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 + chmod +x ./kind + sudo mv ./kind /usr/local/bin/kind + - name: Install containerlab + run: bash -c "$(curl -sL https://get.containerlab.dev)" -- -v 0.78.2 + - name: Install chainsaw + uses: kyverno/action-install-chainsaw@v0.2.12 + + - name: Bring up metal-lab + working-directory: metal-lab + run: | + touch kubeconfig.yaml + sudo -E make deploy \ + metal-operator-deploy-wait boot-operator-deploy-wait \ + fedhcp-deploy-wait tftp-deploy-wait + sudo chown -R "$USER:$USER" . + + - name: Run compatibility suite + run: | + mkdir -p "${{ github.workspace }}/artifacts" + make test-compatibility-all \ + ASSERT_TIMEOUT=25m \ + CHAINSAW_EXTRA_FLAGS="--report-format JSON --report-name chainsaw-report --report-path ${{ github.workspace }}/artifacts" + + - name: Collect diagnostics + if: always() + run: | + mkdir -p artifacts + kubectl get all -A > artifacts/k8s-all.txt 2>&1 || true + kubectl get bmc,server,serverclaim,biossettings,bmcsettings,server,serverbootconfigurations -A -o yaml > artifacts/metal-crs.yaml 2>&1 || true + kubectl -n metal-operator-system logs deploy/metal-operator-controller-manager --tail=-1 > artifacts/metal-operator.log 2>&1 || true + kubectl -n boot-operator-system logs deploy/boot-operator-controller-manager --tail=-1 > artifacts/boot-operator.log 2>&1 || true + cp metal-lab/vm/node1/console.log artifacts/node1-console.log 2>/dev/null || true + cp metal-lab/vm/node2/console.log artifacts/node2-console.log 2>/dev/null || true + sudo -E clab inspect -t metal-lab/infra.clab.yaml > artifacts/clab-inspect.txt 2>&1 || true + + - name: Upload artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-artifacts + path: artifacts/ + if-no-files-found: warn + + - name: Tear down + if: always() + working-directory: metal-lab + run: sudo -E make destroy clean-disks || true diff --git a/Makefile b/Makefile index e569458..9127c21 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,8 @@ help: ## Show available targets @echo " test-compatibility-f (F3)" @echo " test-compatibility-f3 (persistent boot order)" @echo "" + @echo " test-compatibility-all (everything: A1,A2,B1-3,D1-3,F3)" + @echo "" .PHONY: test-compatibility test-compatibility-a1 test-compatibility-a2 test-compatibility: ## Run A compatibility chainsaw tests (A1, A2) @@ -80,3 +82,16 @@ test-compatibility-f: ## Run all F boot-control tests (F3) test-compatibility-f3: ## Run F3 persistent boot order $(CHAINSAW) test --values $(COMPATIBILITY_VALUES) --parallel 1 --assert-timeout $(ASSERT_TIMEOUT) $(CHAINSAW_EXTRA_FLAGS) $(COMPATIBILITY_TEST_DIR)/f3-persistent-boot-order + +.PHONY: test-compatibility-all +test-compatibility-all: ## Run every compatibility case (A1,A2,B1-3,D1-3,F3) + $(CHAINSAW) test --values $(COMPATIBILITY_VALUES) --parallel 1 --assert-timeout $(ASSERT_TIMEOUT) $(CHAINSAW_EXTRA_FLAGS) \ + $(COMPATIBILITY_TEST_DIR)/a1-bmc-registration \ + $(COMPATIBILITY_TEST_DIR)/a2-discovery \ + $(COMPATIBILITY_TEST_DIR)/b1-power-annotation \ + $(COMPATIBILITY_TEST_DIR)/b2-bmc-reset \ + $(COMPATIBILITY_TEST_DIR)/b3-indicator-led \ + $(COMPATIBILITY_TEST_DIR)/d1-biossettings-noreboot \ + $(COMPATIBILITY_TEST_DIR)/d2-biossettings-reboot \ + $(COMPATIBILITY_TEST_DIR)/d3-bmcsettings \ + $(COMPATIBILITY_TEST_DIR)/f3-persistent-boot-order