Skip to content

Use go 1.23.3

Use go 1.23.3 #201

Workflow file for this run

name: Go
on:
push:
branches:
- main
- release-*
paths:
- '.github/workflows/go.yaml'
- '**.go'
- 'go.mod'
- 'go.sum'
- '**/Dockerfile'
- 'tests/*'
pull_request:
branches:
- main
- release-*
paths:
- '.github/workflows/go.yaml'
- '**.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
# env:
# DOCKER_VERSION: 24.0.9
steps:
- name: Install Docker ${{ env.DOCKER_VERSION }}
if: env.DOCKER_VERSION != ''
env:
DEBIAN_FRONTEND: noninteractive
run: |
arch=$(dpkg --print-architecture)
codename=$(. /etc/os-release && echo "$VERSION_CODENAME")
repo=https://download.docker.com/linux/ubuntu
keyfile=/etc/apt/keyrings/docker.asc
pkgver="5:$DOCKER_VERSION-1~ubuntu.20.04~$codename"
sudo install -m 0755 -d -- "${keyfile%/*}"
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o "$keyfile"
sudo chmod 0644 -- "$keyfile"
printf 'deb [arch=%s signed-by=%s] %s %s stable\n' "$arch" "$keyfile" "$repo" "$codename" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get install -y --allow-downgrades docker-ce="$pkgver" docker-ce-cli="$pkgver"
sudo systemctl restart docker
sudo docker --version
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
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@v4
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@v6
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)
id: e2e
run: go test -timeout 15m -v ./tests -args -image=${{ matrix.image }}
- name: Docker logs after e2e failure
if: always() && steps.e2e.outcome == 'failure'
run: docker ps -a -f=label=io.k0sproject.bootloose.owner=bootloose --format "{{.ID}}" | xargs -n1 -r docker logs