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