Skip to content

Commit

Permalink
Run e2e tests on label change and introduce auto cancel of previous j…
Browse files Browse the repository at this point in the history
…ob (#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 <[email protected]>

* Label updatecli PRs

Signed-off-by: Danil-Grigorev <[email protected]>

* Allow to run updatecli locally

Signed-off-by: Danil-Grigorev <[email protected]>

* Review: label fix - area/update

Signed-off-by: Danil-Grigorev <[email protected]>

---------

Signed-off-by: Danil-Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev authored Oct 29, 2024
1 parent 8370e64 commit 0d3dba6
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 9 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/e2e-short.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test_chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
## --------------------------------------
Expand Down Expand Up @@ -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) \
Expand Down
5 changes: 3 additions & 2 deletions updatecli/updatecli.d/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ actions:
kind: github/pullrequest
scmid: turtles
spec:
automerge: false
automerge: true
mergemethod: squash
labels:
- capiproviders
- area/update
- kind/chore

0 comments on commit 0d3dba6

Please sign in to comment.