Skip to content

Add version test

Add version test #11

Workflow file for this run

name: Dynamic Matrix from config.yaml
on:
push:
branches:
- main
jobs:
test-versions:
name: Build & Test Versions
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup Golang
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.0
with:
go-version: 1.20
- name: Download all Go modules
run: go mod download && go mod tidy
- name: Compile all packages and test versions
run: go run main.go test
prepare-versions:
name: Prepare Versions
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Install yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/v4.2.0/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
- name: Get versions from config.yaml
id: get_versions
run: echo "versions=[$(yq -j eval '.versions[].version' config.yaml | tr '\n' ', ' | sed 's/,$/\n/')]" >> $GITHUB_OUTPUT
- name: Print matrix
run: echo "${{ steps.get_versions.outputs.versions }}"
outputs:
versions: ${{ steps.get_versions.outputs.versions }}
build:
name: Build Version
needs: prepare-versions
runs-on: ubuntu-20.04
strategy:
max-parallel: 2
matrix:
version: ${{ fromJson(needs.prepare-versions.outputs.versions) }}
steps:
- name: Run job for matrix element
run: |
echo "Running for version: ${{ matrix.version.version }}"