Skip to content

Merge pull request #56 from ncopa/cgroup-parent #48

Merge pull request #56 from ncopa/cgroup-parent

Merge pull request #56 from ncopa/cgroup-parent #48

Workflow file for this run

name: Go
on:
push:
branches:
- main
- release-*
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '**/Dockerfile'
- 'tests/*'
pull_request:
branches:
- main
- release-*
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '**/Dockerfile'
- 'tests/*'
jobs:
prepare:
runs-on: ubuntu-20.04
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-20.04
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@v5
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: Remove any leftover bootloose machines
run: docker ps -a --filter "label=io.k0sproject.bootloose.owner=bootloose" --format "{{.ID}}" | xargs -r docker rm
# TODO i think main and pkg can be run outside of the matrix
- name: Run tests (main)
run: go test -timeout 5m -v ./cmd/...
- 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 }}