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

Commit

Permalink
Merge pull request #146 from kairos-io/e2e-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Itxaka authored Jul 31, 2024
2 parents 293e9c5 + 9210e1a commit 2cedb7e
Show file tree
Hide file tree
Showing 14 changed files with 450 additions and 92 deletions.
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

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"]
42 changes: 35 additions & 7 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
VERSION 0.7

# renovate: datasource=docker depName=golang
ARG --global GO_VERSION=1.22-bookworm
# renovate: datasource=docker depName=golang versioning=docker
ARG --global GO_VERSION=1.22.5-bookworm
# renovate: datasource=github-releases depName=kairos-io/kairos
ARG IMAGE_VERSION=v3.1.1
ARG --global BASE_IMAGE=quay.io/kairos/ubuntu:24.04-core-amd64-generic-${IMAGE_VERSION}-uki

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 +22,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 +35,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 +54,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
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

0 comments on commit 2cedb7e

Please sign in to comment.