Skip to content

Fix tests + enable GH test action #35

Fix tests + enable GH test action

Fix tests + enable GH test action #35

Workflow file for this run

name: Go
on:
push:
branches:
- main
- release-*
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '**/Dockerfile'
pull_request:
branches:
- main
- release-*
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '**/Dockerfile'
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
hash: ${{ steps.set-hash.outputs.hash }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Populate list of images to build
id: set-matrix
run: |
IMAGES=($(find images -mindepth 1 -maxdepth 1 -type d -exec basename {} \;))
IMAGES_JSON="[$(printf '"%s",' "${IMAGES[@]}")]"
IMAGES_JSON="${IMAGES_JSON/,\]/]}"
echo "matrix={\"image\":$IMAGES_JSON}" >> $GITHUB_OUTPUT
- name: Calculate a hash for images/
id: set-hash
run: echo "hash=${{ hashFiles('images/**') }}" >> $GITHUB_OUTPUT
run_tests:
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.prepare.outputs.matrix)}}
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Buildx Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ needs.prepare.outputs.hash }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build ${{ matrix.image }}
uses: docker/build-push-action@v4
with:
push: false
load: true
tags: ${{ matrix.image }}:latest
context: images/${{ matrix.image }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Run go install
run: go install
# TODO i think main and pkg can be run outside of the matrix
- name: Run tests (main)
run: go test -timeout 5m -v .
- name: Run tests (pkg)
run: go test -timeout 5m -v ./pkg/...
- name: Run tests (e2e)
run: go test -timeout 15m -v ./tests -args -image=${{ matrix.image }}