Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Add bootable test for enki UKI generated isos #146

Merged
merged 4 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
27 changes: 27 additions & 0 deletions .github/workflows/bootable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: 'Enki Bootable tests'

on:
pull_request:
push:
branches:
- main

concurrency:
group: enki-bootable-${{ github.ref || github.head_ref }}
cancel-in-progress: true

env:
FORCE_COLOR: 1

jobs:
bootable:
runs-on: ubuntu-latest
steps:
- uses: earthly/actions-setup@v1.0.13
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build
run: earthly +test-bootable
12 changes: 2 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG LUET_VERSION=0.35.2
ARG GO_VERSION=1.22-alpine
ARG GO_VERSION=1.22.5-alpine
mauromorales marked this conversation as resolved.
Show resolved Hide resolved

FROM quay.io/luet/base:$LUET_VERSION AS luet
FROM golang:$GO_VERSION AS builder
Expand Down Expand Up @@ -41,12 +41,4 @@ RUN dnf install -y binutils mtools efitools shim openssl dosfstools xorriso rsyn

COPY --from=builder /enki /enki

ENTRYPOINT ["/enki"]

FROM gcr.io/kaniko-project/executor:latest

COPY --from=builder /enki /enki

ENTRYPOINT ["/enki"]

CMD ["convert"]
ENTRYPOINT ["/enki"]
35 changes: 30 additions & 5 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ VERSION 0.7
ARG --global GO_VERSION=1.22-bookworm

enki-image:
FROM DOCKERFILE -f e2e/assets/Dockerfile.enki e2e/assets/
FROM DOCKERFILE -f Dockerfile .

SAVE IMAGE enki-image

go-deps:
ARG GO_VERSION
FROM golang:$GO_VERSION
RUN apt-get update && apt-get install -y rsync gcc bash git jq docker
WORKDIR /build
COPY go.mod go.sum . # This will make the go mod download able to be cached as long as it hasnt change
RUN go mod download
Expand All @@ -20,7 +19,7 @@ go-deps:

version:
FROM +go-deps
COPY . ./
COPY .git ./
RUN --no-cache echo $(git describe --always --tags --dirty) > VERSION
RUN --no-cache echo $(git describe --always --dirty) > COMMIT
ARG VERSION=$(cat VERSION)
Expand All @@ -33,11 +32,10 @@ test:
WORKDIR /build
COPY . .
ARG TEST_PATHS=./...
ARG LABEL_FILTER=
ENV CGO_ENABLED=1
# Some test require the docker sock exposed
WITH DOCKER --load enki-image=(+enki-image)
RUN go run github.com/onsi/ginkgo/v2/ginkgo run --label-filter "$LABEL_FILTER" -v --fail-fast --race --covermode=atomic --coverprofile=coverage.out --coverpkg=github.com/kairos-io/enki/... -p -r $TEST_PATHS
RUN go run github.com/onsi/ginkgo/v2/ginkgo run --label-filter "build-uki && genkey" -v --fail-fast --race --covermode=atomic --coverprofile=coverage.out --coverpkg=github.com/kairos-io/enki/... -p -r $TEST_PATHS
END
SAVE ARTIFACT coverage.out AS LOCAL coverage.out

Expand All @@ -53,3 +51,30 @@ build:
ENV CGO_ENABLED=0
RUN go build -o enki -ldflags "${LDFLAGS}" main.go
SAVE ARTIFACT enki enki AS LOCAL build/enki

build-iso:
FROM +enki-image
ARG BASE_IMAGE=quay.io/kairos/ubuntu:24.04-core-amd64-generic-v3.1.1-uki
Itxaka marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /build
RUN /enki genkey -e 7 --output /keys CIKEYS
# Extend the default cmdline to write everything to serial first :D
RUN /enki build-uki $BASE_IMAGE --output-dir /build/ -k /keys --output-type iso -x "console=ttyS0"
SAVE ARTIFACT /build/*.iso enki.iso AS LOCAL build/enki.iso


test-bootable:
FROM +go-deps
WORKDIR /build
RUN . /etc/os-release && echo "deb http://deb.debian.org/debian $VERSION_CODENAME-backports main contrib non-free" > /etc/apt/sources.list.d/backports.list
RUN apt update
RUN apt install -y qemu-system-x86 qemu-utils git swtpm && apt clean
COPY . .
COPY +build-iso/enki.iso enki.iso
ARG ISO=/build/enki.iso
ARG FIRMWARE=/usr/share/OVMF/OVMF_CODE.fd
ARG USE_QEMU=true
ARG MEMORY=4000
ARG CPUS=2
ARG CREATE_VM=true
RUN date
RUN go run github.com/onsi/ginkgo/v2/ginkgo run --label-filter "bootable" -v --fail-fast -r ./e2e
21 changes: 0 additions & 21 deletions e2e/assets/Dockerfile.enki

This file was deleted.

Binary file added e2e/assets/efivars.empty.fd
Binary file not shown.
16 changes: 0 additions & 16 deletions e2e/assets/luet-amd64.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions e2e/assets/luet-arm64.yaml

This file was deleted.

Loading