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 6fb305e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@ 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: |
echo "matrix=$(LIST_ONLY=1 go test ./tests/... -list=. | grep Test | jq -cnR '[inputs | select(length>0)]')" >> $GITHUB_OUTPUT
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 }}
2 changes: 1 addition & 1 deletion 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
7 changes: 7 additions & 0 deletions tests/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ const (
)

func TestMain(m *testing.M) {
if os.Getenv("LIST_ONLY") != "" {
// For go test ./... -list=.
// to get test names
m.Run()
return
}

err := setupSuite()
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 6fb305e

Please sign in to comment.