Skip to content

Update docker/setup-qemu-action action to v3 #681

Update docker/setup-qemu-action action to v3

Update docker/setup-qemu-action action to v3 #681

name: "Continuous Integration"
on:
pull_request:
push:
branches:
- '[0-9]+.[0-9]+.x'
- 'refs/pull/*'
tags:
env:
TEST_TAG: laminas/ci-matrix-action:test
jobs:
matrix:
name: Generate job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout sourcecode
uses: actions/checkout@v4
- name: Gather integration test directory names
id: matrix
# This provides a dedicated "check" to asynchronously test all integration tests within the tests/ directory
# The project name from the tests/ directory is then re-used within the "qa" job to run the generated "container"
# within that directory.
run: cd tests; echo "matrix=[\"$(ls -d * | tr '\n' ' ' | sed 's/ $//' | sed 's/ /\",\"/g')\"]" >> $GITHUB_OUTPUT
container:
name: Prepare docker container
runs-on: "ubuntu-latest"
strategy:
fail-fast: true
steps:
- name: Checkout sourcecode
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build container for CI pipeline
uses: docker/build-push-action@v5
with:
context: .
load: true
push: false
tags: ${{ env.TEST_TAG }}
outputs: type=docker,dest=/tmp/container.tar
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Upload container artifact
uses: actions/upload-artifact@v3
with:
name: container
path: /tmp/container.tar
qa:
name: QA Checks
needs: [matrix, container]
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
projectName: ${{ fromJSON(needs.matrix.outputs.matrix) }}
steps:
- name: Checkout sourcecode
uses: actions/checkout@v4
- name: Download container artifact
uses: actions/download-artifact@v3
with:
name: container
path: /tmp
- name: Load image
run: docker load --input /tmp/container.tar
- name: "Generating matrix for project: ${{ matrix.projectName }}"
id: matrix_generation
env:
PROJECT_NAME_TO_TEST: ${{ matrix.projectName }}
run: |
cd tests/${PROJECT_NAME_TO_TEST} && \
docker run \
-i \
--entrypoint "/action/main.js" \
-v $(realpath .):/github/workspace \
--env-file=test.env \
-w=/github/workspace \
${TEST_TAG} $(test -r diff && cat diff || echo -n "")
- name: "Output generated matrix"
uses: sergeysova/jq-action@v2
with:
multiline: true
cmd: "jq . < <(echo '${{ steps.matrix_generation.outputs.matrix }}')"
- name: Minify matrix from test directory
uses: sergeysova/jq-action@v2
id: expected_matrix
env:
PROJECT_NAME_TO_TEST: ${{ matrix.projectName }}
with:
multiline: true
cmd: 'jq -c . < tests/${PROJECT_NAME_TO_TEST}/matrix.json'
- name: "verify output of generated matrix for project: ${{ matrix.projectName }}"
run: diff --color <(echo '${{ steps.expected_matrix.outputs.value }}' | jq --sort-keys) <(echo '${{ steps.matrix_generation.outputs.matrix }}' | jq --sort-keys)
docker-build:
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build
uses: docker/build-push-action@v5
with:
push: false
linting:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "actions/setup-node@v3"
with:
check-latest: true
node-version: 20
- name: "Install node modules"
run: "npm ci"
- name: Run ESLint
run: "npm run lint"
testing:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "actions/setup-node@v3"
with:
check-latest: true
node-version: 20
- name: "Install node modules"
run: "npm ci"
- name: Run Jest
run: "npm run test"