diff --git a/.github/workflows/container.yaml b/.github/workflows/container.yaml index 31ace75..23d6dfc 100644 --- a/.github/workflows/container.yaml +++ b/.github/workflows/container.yaml @@ -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 @@ -51,12 +53,11 @@ 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" @@ -64,43 +65,58 @@ jobs: "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: diff --git a/Dockerfile.fakemachine-arch b/Dockerfile.arch similarity index 69% rename from Dockerfile.fakemachine-arch rename to Dockerfile.arch index 7297d69..3ff7ec5 100644 --- a/Dockerfile.fakemachine-arch +++ b/Dockerfile.arch @@ -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 diff --git a/Dockerfile.fakemachine-debian b/Dockerfile.debian similarity index 83% rename from Dockerfile.fakemachine-debian rename to Dockerfile.debian index 56efbdd..68eb5c9 100644 --- a/Dockerfile.fakemachine-debian +++ b/Dockerfile.debian @@ -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 \ @@ -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 diff --git a/Dockerfile.debos-arch b/Dockerfile.debos-arch deleted file mode 100644 index b1a2148..0000000 --- a/Dockerfile.debos-arch +++ /dev/null @@ -1,13 +0,0 @@ -ARG BASE_REGISTRY=ghcr.io/go-debos/test-containers -ARG BASE_IMAGE=fakemachine-arch -ARG BASE_TAG=main -FROM $BASE_REGISTRY/$BASE_IMAGE:$BASE_TAG - -# Bits needed to run debos test suite -RUN pacman -Syu --noconfirm dpkg \ - unzip \ - && 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 diff --git a/Dockerfile.debos-debian b/Dockerfile.debos-debian deleted file mode 100644 index dd40f3e..0000000 --- a/Dockerfile.debos-debian +++ /dev/null @@ -1,18 +0,0 @@ -ARG VARIANT=bullseye -ARG BASE_REGISTRY=ghcr.io/go-debos/test-containers -ARG BASE_IMAGE=fakemachine-${VARIANT} -ARG BASE_TAG=main -FROM $BASE_REGISTRY/$BASE_IMAGE:$BASE_TAG - -ARG DEBIAN_FRONTEND=noninteractive - -# Bits needed to run debos test suite -RUN apt-get update && \ - apt-get install --no-install-recommends -y \ - unzip - -# Bits needed to build debos -RUN apt-get update && \ - apt-get install --no-install-recommends -y \ - libostree-dev -