From 138e56984188bf45cf6565058fa3cc071fe5690e Mon Sep 17 00:00:00 2001 From: Luigi Operoso <40476330+brokenpip3@users.noreply.github.com> Date: Mon, 13 Nov 2023 00:26:13 +0100 Subject: [PATCH] fix(ci): update devcontainers, github actions config, bats action (#928) --- .devcontainer/devcontainer.json | 85 +++++++++++++++----------- .github/dependabot.yml | 16 ++++- .github/workflows/auto-tests-bats.yaml | 14 +++-- Makefile | 4 +- test/bats/test_helper.bash | 2 +- 5 files changed, 75 insertions(+), 46 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 31270ced..bec6e7a7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,43 +1,56 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/kubernetes-helm-minikube +// For format details, see https://aka.ms/devcontainer.json { - "name": "Kubernetes - Minikube-in-Docker", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/base:bookworm", + "name": "Jenkins kubernetes operator devcontainer", + "image": "mcr.microsoft.com/devcontainers/base:bookworm", - "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": { - "enableNonRootDocker": "true", - "moby": "true" - }, - "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { - "version": "latest", - "helm": "latest", - "minikube": "latest" - }, - "ghcr.io/devcontainers/features/go:1": { - "version": "1.15", - "golangciLintVersion": "1.26.0" - }, - "ghcr.io/mpriscella/features/kind:1": { - "version": "latest" - }, - "ghcr.io/edouard-lopez/devcontainer-features/bats:0": { - "version": "latest" - } - } - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "enableNonRootDocker": "true", + "moby": "true" + }, + "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { + "version": "latest", + "helm": "latest", + "minikube": "none" + }, + "ghcr.io/devcontainers/features/go:1": { + "version": "1.15", + "golangciLintVersion": "1.26.0" + }, + "ghcr.io/mpriscella/features/kind:1": { + "version": "latest" + }, + "ghcr.io/edouard-lopez/devcontainer-features/bats:0": { + "version": "latest" + }, + "ghcr.io/brokenpip3/devcontainers-bats/bats-libs:0": { + } + }, + // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "kubectl version", + "postCreateCommand": "go version", - // Use 'postStartCommand' to run commands after the container is created like starting minikube. - // "postStartCommand": "nohup bash -c 'minikube start &' > minikube.log 2>&1", + // "postStartCommand": "nohup bash -c 'minikube start &' > minikube.log 2>&1", - // Configure tool-specific properties. - // "customizations": {}, + // Configure tool-specific properties. + "customizations": { + "codespaces": { + "openFiles": [ + "Makefile" + ] + }, + // install some vscode extensions + "vscode": { + "extensions": [ + "golang.Go", + "jetmartin.bats", + "ms-kubernetes-tools.vscode-kubernetes-tools", + "budparr.language-hugo-vscode", + "GitHub.copilot", + "GitHub.copilot-chat" + ] + } + }, - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" + // "remoteUser": "root" } diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 620ba821..285819f7 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,11 +4,25 @@ updates: directory: "/" schedule: interval: "daily" + groups: + golang: + patterns: + - "*" + - package-ecosystem: "npm" directory: "/website" schedule: interval: "daily" + groups: + npm: + patterns: + - "*" + - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "weekly" + interval: "daily" + groups: + actions: + patterns: + - "*" diff --git a/.github/workflows/auto-tests-bats.yaml b/.github/workflows/auto-tests-bats.yaml index b5115458..abd839c5 100644 --- a/.github/workflows/auto-tests-bats.yaml +++ b/.github/workflows/auto-tests-bats.yaml @@ -44,13 +44,13 @@ jobs: - name: Ensure Golang runtime dependencies run: make go-dependencies - - name: Setup BATS - uses: mig4/setup-bats@v1 + - name: Setup Bats and libs + uses: brokenpip3/setup-bats-libs@1.5.2 with: - bats-version: 1.9.0 - - - name: Setup Bats libs - uses: brokenpip3/setup-bats-libs@0.1.0 + support-path: "${{ github.workspace }}/.bats/bats-support" + assert-path: "${{ github.workspace }}/.bats/bats-assert" + detik-path: "${{ github.workspace }}/.bats/bats-detik" + file-path: "${{ github.workspace }}/.bats/bats-file" - name: Kind setup uses: helm/kind-action@v1.5.0 @@ -58,4 +58,6 @@ jobs: cluster_name: ${{env.KIND_CLUSTER_NAME}} - name: Jenkins Operator - bats tests + env: + BATS_LIB_PATH: "${{ github.workspace }}/.bats" run: make bats-tests diff --git a/Makefile b/Makefile index 4d6c6648..7374460c 100644 --- a/Makefile +++ b/Makefile @@ -387,11 +387,11 @@ ifndef BUILD_PRESENT bats-tests: container-runtime-build-amd64 ## Run bats tests @echo "+ $@" kind load docker-image ${IMAGE_NAME} --name $(KIND_CLUSTER_NAME) - OPERATOR_IMAGE="${IMAGE_NAME}" TERM=xterm bats -T -p -x test/bats + OPERATOR_IMAGE="${IMAGE_NAME}" TERM=xterm bats -T -p test/bats else bats-tests: ## Run bats tests @echo "+ $@" - OPERATOR_IMAGE="${IMAGE_NAME}" TERM=xterm bats -T -p -x test/bats + OPERATOR_IMAGE="${IMAGE_NAME}" TERM=xterm bats -T -p test/bats endif .PHONY: crc-start diff --git a/test/bats/test_helper.bash b/test/bats/test_helper.bash index 0fde73fa..bb5da0b3 100644 --- a/test/bats/test_helper.bash +++ b/test/bats/test_helper.bash @@ -1,5 +1,5 @@ _common_setup() { - export BATS_LIB_PATH="/usr/lib/" + export BATS_LIB_PATH="${BATS_LIB_PATH}:/usr/lib" bats_load_library bats-support bats_load_library bats-assert bats_load_library bats-file