Skip to content

Commit

Permalink
ci: fix matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
id committed Oct 9, 2024
1 parent 826d520 commit b42ed8f
Showing 1 changed file with 52 additions and 37 deletions.
89 changes: 52 additions & 37 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand Down

0 comments on commit b42ed8f

Please sign in to comment.