kairos-agent/Earthfile

75 lines
2.5 KiB
Plaintext
Raw Normal View History

VERSION 0.7
2022-07-07 23:56:51 +00:00
FROM alpine
# renovate: datasource=docker depName=golang
ARG --global GOLINT_VERSION=1.52.2
# renovate: datasource=docker depName=golang
ARG --global GO_VERSION=1.22-bookworm
# renovate: datasource=docker depName=cypress/base
ARG --global CYPRESS_VERSION=18.16.0
2022-07-07 23:56:51 +00:00
go-deps:
ARG GO_VERSION
FROM golang:$GO_VERSION
RUN apt-get update && apt-get install -y rsync gcc bash git
2022-07-07 23:56:51 +00:00
WORKDIR /build
COPY . .
RUN go mod tidy
2022-07-07 23:56:51 +00:00
RUN go mod download
RUN go mod verify
2022-07-07 23:56:51 +00:00
sparkles: custom user bind and ephemeral mounts (#692) * :sparkles: custom user bind and ephemeral mounts Users can now specify custom and ephemeral mounts in cloud-init under the `install` section, e.g.: ``` users: - name: kairos ... install: auto: true device: "auto" bind_mounts: - /mnt/bind1 - /mnt/bind2 ephemeral_mounts: - /mnt/ephemeral - /mnt/ephemeral2 ... ``` Ephemeral mounts are mounted as RW - but changes are discarded when the machine is restart. Bind mounts will persist changes after restarted. This is a fix for #210 Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Add the custom user mount to /cos/run/cos-layout.env Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Add docs for custom user mounts in configuration example Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Reuse test_install function DRY the code, change how we call the function install_test Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Enable custom mount tests and install tests Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Enable tests in CI Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Remove duplicate if check Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Remove uneeded fmt.Println ... Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Use separate label for custom mounts Signed-off-by: Oz Tiram <oz@spectrocloud.com> * 🔧 Earthfile - DRY ginkgo We repeat this a more than twice so just extract to own target... Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Correct return type for ContainElements Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Remove CLOUD_INIT from custom mounts test This is not needed here. Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Fix qemu-test-* earthly targets Signed-off-by: Oz Tiram <oz@spectrocloud.com> * 🔧 Fix CPU passing to VM Signed-off-by: Oz Tiram <oz@spectrocloud.com> * 🔧 remove apt cache after install qemu Helps deal with space running out in the CI. Signed-off-by: Oz Tiram <oz@spectrocloud.com> * :book: Document custom mounts Signed-off-by: Oz Tiram <oz@spectrocloud.com> --------- Signed-off-by: Oz Tiram <oz@spectrocloud.com> Co-authored-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
2023-02-03 10:04:02 +00:00
test:
2023-03-17 15:45:43 +00:00
FROM +go-deps
sparkles: custom user bind and ephemeral mounts (#692) * :sparkles: custom user bind and ephemeral mounts Users can now specify custom and ephemeral mounts in cloud-init under the `install` section, e.g.: ``` users: - name: kairos ... install: auto: true device: "auto" bind_mounts: - /mnt/bind1 - /mnt/bind2 ephemeral_mounts: - /mnt/ephemeral - /mnt/ephemeral2 ... ``` Ephemeral mounts are mounted as RW - but changes are discarded when the machine is restart. Bind mounts will persist changes after restarted. This is a fix for #210 Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Add the custom user mount to /cos/run/cos-layout.env Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Add docs for custom user mounts in configuration example Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Reuse test_install function DRY the code, change how we call the function install_test Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Enable custom mount tests and install tests Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Enable tests in CI Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Remove duplicate if check Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Remove uneeded fmt.Println ... Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Use separate label for custom mounts Signed-off-by: Oz Tiram <oz@spectrocloud.com> * 🔧 Earthfile - DRY ginkgo We repeat this a more than twice so just extract to own target... Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Correct return type for ContainElements Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Remove CLOUD_INIT from custom mounts test This is not needed here. Signed-off-by: Oz Tiram <oz@spectrocloud.com> * Fix qemu-test-* earthly targets Signed-off-by: Oz Tiram <oz@spectrocloud.com> * 🔧 Fix CPU passing to VM Signed-off-by: Oz Tiram <oz@spectrocloud.com> * 🔧 remove apt cache after install qemu Helps deal with space running out in the CI. Signed-off-by: Oz Tiram <oz@spectrocloud.com> * :book: Document custom mounts Signed-off-by: Oz Tiram <oz@spectrocloud.com> --------- Signed-off-by: Oz Tiram <oz@spectrocloud.com> Co-authored-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
2023-02-03 10:04:02 +00:00
WORKDIR /build
ARG TEST_PATHS=./...
ARG LABEL_FILTER=
ENV CGO_ENABLED=1
RUN go run github.com/onsi/ginkgo/v2/ginkgo run --label-filter "$LABEL_FILTER" --covermode=atomic --coverprofile=coverage.out -v --race -r $TEST_PATHS
2022-07-16 13:19:23 +00:00
SAVE ARTIFACT coverage.out AS LOCAL coverage.out
version:
FROM +go-deps
RUN --no-cache echo $(git describe --always --tags --dirty) > VERSION
RUN --no-cache echo $(git describe --always --dirty) > COMMIT
ARG VERSION=$(cat VERSION)
ARG COMMIT=$(cat COMMIT)
SAVE ARTIFACT VERSION VERSION
SAVE ARTIFACT COMMIT COMMIT
build-kairos-agent:
FROM +go-deps
COPY +webui-deps/node_modules ./internal/webui/public/node_modules
2023-07-05 09:42:44 +00:00
COPY github.com/kairos-io/kairos-docs:main+docs/public ./internal/webui/public/local
COPY +version/VERSION ./
COPY +version/COMMIT ./
ARG VERSION=$(cat VERSION)
ARG COMMIT=$(cat COMMIT)
RUN --no-cache echo "Building Version: ${VERSION} and Commit: ${COMMIT}"
2023-07-10 12:39:48 +00:00
ARG LDFLAGS="-s -w -X github.com/kairos-io/kairos-agent/v2/internal/common.VERSION=${VERSION} -X github.com/kairos-io/kairos-agent/v2/internal/common.gitCommit=$COMMIT"
ENV CGO_ENABLED=0
RUN go build -o kairos-agent -ldflags "${LDFLAGS}" main.go
SAVE ARTIFACT kairos-agent kairos-agent AS LOCAL build/kairos-agent
build:
BUILD +build-kairos-agent
2022-07-07 23:56:51 +00:00
golint:
FROM +go-deps
2022-08-08 08:27:41 +00:00
ARG GOLINT_VERSION
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v$GOLINT_VERSION
2022-07-16 14:28:22 +00:00
WORKDIR /build
RUN bin/golangci-lint run
2022-07-16 14:28:22 +00:00
webui-deps:
FROM node:19-alpine
COPY . .
WORKDIR ./internal/webui/public
RUN npm install
SAVE ARTIFACT node_modules /node_modules AS LOCAL internal/webui/public/node_modules
webui-tests:
FROM cypress/base:$CYPRESS_VERSION
COPY +build-kairos-agent/kairos-agent /usr/bin/kairos-agent
COPY . src/
WORKDIR src/
RUN .github/cypress_tests.sh
2023-06-23 12:49:38 +00:00
SAVE ARTIFACT /src/internal/webui/public/cypress/videos videos