particle-os-cli/integration-tests/Earthfile
Gerald Pinder 02b2fe5434
refactor!: Rename template to generate and move rebase/upgrade under switch (#116)
This updates the `template` subcommand to be `generate`. The `template`
usage will continue to work as an alias to `generate`. A new `switch`
command is added that will manage both `rpm-ostree rebase` and
`rpm-ostree upgrade` and is fully replacing the respective subcommands
as a breaking change.

The new `switch` command is under the feature flag `switch` and will
currently only build for the `main` branch builds until it is moved as a
default feature (`v0.9.0`).

Closes #159
2024-05-26 22:47:34 -04:00

143 lines
2.9 KiB
Text

VERSION 0.8
PROJECT blue-build/cli
all:
BUILD +test-image
BUILD +test-secureblue
BUILD +test-legacy-image
BUILD +build
BUILD +rebase
BUILD +upgrade
BUILD +switch
test-image:
FROM +build-template --src=template-containerfile
WORKDIR /tmp/test
COPY ./test-scripts/*.sh ./
DO +RUN_TESTS
test-legacy-image:
FROM +build-template --src=template-legacy-containerfile
WORKDIR /tmp/test
COPY ./test-scripts/*.sh ./
DO +RUN_TESTS
test-secureblue:
FROM +build-template --src=template-secureblue
WORKDIR /tmp/test
COPY ./test-scripts/secureblue/*.sh ./
DO +RUN_TESTS
test-secureblue-ucore:
FROM +build-template --src=template-secureblue-ucore
WORKDIR /tmp/test
COPY ./test-scripts/secureblue/*.sh ./
DO +RUN_TESTS
build-template:
ARG --required src
FROM DOCKERFILE \
-f +$src/test/Containerfile \
+$src/test/*
template-containerfile:
FROM +test-base
RUN bluebuild -vv generate recipes/recipe.yml | tee Containerfile
SAVE ARTIFACT /test
template-legacy-containerfile:
FROM +legacy-base
RUN bluebuild -vv template config/recipe.yml | tee Containerfile
SAVE ARTIFACT /test
template-secureblue:
FROM +secureblue-base
RUN bluebuild -vv generate -o Containerfile recipes/general/recipe-silverblue-nvidia.yml
SAVE ARTIFACT /test
template-secureblue-ucore:
FROM +secureblue-base
RUN bluebuild -vv generate -o Containerfile recipes/server/recipe-server-main.yml
SAVE ARTIFACT /test
build:
FROM +test-base
RUN bluebuild -vv build recipes/recipe.yml
rebase:
FROM +legacy-base
RUN bluebuild -vv rebase config/recipe.yml
upgrade:
FROM +legacy-base
RUN mkdir -p /etc/bluebuild && touch $BB_TEST_LOCAL_IMAGE
RUN bluebuild -vv upgrade config/recipe.yml
switch:
FROM +test-base
RUN mkdir -p /etc/bluebuild && touch $BB_TEST_LOCAL_IMAGE
RUN bluebuild -vv switch recipes/recipe.yml
secureblue-base:
FROM +test-base
RUN rm -fr /test
GIT CLONE https://github.com/secureblue/secureblue.git /test
DO +GEN_KEYPAIR
legacy-base:
FROM ../+blue-build-cli-alpine
RUN apk update --no-cache && apk add bash grep jq sudo coreutils
ENV BB_TEST_LOCAL_IMAGE=/etc/bluebuild/cli_test-legacy.tar.gz
ENV CLICOLOR_FORCE=1
COPY ./mock-scripts/ /usr/bin/
WORKDIR /test
COPY ./legacy-test-repo /test
DO ../+INSTALL --OUT_DIR="/usr/bin/" --BUILD_TARGET="x86_64-unknown-linux-musl" --TAGGED="true"
DO +GEN_KEYPAIR
test-base:
FROM ../+blue-build-cli-alpine
RUN apk update --no-cache && apk add bash grep jq sudo coreutils
ENV BB_TEST_LOCAL_IMAGE=/etc/bluebuild/cli_test.tar.gz
ENV CLICOLOR_FORCE=1
COPY ./mock-scripts/ /usr/bin/
WORKDIR /test
COPY ./test-repo /test
DO +GEN_KEYPAIR
GEN_KEYPAIR:
FUNCTION
# Setup a cosign key pair
RUN echo -n "\n\n" | cosign generate-key-pair
ENV COSIGN_PRIVATE_KEY=$(cat cosign.key)
RUN rm cosign.key
RUN_TESTS:
FUNCTION
FOR script IN $(ls *.sh)
RUN --no-cache chmod +x $script \
&& echo "Running test $script" \
&& ./$script
END