Test major packages #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |