Skip to content

Commit 2c4e018

Browse files
committed
test: split tests into chunks
Dynamically creating a matrix that executes the tests is not working because it exceeds the maximum of 256 tests. Therefore, adding some hardcoded paths
1 parent 970bf86 commit 2c4e018

File tree

1 file changed

+22
-33
lines changed

1 file changed

+22
-33
lines changed

.github/workflows/tests.yml

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,41 +21,30 @@ jobs:
2121
GOPROXY: "https://proxy.golang.org"
2222
run: go test -tags=unit -v ./...
2323

24-
discover-tests:
25-
name: Discover integration test paths
26-
runs-on: ubuntu-latest
27-
outputs:
28-
matrix: ${{ steps.set-matrix.outputs.matrix }}
29-
steps:
30-
- name: Set up Go
31-
uses: actions/setup-go@19bb51245e9c80abacb2e91cc42b33fa478b8639 # 4.2.1
32-
with:
33-
go-version: '1.22'
34-
35-
- name: Check out source code
36-
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # 4.3.0
37-
38-
- name: Discover test paths
39-
id: set-matrix
40-
# Use go list to find all packages with integration tests
41-
# -f to format the output to only show package import paths that have test files
42-
# Filter to only include packages under the dynatrace/api/ directory
43-
run: |
44-
paths=$(go list -tags=integration -f '{{with .TestGoFiles}}{{$.ImportPath}}{{end}}{{with .XTestGoFiles}}{{$.ImportPath}}{{end}}' ./... | \
45-
sort -u | \
46-
grep '^github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/api/' | \
47-
jq -R -s -c 'split("\n") | map(select(length > 0))')
48-
echo "matrix={\"path\":$paths}" >> $GITHUB_OUTPUT
49-
echo "Found test paths:"
50-
echo "$paths" | jq .
51-
5224
integration-tests:
53-
name: Integration Tests
25+
name: Integration Tests - ${{ matrix.config.name }}
5426
runs-on: ubuntu-latest
55-
needs: discover-tests
5627
strategy:
5728
fail-fast: false
58-
matrix: ${{ fromJson(needs.discover-tests.outputs.matrix) }}
29+
matrix:
30+
config:
31+
- { name: "app", path: "./dynatrace/api/app/..." }
32+
- { name: "automation", path: "./dynatrace/api/automation/..." }
33+
- { name: "cluster", path: "./dynatrace/api/cluster/..." }
34+
- { name: "documents", path: "./dynatrace/api/documents/..." }
35+
- { name: "grail", path: "./dynatrace/api/grail/..." }
36+
- { name: "iam", path: "./dynatrace/api/iam/..." }
37+
- { name: "openpipeline", path: "./dynatrace/api/openpipeline/..." }
38+
- { name: "platform", path: "./dynatrace/api/platform/..." }
39+
- { name: "service", path: "./dynatrace/api/service/..." }
40+
- { name: "slo", path: "./dynatrace/api/slo/..." }
41+
- { name: "v1", path: "./dynatrace/api/v1/..." }
42+
- { name: "v2", path: "./dynatrace/api/v2/..." }
43+
- { name: "builtin (a-b)", path: "$(go list ./dynatrace/api/builtin/... | grep -E '^.+/dynatrace/api/builtin/[a-b][^/]*/?')" } # split into chunks about 20 tests
44+
- { name: "builtin (c-e)", path: "$(go list ./dynatrace/api/builtin/... | grep -E '^.+/dynatrace/api/builtin/[c-e][^/]*/?')" } # split into chunks about 20 tests
45+
- { name: "builtin (f-m)", path: "$(go list ./dynatrace/api/builtin/... | grep -E '^.+/dynatrace/api/builtin/[f-m][^/]*/?')" } # split into chunks about 20 tests
46+
- { name: "builtin (n-r)", path: "$(go list ./dynatrace/api/builtin/... | grep -E '^.+/dynatrace/api/builtin/[n-r][^/]*/?')" } # split into chunks about 20 tests
47+
- { name: "builtin (s-z)", path: "$(go list ./dynatrace/api/builtin/... | grep -E '^.+/dynatrace/api/builtin/[s-z][^/]*/?')" } # split into chunks about 20 tests
5948
steps:
6049
- name: Set up Go
6150
uses: actions/setup-go@19bb51245e9c80abacb2e91cc42b33fa478b8639 # 4.2.1
@@ -69,7 +58,7 @@ jobs:
6958
with:
7059
terraform_wrapper: false
7160

72-
- name: Run Integration Tests - ${{ matrix.path }}
61+
- name: Run Integration Tests - ${{ matrix.config.name }}
7362
if: success() || failure()
7463
env:
7564
GOPROXY: "https://proxy.golang.org"
@@ -82,4 +71,4 @@ jobs:
8271
DT_CLIENT_ID: ${{ secrets.DT_CLIENT_ID }}
8372
DT_CLIENT_SECRET: ${{ secrets.DT_CLIENT_SECRET }}
8473
DT_ACCOUNT_ID: ${{ secrets.DT_ACCOUNT_ID }}
85-
run: go test -tags=integration -v -p 1 ${{ matrix.path }}
74+
run: go test -tags=integration -v -p 1 ${{ matrix.config.path }}

0 commit comments

Comments
 (0)