Skip to content

Commit 0162581

Browse files
committed
Parallelize native tests CI build
1 parent 6c8a1cd commit 0162581

File tree

2 files changed

+57
-5
lines changed

2 files changed

+57
-5
lines changed

.github/generate-native-matrix.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /bin/bash
2+
3+
IFS=$'\n'
4+
modules=($(grep -LR --include=pom.xml '<packaging>pom</packaging>' */ | xargs dirname | sort))
5+
count=${#modules[@]}
6+
partition=$(expr $count / 4 + 1)
7+
8+
json=$'{\n'
9+
json+=$' "include": [\n'
10+
json+=$' {\n'
11+
i=0
12+
partition_index=1
13+
for module in ${modules[@]}; do
14+
if [ $i -gt $partition ]; then
15+
json+=$'"\n },\n {\n'
16+
i=0
17+
fi
18+
if [ $i -eq 0 ]; then
19+
json+=" \"category\": \"Native Tests - $partition_index\","
20+
json+=$'\n "test-modules": "'
21+
((partition_index=partition_index+1))
22+
i=0
23+
fi
24+
json+="$module,"
25+
((i=i+1))
26+
done
27+
json+=$'"\n }\n ]\n}\n'
28+
29+
echo "$json"

.github/workflows/native-build-development.yml

+28-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,27 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12-
build_with_native:
12+
generate-json-matrix:
13+
name: Native Tests - Read JSON matrix
1314
runs-on: ubuntu-latest
1415
if: "github.repository == 'quarkusio/quarkus-quickstarts' || github.event_name == 'workflow_dispatch'"
16+
outputs:
17+
matrix: ${{ steps.generate.outputs.matrix }}
18+
steps:
19+
- uses: actions/checkout@v2
20+
- id: generate
21+
run: |
22+
json=$(.github/generate-native-matrix.sh | tr -d '\n')
23+
echo "::set-output name=matrix::${json}"
24+
build-with-native:
25+
name: ${{matrix.category}}
26+
runs-on: ubuntu-latest
27+
needs: [generate-json-matrix]
28+
if: "github.repository == 'quarkusio/quarkus-quickstarts' || github.event_name == 'workflow_dispatch'"
29+
strategy:
30+
max-parallel: 5
31+
fail-fast: false
32+
matrix: ${{ fromJson(needs.generate-json-matrix.outputs.matrix) }}
1533
steps:
1634
- uses: actions/checkout@v2
1735
with:
@@ -44,10 +62,10 @@ jobs:
4462
cd quarkus
4563
./mvnw -T1C -e -B --settings .github/mvn-settings.xml clean install -Dquickly-ci
4664
47-
- name: Build Quickstart with native
65+
- name: Build Quickstarts with Native
4866
run: |
4967
./mvnw -e -B --settings .github/mvn-settings.xml clean install --fail-at-end -Pnative -Dstart-containers \
50-
-Dquarkus.native.container-build=true
68+
-Dquarkus.native.container-build=true -am -pl "${{ matrix.test-modules }}"
5169
5270
#- name: Check RSS
5371
# env:
@@ -90,11 +108,16 @@ jobs:
90108
shell: bash
91109
run: rm -rf ~/.m2/repository/org/acme
92110

111+
report:
112+
name: Report
113+
runs-on: ubuntu-latest
114+
needs: [build-with-native]
115+
if: "always() && github.repository == 'quarkusio/quarkus-quickstarts'"
116+
steps:
93117
- name: Report
94-
if: "always() && github.repository == 'quarkusio/quarkus-quickstarts'"
95118
env:
96119
GITHUB_TOKEN: ${{ secrets.GITHUB_API_TOKEN }}
97-
STATUS: ${{ job.status }}
120+
STATUS: ${{ needs.build-with-native.result }}
98121
run: |
99122
echo "The report step got status: ${STATUS}"
100123
sudo apt-get update -o Dir::Etc::sourcelist="sources.list" \

0 commit comments

Comments
 (0)