From 0d3dba6da7ae0cadee91ec478b052b57d6c783e5 Mon Sep 17 00:00:00 2001 From: Danil Grigorev Date: Tue, 29 Oct 2024 16:34:32 +0100 Subject: [PATCH] Run e2e tests on label change and introduce auto cancel of previous job (#820) * Run e2e tests on label change and introduce cancel - Cancel previous in-progress task if a new is scheduled Signed-off-by: Danil-Grigorev * Label updatecli PRs Signed-off-by: Danil-Grigorev * Allow to run updatecli locally Signed-off-by: Danil-Grigorev * Review: label fix - area/update Signed-off-by: Danil-Grigorev --------- Signed-off-by: Danil-Grigorev --- .github/workflows/ci.yaml | 6 +++++- .github/workflows/codeql.yml | 6 +++++- .github/workflows/e2e-short.yaml | 6 +++++- .github/workflows/golangci-lint.yml | 6 +++++- .github/workflows/lint.yaml | 6 +++++- .github/workflows/test_chart.yaml | 6 +++++- .github/workflows/trivy.yml | 6 +++++- Makefile | 26 ++++++++++++++++++++++++++ updatecli/updatecli.d/manifest.yaml | 5 +++-- 9 files changed, 64 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d1fe2a6c..e51b76a4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,9 +2,13 @@ name: Run CI checks on: pull_request: - types: [opened, edited, synchronize, reopened, labeled, unlabeled] + types: [opened, synchronize, reopened, labeled, unlabeled] workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: ci: name: ci diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 74301baa..64b9903e 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -5,10 +5,14 @@ on: branches: [ "main", "release-*" ] pull_request: branches: [ "main" ] - types: [opened, edited, synchronize, reopened, labeled, unlabeled] + types: [opened, synchronize, reopened, labeled, unlabeled] schedule: - cron: '45 15 * * *' +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: analyze: name: Analyze diff --git a/.github/workflows/e2e-short.yaml b/.github/workflows/e2e-short.yaml index d81601d2..a1fe1dbe 100644 --- a/.github/workflows/e2e-short.yaml +++ b/.github/workflows/e2e-short.yaml @@ -2,7 +2,11 @@ name: Run short e2e tests on: pull_request: - types: [opened, synchronize, reopened] + types: [opened, synchronize, reopened, labeled, unlabeled] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true env: MANAGEMENT_CLUSTER_ENVIRONMENT: "isolated-kind" diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index c262d9aa..ee516a7b 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -2,7 +2,11 @@ name: golangci-lint on: pull_request: - types: [opened, edited, synchronize, reopened, labeled, unlabeled] + types: [opened, synchronize, reopened, labeled, unlabeled] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true # Remove all permissions from GITHUB_TOKEN except metadata. permissions: {} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 6d6d31fc..888b0a74 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -2,7 +2,11 @@ name: Lint on: pull_request: - types: [opened, edited, synchronize, reopened, labeled, unlabeled] + types: [opened, synchronize, reopened, labeled, unlabeled] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true # Remove all permissions from GITHUB_TOKEN except metadata. permissions: {} diff --git a/.github/workflows/test_chart.yaml b/.github/workflows/test_chart.yaml index 3af75bd6..601b5e8a 100644 --- a/.github/workflows/test_chart.yaml +++ b/.github/workflows/test_chart.yaml @@ -2,7 +2,11 @@ name: Lint and Test Charts on: pull_request: - types: [opened, edited, synchronize, reopened, labeled, unlabeled] + types: [opened, synchronize, reopened, labeled, unlabeled] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true env: TAG: v0.0.1 diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index 37a23ccb..cd330f31 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -4,11 +4,15 @@ on: push: branches: [ "main", "release-*" ] pull_request: - types: [opened, edited, synchronize, reopened, labeled, unlabeled] + types: [opened, synchronize, reopened, labeled, unlabeled] branches: [ "main" ] schedule: - cron: '37 1 * * *' +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + permissions: contents: read diff --git a/Makefile b/Makefile index 290d4a83..8d57932f 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,18 @@ SHELL = /usr/bin/env bash -o pipefail # # Go. # +ifeq ($(shell go env GOARCH),amd64) +GO_ARCH = x86_64 +else +GO_ARCH = arm64 +endif + +ifeq ($(shell go env GOOS),linux) +UPDATECLI_OS = Linux +else +UPDATECLI_OS = Darwin +endif + GO_VERSION ?= 1.22.0 GO_CONTAINER_IMAGE ?= docker.io/library/golang:$(GO_VERSION) REPO ?= rancher/turtles @@ -142,6 +154,10 @@ GINGKO_VER := $(call get_go_version,github.com/onsi/ginkgo/v2) GINKGO := $(abspath $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINGKO_VER)) GINKGO_PKG := github.com/onsi/ginkgo/v2/ginkgo +UPDATECLI_BIN := updatecli +UPDATECLI_VER := v0.85.0 +UPDATECLI := $(abspath $(TOOLS_BIN_DIR)/$(UPDATECLI_BIN)-$(UPDATECLI_VER)) + HELM_VER := v3.15.3 HELM_BIN := helm HELM := $(TOOLS_BIN_DIR)/$(HELM_BIN)-$(HELM_VER) @@ -306,6 +322,10 @@ lint: $(GOLANGCI_LINT) ## Lint the codebase lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported by the linter GOLANGCI_LINT_EXTRA_ARGS=--fix $(MAKE) lint +.PHONY: updatecli +updatecli-apply: $(UPDATECLI) + $(UPDATECLI) apply --config ./updatecli/updatecli.d + ## -------------------------------------- ## Testing ## -------------------------------------- @@ -504,6 +524,12 @@ $(SETUP_ENVTEST): # Build setup-envtest from tools folder. $(GINKGO): # Build ginkgo from tools folder. GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GINKGO_PKG) $(GINKGO_BIN) $(GINGKO_VER) +$(UPDATECLI): # Install updatecli + curl -sSL -o ${TOOLS_BIN_DIR}/updatecli_${GO_ARCH}.tar.gz https://github.com/updatecli/updatecli/releases/download/${UPDATECLI_VER}/updatecli_${UPDATECLI_OS}_${GO_ARCH}.tar.gz + cd ${TOOLS_BIN_DIR} && tar -xzf updatecli_${GO_ARCH}.tar.gz + cd ${TOOLS_BIN_DIR} && chmod +x updatecli + cd ${TOOLS_BIN_DIR} && mv updatecli $(UPDATECLI_BIN)-$(UPDATECLI_VER) + $(GOLANGCI_LINT): # Download and install golangci-lint hack/ensure-golangci-lint.sh \ -b $(TOOLS_BIN_DIR) \ diff --git a/updatecli/updatecli.d/manifest.yaml b/updatecli/updatecli.d/manifest.yaml index 5e1903ce..0ecf9974 100644 --- a/updatecli/updatecli.d/manifest.yaml +++ b/updatecli/updatecli.d/manifest.yaml @@ -160,7 +160,8 @@ actions: kind: github/pullrequest scmid: turtles spec: - automerge: false + automerge: true mergemethod: squash labels: - - capiproviders + - area/update + - kind/chore