Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build container images only on changes #332

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/ci-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Split the image builds into a separate workflow so we can easily run it
# when only the Containerfiles have changed without introducing new external
# GitHub Actions dependencies, such as the `tj-actions/changed-files` action.
name: ci images

on:
pull_request:
paths:
- "**/container-images/**"
push:
branches:
- main
paths:
- "**/container-images/**"

jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: install
shell: bash
run: |
sudo apt-get update
sudo apt-get install podman bash
make install-requirements

- name: Print disk space before cleanup
shell: bash
run: |
df -h

- name: Free Disk Space Linux
shell: bash
run: |
sudo docker rmi "$(docker image ls -aq)" >/dev/null 2>&1 || true
sudo rm -rf \
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
/usr/lib/jvm || true

# /mnt has ~ 65 GB free disk space. / is too small.
- name: Reconfigure Docker data-root
run: |
sudo mkdir -p /mnt/docker /etc/docker
echo '{"data-root": "/mnt/docker"}' > /tmp/daemon.json
sudo mv /tmp/daemon.json /etc/docker/daemon.json
cat /etc/docker/daemon.json
sudo systemctl restart docker.service
df -h

- name: Print disk space after cleanup
shell: bash
run: |
df -h

- name: run bats
run: |
make build
69 changes: 14 additions & 55 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- main

jobs:
linux:
bats:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
Expand All @@ -17,41 +17,23 @@ jobs:
sudo apt-get update
sudo apt-get install podman bats bash codespell python3-argcomplete pipx
make install-requirements
- name: Print disk space before cleanup
shell: bash
run: |
df -h
- name: Free Disk Space Linux
shell: bash
run: |
sudo docker rmi "$(docker image ls -aq)" >/dev/null 2>&1 || true
sudo rm -rf \
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
/usr/lib/jvm || true

# /mnt has ~ 65 GB free disk space. / is too small.
- name: Reconfigure Docker data-root
run: |
sudo mkdir -p /mnt/docker /etc/docker
echo '{"data-root": "/mnt/docker"}' > /tmp/daemon.json
sudo mv /tmp/daemon.json /etc/docker/daemon.json
cat /etc/docker/daemon.json
sudo systemctl restart docker.service
df -h


- name: Print disk space after cleanup
shell: bash
run: |
df -h

- name: run bats
run: |
make build
make validate
make bats

bats-nocontainer:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: install bats
shell: bash
run: |
sudo apt-get update
sudo apt-get install podman bats bash codespell python3-argcomplete pipx
make install-requirements

- name: bats-nocontainer
run: |
pip install tqdm --break-system-packages
Expand All @@ -67,33 +49,10 @@ jobs:
sudo apt-get update
sudo apt-get install bats bash codespell python3-argcomplete pipx
make install-requirements
- name: Print disk space before cleanup
shell: bash
run: |
df -h
- name: Free Disk Space Linux
shell: bash
run: |
sudo docker rmi "$(docker image ls -aq)" >/dev/null 2>&1 || true
sudo rm -rf \
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
/usr/lib/jvm || true

# /mnt has ~ 65 GB free disk space. / is too small.
- name: Reconfigure Docker data-root
run: |
sudo mkdir -p /mnt/docker /etc/docker
echo '{"data-root": "/mnt/docker"}' > /tmp/daemon.json
sudo mv /tmp/daemon.json /etc/docker/daemon.json
cat /etc/docker/daemon.json
sudo systemctl restart docker.service
df -h

- name: Print disk space after cleanup
shell: bash
- name: build image
run: |
df -h
make build cpuonly

- name: bats-docker
run: |
Expand Down
20 changes: 16 additions & 4 deletions container_build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -euo pipefail

available() {
command -v "$1" >/dev/null
}
Expand Down Expand Up @@ -61,10 +63,20 @@ main() {
platform="linux/arm64"
fi

for i in container-images/*; do
build "$i" "$@"
done
local target="${1:-all}"

if [ "$target" = "--help" ]; then
echo "Usage: $0 [all|image_name]"
exit 0
fi

if [ "$target" = "all" ]; then
for i in container-images/*; do
build "$i" "${@:2}"
done
else
build "container-images/$target" "${@:2}"
fi
}

main "$@"

Loading