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

Test container before pushing to Docker registry #28

Draft
wants to merge 8 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
72 changes: 44 additions & 28 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ env:
jobs:
build-containers:
runs-on: ubuntu-latest
name: Build ${{ matrix.variant }} containers
name: Build ${{ matrix.variant }} container
env:
TEST_TAG: ${{ github.repository }}-${{ matrix.variant }}-testbuild
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -51,56 +53,70 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Build Fakemachine containers
- name: Extract metadata (tags, labels) for Fakemachine Docker image
id: meta-fakemachine
- name: Extract metadata (tags, labels) for Docker image
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/fakemachine-${{ matrix.variant }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.variant }}
tags: |
"type=ref,event=branch"
"type=ref,suffix=-{{sha}},event=branch"
"type=ref,suffix=-{{date 'YYYYMMDD'}},event=branch"
"type=ref,event=tag"
"type=ref,event=pr"

- name: Build and push Fakemachine Docker image
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.fakemachine-${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-fakemachine.outputs.tags }}
labels: ${{ steps.meta-fakemachine.outputs.labels }}
file: Dockerfile.${{ matrix.dockerfile }}
load: true
push: false
tags: ${{ env.TEST_TAG }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VARIANT=${{ matrix.variant }}

# Build Debos containers (based on Fakemachine container)
- name: Extract metadata (tags, labels) for Debos Docker image
id: meta-debos
uses: docker/metadata-action@v5
# TODO: actually do something useful here
# git clone latest version && go test -v ./...
- name: Checkout fakemachine (for unit tests)
uses: actions/checkout@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/debos-${{ matrix.variant }}
tags: |
"type=ref,event=branch"
"type=ref,suffix=-{{sha}},event=branch"
"type=ref,suffix=-{{date 'YYYYMMDD'}},event=branch"
"type=ref,event=tag"
"type=ref,event=pr"
repository: 'go-debos/fakemachine'
path: src/fakemachine

- name: Run fakemachine unit tests in Docker image
run: |
docker run --rm \
--workdir /mnt \
--mount "type=bind,source=$(pwd),destination=/mnt" \
${{ env.TEST_TAG }} \
bash -c "ls -la && cd src/fakemachine && go test -v ./... --backend=qemu"

- name: Checkout debos (for unit tests)
uses: actions/checkout@v4
with:
repository: 'go-debos/debos'
path: src/debos

- name: Run debos unit tests in Docker image
run: |
docker run --rm \
--workdir /mnt \
--mount "type=bind,source=$(pwd),destination=/mnt" \
${{ env.TEST_TAG }} \
bash -c "ls -la && cd src/debos && go test -v ./... --fakemachine-backend=qemu"

- name: Build and push Debos Docker image
- name: Push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.debos-${{ matrix.dockerfile }}
file: Dockerfile.${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-debos.outputs.tags }}
labels: ${{ steps.meta-debos.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VARIANT=${{ matrix.variant }}
BASE_REGISTRY=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
BASE_IMAGE=fakemachine-${{ matrix.variant }}
BASE_TAG=${{ steps.meta-fakemachine.outputs.version }}

# Job to key success status against
allgreen:
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile.fakemachine-arch → Dockerfile.arch
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ RUN pacman -Syu --noconfirm qemu-base \
--assume-installed initramfs \
&& find /var/cache/pacman/pkg -mindepth 1 -delete

# Bits needed to run debos
RUN pacman -Syu --noconfirm dpkg \
unzip \
&& find /var/cache/pacman/pkg -mindepth 1 -delete

# Bits needed to build fakemachine
RUN pacman -Syu --noconfirm go \
git \
&& find /var/cache/pacman/pkg -mindepth 1 -delete

# Bits needed to build debos
RUN pacman -Syu --noconfirm ostree \
&& find /var/cache/pacman/pkg -mindepth 1 -delete
10 changes: 10 additions & 0 deletions Dockerfile.fakemachine-debian → Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ RUN if [ "$VARIANT" != "bullseye" ] ; then \
apt-get install --no-install-recommends -y systemd-resolved; \
fi

# Bits needed to run debos
RUN apt-get update && \
apt-get install --no-install-recommends -y \
unzip

# Bits needed to build fakemachine
RUN apt-get update && \
apt-get install --no-install-recommends -y \
Expand All @@ -31,3 +36,8 @@ RUN apt-get update && \
ca-certificates \
gcc \
libc6-dev

# Bits needed to build debos
RUN apt-get update && \
apt-get install --no-install-recommends -y \
libostree-dev
13 changes: 0 additions & 13 deletions Dockerfile.debos-arch

This file was deleted.

18 changes: 0 additions & 18 deletions Dockerfile.debos-debian

This file was deleted.

Loading