Private cgroupns 2 #150
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@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@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) | |
continue-on-error: true | |
shell: bash | |
run: | | |
# TODO: Remove this once resolved properly | |
# Downgrade Docker as a workaround | |
sudo install -m 0755 -d /etc/apt/keyrings | |
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | |
sudo chmod a+r /etc/apt/keyrings/docker.asc | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ | |
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
sudo apt-get update | |
sudo apt-get install -y --allow-downgrades docker-ce=5:24.0.9-1~ubuntu.20.04~focal docker-ce-cli=5:24.0.9-1~ubuntu.20.04~focal containerd.io | |
sudo systemctl restart docker | |
sudo docker --version | |
go test -timeout 15m -v ./tests -args -image=${{ matrix.image }} | |
- name: Inspect docker info | |
run: docker info --format '{{json .}}' | |
- name: Inspect daemon json file | |
run: cat /etc/docker/daemon.json | |
- name: Collect Docker logs using journalctl | |
if: always() | |
run: | | |
sudo journalctl -u docker --no-pager --since "1 hour ago" | |
- name: Collect Docker container logs | |
if: always() | |
run: | | |
for container in $(docker ps -a -q); do | |
echo "Logs for container $container:" | |
docker logs $container || true | |
done | |
docker ps -a | |
docker images | |