Skip to content

Commit

Permalink
ci(tests): run each test as a separate job
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov committed Dec 19, 2023
1 parent 5cc56e2 commit 789fe33
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
25 changes: 21 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,36 @@ on:
workflow_dispatch: {}

jobs:
list:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.list.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- id: list
run: |
make envtest
go test ./tests/... -list=.
echo "matrix=$(go test ./tests/... -list=. | grep Test | jq -cnR '[inputs | select(length>0)]')" >> $GITHUB_OUTPUT
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME: ${{ secrets.AIVEN_PROJECT_NAME }}
test:
runs-on: ubuntu-latest
needs: list
strategy:
max-parallel: 5
matrix:
k8s-version:
- 1.24.10
name: ${{ fromJson(needs.list.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: make test
- run: make test -run="^${{ matrix.name }}$"
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME: ${{ secrets.AIVEN_PROJECT_NAME }}
ENVTEST_K8S_VERSION: ${{ matrix.k8s-version }}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ endif
IMG ?= aivenoy/aiven-operator:${IMG_TAG}
IMG_TAG ?= $(shell git rev-parse HEAD)
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.24.2
ENVTEST_K8S_VERSION ?= 1.24.10

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -125,7 +125,6 @@ test-e2e-preinstalled:
kubectl kuttl test --config test/e2e/kuttl-test.preinstalled.yaml

test: envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" \
go test ./tests/... -race -run=$(run) -v -timeout 42m -parallel 10 -cover -coverpkg=./controllers -covermode=atomic -coverprofile=coverage.out

##@ Build
Expand Down Expand Up @@ -215,6 +214,7 @@ $(CONTROLLER_GEN): $(LOCALBIN)
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" \

.PHONY: bundle
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
Expand Down

0 comments on commit 789fe33

Please sign in to comment.