@@ -2,11 +2,16 @@ name: Test major packages
2
2
on :
3
3
workflow_dispatch :
4
4
inputs :
5
+ nJobs :
6
+ description : " Number of jobs to run in parallel"
7
+ required : true
8
+ type : number
9
+ default : 8
5
10
minVersionCount :
6
11
description : " Minimum number of versions a package must have to be tested"
7
12
required : true
8
13
type : number
9
- default : 10
14
+ default : 1
10
15
11
16
jobs :
12
17
matrix-setup :
17
22
outputs :
18
23
matrix : ${{ steps.set-matrix.outputs.matrix }}
19
24
steps :
25
+ - name : Checkout repository
26
+ uses : actions/checkout@v4
20
27
- id : set-matrix
21
28
run : |
22
- matrix=$(curl -L "$PM_URL" | jq -cr "$JQ_SCRIPT")
29
+ matrix=$(curl -L "$PM_URL" | jq -cr "$JQ_SCRIPT" | python3 .github/scripts/batcher.py ${{ inputs.nJobs }} | jq -cr . )
23
30
echo "matrix=$matrix" >> $GITHUB_OUTPUT
24
31
25
32
prepare-image :
@@ -43,14 +50,14 @@ jobs:
43
50
- name : Test Image
44
51
run : |
45
52
docker load -i /tmp/zpmimage.tar
46
- docker image ls
47
53
CONTAINER=$(docker run -d --rm -v `pwd`:/home/irisowner/zpm/ zpm)
48
54
docker exec $CONTAINER /usr/irissys/dev/Cloud/ICM/waitISC.sh
49
55
docker exec -i $CONTAINER iris session IRIS << EOF
50
56
zpm "list":1
51
57
zn "%SYS"
52
58
zpm "test zpm -v -only":1:1
53
59
EOF
60
+ docker container stop $CONTAINER
54
61
- name : Upload Image
55
62
uses : actions/upload-artifact@v2
56
63
with :
65
72
strategy :
66
73
fail-fast : false
67
74
matrix :
68
- package : ${{ fromJson(needs.matrix-setup.outputs.matrix) }}
75
+ packages : ${{ fromJson(needs.matrix-setup.outputs.matrix) }}
69
76
steps :
70
77
- uses : actions/checkout@master
71
78
- name : Set up Docker Buildx
@@ -78,33 +85,63 @@ jobs:
78
85
- name : Load Image
79
86
run : |
80
87
docker load -i /tmp/zpmimage.tar
81
- docker image ls
82
- - name : Container Setup
83
- id : setup-zpm
84
- timeout-minutes : 15
85
- run : |
86
- # Don't specify the container name because `act` will run multiple jobs in parallel and cause name conflicts
87
- CONTAINER=$(docker run -d --rm -v `pwd`:/home/irisowner/zpm/ zpm)
88
- echo "CONTAINER=$CONTAINER" >> $GITHUB_OUTPUT
89
- docker exec $CONTAINER /usr/irissys/dev/Cloud/ICM/waitISC.sh
90
- docker exec -i $CONTAINER iris session IRIS << EOF
91
- zpm "repo -r -name registry -url https://pm.community.intersystems.com/":1
92
- halt
93
- EOF
94
- - name : Test ${{ matrix.package }}
95
- timeout-minutes : 15
88
+ - name : Run tests sequentially
96
89
env :
97
- CONTAINER : ${{ steps.setup-zpm.outputs.CONTAINER }}
98
90
test-flags : >-
99
91
-verbose -DUnitTest.ManagerClass=%UnitTest.Manager -DUnitTest.JUnitOutput=/test-reports/junit.xml
100
92
-DUnitTest.FailuresAreFatal=1 -DUnitTest.Manager=%UnitTest.Manager
101
93
run : |
102
- docker exec -i ${{ env.CONTAINER }} iris session IRIS << EOF
103
- zpm "install ${{ matrix.package }}":1
104
- zpm "${{ matrix.package }} test -only ${{ env.test-flags }}":1:1
94
+ # Don't specify the container name because `act` will run multiple jobs in parallel and cause name conflicts
95
+ packages=${{ matrix.packages }}
96
+ IFS=','
97
+ RED='\033[0;31m'
98
+ GREEN='\033[0;32m'
99
+ NC='\033[0m'
100
+
101
+ # The EOF of the following heredocs are intentially unindented
102
+ # because <<-EOF doesn't like spaces while yaml only allows spaces
103
+ # A potential solution is to use a script file instead of a block
104
+ for package in $packages; do
105
+ echo "::group::Set up container for package $package"
106
+ CONTAINER=$(docker run -d --rm -v `pwd`:/home/irisowner/zpm/ zpm)
107
+ docker exec $CONTAINER /usr/irissys/dev/Cloud/ICM/waitISC.sh
108
+ docker exec -i $CONTAINER iris session IRIS <<- EOF
109
+ zpm "config set analytics 0":1
110
+ zpm "repo -r -name registry -url https://pm.community.intersystems.com/":1
111
+ halt
105
112
EOF
106
- - name : Stop Container
107
- run : |
108
- # To ensure a clean state after using `act` locally
109
- docker stop -t 5 ${{ steps.setup-zpm.outputs.CONTAINER }}
110
- docker ps
113
+ echo "::endgroup::"
114
+
115
+ echo "::group::Test package $package"
116
+ set +e
117
+ docker exec -i $CONTAINER iris session IRIS <<- EOF
118
+ zpm "install $package":1
119
+ zpm "$package test -only ${{ env.test-flags }}":1:1
120
+ EOF
121
+
122
+ if [ $? -ne 0 ]; then
123
+ # ATTENTION: Don't change the format of the following echo without updating the regex in the summarize.py script
124
+ echo -e "\n${RED}Test for package $package failed${NC}" >&2
125
+ else
126
+ # ATTENTION: Don't change the format of the following echo without updating the regex in the summarize.py script
127
+ echo -e "\n${GREEN}Test for package $package passed${NC}"
128
+ fi
129
+ echo "::endgroup::"
130
+
131
+ echo "::group::Clean up container for $package"
132
+ # To ensure a clean state after using `act` locally
133
+ docker stop -t 5 $CONTAINER
134
+ echo "::endgroup::"
135
+ done
136
+
137
+ IFS=' '
138
+
139
+ summarize :
140
+ needs :
141
+ - run-tests
142
+ runs-on : ubuntu-latest
143
+ steps :
144
+ - name : Call package-summary workflow
145
+ uses : ./.github/workflows/packages-summary.yml
146
+ with :
147
+ runId : ${{ github.run_id }}
0 commit comments