Sanity Check #95
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: "Sanity Check" | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- master | |
jobs: | |
sanity-check-matrix: | |
strategy: | |
fail-fast: false # let other jobs try to complete if one fails | |
matrix: | |
include: | |
- { id: "default-amd64", extraDockerOpts: "", runner: "ubuntu-22.04" } | |
- { id: "default-arm64", extraDockerOpts: "", runner: "ubuntu-22.04-arm" } | |
- { id: "manifest-cache", extraDockerOpts: "-e ENABLE_MANIFEST_CACHE=true", runner: "ubuntu-22.04" } | |
- { id: "disable-ipv6", extraDockerOpts: "-e DISABLE_IPV6=true", runner: "ubuntu-22.04" } | |
runs-on: "${{ matrix.runner }}" | |
name: "${{ matrix.id }} (${{ matrix.extraDockerOpts }})" | |
steps: | |
- name: Install pipetty and ccze and jq | |
run: | | |
sudo apt-get -o "DPkg::Use-Pty=false" -q install -y colorized-logs ccze jq | |
- name: Get machine's first IPv4 address for eth0 | |
id: ip | |
run: | | |
echo "ETHER=$(sudo ip addr show dev eth0 | egrep '^(\ )+inet\ ' | head -1 | tr -s ' ' | cut -d ' ' -f 3 | cut -d '/' -f 1)" >> $GITHUB_OUTPUT | |
- name: Show the IPs via vars | |
run: | | |
echo "Ethernet IPv4 is: ${{ steps.ip.outputs.ETHER }}" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build image locally to Docker | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: | | |
DEBUG_BUILD=0 | |
BASE_IMAGE_SUFFIX= | |
builder: ${{ steps.buildx.outputs.name }} | |
context: . | |
file: ./Dockerfile | |
tags: sanity-check/docker-registry-proxy:latest | |
push: false | |
load: true | |
- name: Start foreground instance for first-contact sanity checking | |
run: | | |
timeout --signal=9 --verbose 10 docker run \ | |
--name docker_registry_proxy_fg ${{ matrix.extraDockerOpts }} \ | |
sanity-check/docker-registry-proxy:latest || true | |
sleep 3 | |
docker stop docker_registry_proxy_fg || true | |
docker remove docker_registry_proxy_fg || true | |
- name: Start proxy instance in docker (ENABLE_MANIFEST_CACHE=false) | |
run: | | |
docker run -d --rm --name docker_registry_proxy \ | |
-p 0.0.0.0:3128:3128 ${{ matrix.extraDockerOpts }} \ | |
-v $(pwd)/docker_mirror_cache:/docker_mirror_cache \ | |
-v $(pwd)/docker_mirror_certs:/ca \ | |
sanity-check/docker-registry-proxy:latest | |
- name: Get the initial logs for the container into a file after 10s | |
run: | | |
echo "Sleeping 10s..." | |
sleep 10 | |
docker logs docker_registry_proxy &> initial_logs.txt | |
- name: "LOG: initial_logs.txt" | |
run: pipetty ccze -A < initial_logs.txt | |
- name: Wait for container to be up | |
timeout-minutes: 1 | |
run: | | |
declare -i IS_UP=0 | |
while [[ $IS_UP -lt 1 ]]; do | |
echo "Waiting for docker-mirror to be available at ${{ steps.ip.outputs.ETHER }} ..." | |
curl --silent -I http://${{ steps.ip.outputs.ETHER }}:3128/ && IS_UP=1 || true | |
sleep 1 | |
done | |
echo "Container is up..." | |
- name: Grab the CA cert from running container via curl | |
run: | | |
curl http://${{ steps.ip.outputs.ETHER }}:3128/ca.crt | sudo tee /usr/share/ca-certificates/docker_registry_proxy.crt | |
- name: Stop proxy instance in docker | |
timeout-minutes: 1 | |
run: | | |
timeout 58 docker stop docker_registry_proxy | |
- name: Refresh system-wide CA store | |
run: | | |
echo "docker_registry_proxy.crt" | sudo tee -a /etc/ca-certificates.conf | |
sudo update-ca-certificates --fresh | |
- name: Configure dockerd via systemd to use the proxy | |
run: | | |
sudo mkdir -p /etc/systemd/system/docker.service.d | |
cat << EOD | sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf | |
[Service] | |
Environment="HTTP_PROXY=http://${{ steps.ip.outputs.ETHER }}:3128/" | |
Environment="HTTPS_PROXY=http://${{ steps.ip.outputs.ETHER }}:3128/" | |
EOD | |
- name: Reload systemd from disk | |
run: | | |
sudo systemctl daemon-reload | |
- name: Restart dockerd via systemd | |
run: | | |
sudo systemctl restart docker.service | |
- name: Start proxy instance in docker again | |
run: | | |
docker run -d --rm --name docker_registry_proxy \ | |
-p 0.0.0.0:3128:3128 ${{ matrix.extraDockerOpts }} \ | |
-v $(pwd)/docker_mirror_cache:/docker_mirror_cache \ | |
-v $(pwd)/docker_mirror_certs:/ca \ | |
sanity-check/docker-registry-proxy:latest | |
- name: Wait for container to be up again | |
timeout-minutes: 1 | |
run: | | |
declare -i IS_UP=0 | |
while [[ $IS_UP -lt 1 ]]; do | |
echo "Waiting for docker-mirror to be available again at ${{ steps.ip.outputs.ETHER }} ..." | |
curl --silent -I http://${{ steps.ip.outputs.ETHER }}:3128/ && IS_UP=1 || true | |
sleep 1 | |
done | |
echo "Container is up again..." | |
# This can be quite slow, since Github Actions runner Docker comes preloaded with a lot of images. | |
- name: Initial prune of all unused images from docker cache (slow) | |
timeout-minutes: 2 | |
run: | | |
docker image prune --all --force | |
- name: First round of pulls | |
timeout-minutes: 2 | |
run: | | |
docker pull alpine:3.20 | |
docker pull registry.k8s.io/pause:3.6 | |
- name: Get the cold cache logs for the container into a file | |
run: | | |
docker logs docker_registry_proxy &> cold_cache.txt | |
- name: "LOG: cold_cache.txt" | |
run: | | |
pipetty ccze -A < cold_cache.txt | |
- name: "ERRORS/WARNINGS: cold_cache.txt" | |
run: | | |
grep -e "error" -e "warn" cold_cache.txt | pipetty ccze -A || true | |
- name: "JSON: cold_cache.txt" | |
run: | | |
grep '^{"' cold_cache.txt | pipetty jq . | |
- name: prune all unused images from docker cache again | |
timeout-minutes: 1 | |
run: | | |
docker image prune --all --force | |
- name: sleep 2s to allow cache to stale a bit | |
run: | | |
sleep 2 | |
- name: Second round of pulls | |
timeout-minutes: 2 | |
run: | | |
docker pull alpine:3.20 | |
docker pull registry.k8s.io/pause:3.6 | |
- name: Get the warm cache docker logs for the container into a file | |
run: | | |
docker logs docker_registry_proxy &> warm_cache.txt | |
- name: "LOG: warm_cache.txt" | |
run: | | |
pipetty ccze -A < warm_cache.txt | |
echo "--------------------------------------------------------------" | |
grep '^{"' warm_cache.txt | pipetty jq . | |
- name: "ERRORS/WARNINGS: warm_cache.txt" | |
run: | | |
grep -e "error" -e "warn" warm_cache.txt | pipetty ccze -A || true | |
- name: "JSON: warm_cache.txt" | |
run: | | |
grep '^{"' warm_cache.txt | pipetty jq . | |