Skip to content

Commit 6f18fb9

Browse files
phipagCopilot
andauthored
chore(ci): Run E2E tests in a per-test matrix (#2398)
* Setup initial test matrix for test classes. * Increase concurrency and move build to its own step. * Add dynamic discovery of test classes to avoid duplication between pom.xml and GH actions script. * output single-line JSON as multi-line is not supported with GITHUB_OUTPUT. * increase degree of concurreny to max 25 (20 for e2e and 5 for e2e-graal). * Update .github/workflows/check-e2e.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Address PR comments by Copilot. * Update .github/workflows/check-e2e.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/check-e2e.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix syntax error caused by Copilot. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent f4f2162 commit 6f18fb9

File tree

1 file changed

+67
-7
lines changed

1 file changed

+67
-7
lines changed

.github/workflows/check-e2e.yml

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,69 @@ permissions:
4040
contents: read
4141

4242
jobs:
43-
e2e:
44-
name: End-to-end Tests (Java ${{ matrix.java }})
43+
discover-tests:
44+
name: Discover E2E test classes
45+
runs-on: ubuntu-latest
46+
outputs:
47+
e2e-classes: ${{ steps.parse.outputs.e2e-classes }}
48+
e2e-graal-classes: ${{ steps.parse.outputs.e2e-graal-classes }}
49+
steps:
50+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
51+
- name: Parse test classes from POM profiles
52+
id: parse
53+
run: |
54+
TEST_DIR="powertools-e2e-tests/src/test/java"
55+
POM="powertools-e2e-tests/pom.xml"
56+
57+
# Extracts <include> patterns from a POM profile, resolves them
58+
# against the test directory, and outputs a compact JSON array
59+
# of class names (without .java suffix).
60+
resolve_classes() {
61+
local profile_id="$1"
62+
awk "/<id>${profile_id}<\\/id>/,/<\\/profile>/" "$POM" \
63+
| { grep '<include>' || true; } \
64+
| sed 's/.*<include>\(.*\)<\/include>.*/\1/' \
65+
| while read -r pattern; do
66+
find "$TEST_DIR" -type f -path "$TEST_DIR/$pattern" -print0 | xargs -0 -r basename -a
67+
done \
68+
| sed 's/\.java$//' | sort -u | jq -R . | jq -sc .
69+
}
70+
71+
E2E_CLASSES=$(resolve_classes "e2e")
72+
GRAAL_CLASSES=$(resolve_classes "e2e-graal")
73+
74+
echo "e2e test classes: $E2E_CLASSES"
75+
echo "e2e-graal test classes: $GRAAL_CLASSES"
76+
77+
if [ "$E2E_CLASSES" = "[]" ] || [ -z "$E2E_CLASSES" ]; then
78+
echo "::error::No e2e test classes found — check POM includes and test directory"
79+
exit 1
80+
fi
81+
if [ "$GRAAL_CLASSES" = "[]" ] || [ -z "$GRAAL_CLASSES" ]; then
82+
echo "::error::No e2e-graal test classes found — check POM includes and test directory"
83+
exit 1
84+
fi
85+
86+
echo "e2e-classes=$E2E_CLASSES" >> "$GITHUB_OUTPUT"
87+
echo "e2e-graal-classes=$GRAAL_CLASSES" >> "$GITHUB_OUTPUT"
88+
89+
e2e:
90+
name: E2E ${{ matrix.test-class }} (Java ${{ matrix.java }})
91+
needs: discover-tests
4592
runs-on: ubuntu-latest
4693
permissions:
4794
id-token: write
4895
environment: E2E
4996
strategy:
5097
fail-fast: false
51-
max-parallel: 4
98+
max-parallel: 20
5299
matrix:
53100
java:
54101
- 11
55102
- 17
56103
- 21
57104
- 25
105+
test-class: ${{ fromJSON(needs.discover-tests.outputs.e2e-classes) }}
58106

59107
steps:
60108
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -64,6 +112,8 @@ jobs:
64112
distribution: 'corretto'
65113
java-version: ${{ matrix.java }}
66114
cache: maven
115+
- name: Build all modules
116+
run: mvn -B -DskipTests -ntp install --file pom.xml
67117
- name: Setup AWS credentials
68118
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0
69119
with:
@@ -72,20 +122,25 @@ jobs:
72122
- name: Run e2e test with Maven
73123
env:
74124
JAVA_VERSION: ${{ matrix.java }}
75-
run: mvn -DskipTests -ntp install --file pom.xml && mvn -Pe2e -B -ntp verify --file powertools-e2e-tests/pom.xml
125+
run: >
126+
mvn -Pe2e -B -ntp
127+
-Dit.test="${{ matrix.test-class }}"
128+
verify --file powertools-e2e-tests/pom.xml
76129
77130
e2e-graal:
78-
name: End-to-end GraalVM Tests (Java ${{ matrix.java }})
131+
name: E2E GraalVM ${{ matrix.test-class }} (Java ${{ matrix.java }})
132+
needs: discover-tests
79133
runs-on: ubuntu-latest
80134
permissions:
81135
id-token: write
82136
environment: E2E
83137
strategy:
84138
fail-fast: false
85-
max-parallel: 1
139+
max-parallel: 5
86140
matrix:
87141
java:
88142
- 25
143+
test-class: ${{ fromJSON(needs.discover-tests.outputs.e2e-graal-classes) }}
89144

90145
steps:
91146
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -95,6 +150,8 @@ jobs:
95150
distribution: 'corretto'
96151
java-version: ${{ matrix.java }}
97152
cache: maven
153+
- name: Build all modules
154+
run: mvn -B -DskipTests -ntp install --file pom.xml
98155
- name: Setup AWS credentials
99156
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0
100157
with:
@@ -103,4 +160,7 @@ jobs:
103160
- name: Run e2e-graal test with Maven
104161
env:
105162
JAVA_VERSION: ${{ matrix.java }}
106-
run: mvn -DskipTests -ntp install --file pom.xml && mvn -Pe2e-graal -B -ntp verify --file powertools-e2e-tests/pom.xml
163+
run: >
164+
mvn -Pe2e-graal -B -ntp
165+
-Dit.test="${{ matrix.test-class }}"
166+
verify --file powertools-e2e-tests/pom.xml

0 commit comments

Comments
 (0)