From b42ed8f9037e435db8f9c8af08b2ce83fa8159b3 Mon Sep 17 00:00:00 2001 From: Ivan Dyachkov Date: Wed, 9 Oct 2024 15:55:50 +0200 Subject: [PATCH] ci: fix matrix --- .github/workflows/test.yaml | 89 ++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 37 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 98817ba..6f1311e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -26,7 +26,7 @@ jobs: needs: - sanity-checks outputs: - versions: ${{ steps.versions.outputs.versions }} + matrix: ${{ steps.versions.outputs.matrix }} steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: get release versions @@ -36,47 +36,62 @@ jobs: versions="$(grep -E "^\+\sOTP-.*" ./RELEASE.md | \ sed -E 's/\+\sOTP-([0-9.-]*),Elixir-([0-9.]*).*/{"otp":"\1","elixir":"\2"}/g' | \ jq -sc .)" - echo "versions=$versions" | tee -a $GITHUB_OUTPUT + + platforms='[ + {"os": "ubuntu24.04", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "ubuntu24.04", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]}, + {"os": "ubuntu22.04", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "ubuntu22.04", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]}, + {"os": "ubuntu20.04", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "ubuntu20.04", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]}, + {"os": "ubuntu18.04", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "ubuntu18.04", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]}, + {"os": "debian12", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "debian12", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]}, + {"os": "debian11", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "debian11", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]}, + {"os": "debian10", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "debian10", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]}, + {"os": "el9", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "el9", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]}, + {"os": "el8", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "el8", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]}, + {"os": "el7", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "el7", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]}, + {"os": "amzn2", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "amzn2", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]}, + {"os": "amzn2023", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "amzn2023", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]}, + {"os": "alpine3.15.1", "arch": "linux/amd64", "runner": ["self-hosted", "linux", "x64", "ephemeral"]}, + {"os": "alpine3.15.1", "arch": "linux/arm64", "runner": ["self-hosted", "linux", "arm64", "ephemeral"]} + ]' + + matrix="$(jq -n \ + --argjson versions "$versions" \ + --argjson platforms "$platforms" \ + '[ + $versions[] as $version | + $platforms[] as $platform | + { + base_image_vsn: "5.0", + otp: $version.otp, + elixir: $version.elixir, + platform: $platform + } + ]')" + + echo "matrix=$matrix" | tee -a $GITHUB_OUTPUT build: - name: ${{ matrix.platform[0] }} ${{ matrix.platform[1] }} OTP-${{ matrix.otp }} Elixir-${{ matrix.elixir }} - runs-on: ${{ github.repository_owner == 'emqx' && matrix.platform[2] || '["ubuntu-latest"]' }} + name: ${{ matrix.platform.os }} ${{ matrix.platform.arch }} OTP-${{ matrix.otp }} Elixir-${{ matrix.elixir }} + runs-on: ${{ github.repository_owner == 'emqx' && matrix.platform.runner || 'ubuntu-latest' }} needs: - prepare strategy: fail-fast: false matrix: - include: ${{ fromJSON(needs.prepare.outputs.versions) }} - base_image_vsn: - - "5.0" - platform: - - [ubuntu24.04, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [ubuntu24.04, linux/arm64, [self-hosted, linux, arm64, ephemeral]] - - [ubuntu22.04, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [ubuntu22.04, linux/arm64, [self-hosted, linux, arm64, ephemeral]] - - [ubuntu20.04, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [ubuntu20.04, linux/arm64, [self-hosted, linux, arm64, ephemeral]] - - [ubuntu18.04, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [ubuntu18.04, linux/arm64, [self-hosted, linux, arm64, ephemeral]] - - [debian12, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [debian12, linux/arm64, [self-hosted, linux, arm64, ephemeral]] - - [debian11, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [debian11, linux/arm64, [self-hosted, linux, arm64, ephemeral]] - - [debian10, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [debian10, linux/arm64, [self-hosted, linux, arm64, ephemeral]] - - [el9, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [el9, linux/arm64, [self-hosted, linux, arm64, ephemeral]] - - [el8, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [el8, linux/arm64, [self-hosted, linux, arm64, ephemeral]] - - [el7, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [el7, linux/arm64, [self-hosted, linux, arm64, ephemeral]] - - [amzn2, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [amzn2, linux/arm64, [self-hosted, linux, arm64, ephemeral]] - - [amzn2023, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [amzn2023, linux/arm64, [self-hosted, linux, arm64, ephemeral]] - - [alpine3.15.1, linux/amd64, [self-hosted, linux, x64, ephemeral]] - - [alpine3.15.1, linux/arm64, [self-hosted, linux, arm64, ephemeral]] + include: ${{ fromJSON(needs.prepare.outputs.matrix) }} steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 @@ -93,9 +108,9 @@ jobs: - name: define base tag id: base_tag run: | - PLATFORM=${{ matrix.platform[1] }} + PLATFORM=${{ matrix.platform.arch }} ARCH="${PLATFORM#linux/}" - TAG="${{ matrix.platform[0] }}-${ARCH}" + TAG="${{ matrix.platform.os }}-${ARCH}" echo "tag=${TAG}" | tee -a $GITHUB_OUTPUT echo "image=ghcr.io/${{ github.repository }}/base-${{ matrix.base_image_vsn }}:${TAG}" | tee -a $GITHUB_OUTPUT - name: Get cache @@ -106,7 +121,7 @@ jobs: driver-opts: network=host - uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 with: - platforms: ${{ matrix.platform[1] }} + platforms: ${{ matrix.platform.arch }} cache-from: type=local,src=/tmp/.docker-buildx-cache,mode=max build-args: | BUILD_FROM=${{ steps.base_tag.outputs.image }}