diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index da98aff5..e3d67afc 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -1,19 +1,110 @@ -name: Test all packages -on: workflow_dispatch +name: Test major packages +on: + workflow_dispatch: + inputs: + minVersionCount: + description: "Minimum number of versions a package must have to be tested" + required: true + type: number + default: 10 + jobs: - job1: + 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: - - id: set-matrix - run: | - matrix=`curl https://pm.community.intersystems.com/packages/-/all | jq '.[].name' | jq -s` - echo "::set-output name=matrix::$matrix" - job2: - needs: job1 + - id: set-matrix + run: | + matrix=$(curl -L "$PM_URL" | jq -cr "$JQ_SCRIPT") + 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 + docker image ls + 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 + - 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: - matrix: ${{fromJson(needs.job1.outputs.matrix)}} + fail-fast: false + matrix: + package: ${{ fromJson(needs.matrix-setup.outputs.matrix) }} steps: - - run: echo test \ No newline at end of file + - 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 + docker image ls + - name: Container Setup + id: setup-zpm + timeout-minutes: 15 + run: | + # Don't specify the container name because `act` will run multiple jobs in parallel and cause name conflicts + CONTAINER=$(docker run -d --rm -v `pwd`:/home/irisowner/zpm/ zpm) + echo "CONTAINER=$CONTAINER" >> $GITHUB_OUTPUT + docker exec $CONTAINER /usr/irissys/dev/Cloud/ICM/waitISC.sh + docker exec -i $CONTAINER iris session IRIS << EOF + zpm "repo -r -name registry -url https://pm.community.intersystems.com/":1 + halt + EOF + - name: Test ${{ matrix.package }} + timeout-minutes: 15 + env: + CONTAINER: ${{ steps.setup-zpm.outputs.CONTAINER }} + test-flags: >- + -verbose -DUnitTest.ManagerClass=%UnitTest.Manager -DUnitTest.JUnitOutput=/test-reports/junit.xml + -DUnitTest.FailuresAreFatal=1 -DUnitTest.Manager=%UnitTest.Manager + run: | + docker exec -i ${{ env.CONTAINER }} iris session IRIS << EOF + zpm "install ${{ matrix.package }}":1 + zpm "${{ matrix.package }} test -only ${{ env.test-flags }}":1:1 + EOF + - name: Stop Container + run: | + # To ensure a clean state after using `act` locally + docker stop -t 5 ${{ steps.setup-zpm.outputs.CONTAINER }} + docker ps