From 96d9f402a1aa50c8b01059a2b222d32ec9572c1d Mon Sep 17 00:00:00 2001 From: Itxaka Date: Mon, 15 Jan 2024 13:54:38 +0100 Subject: [PATCH] reuse same base image across all targets (#202) --- .github/cypress_tests.sh | 2 +- .github/workflows/unit-tests.yml | 2 +- .github/workflows/webui.yaml | 2 +- Earthfile | 15 ++++++--------- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/cypress_tests.sh b/.github/cypress_tests.sh index 4b05ebe2..fa75dab3 100755 --- a/.github/cypress_tests.sh +++ b/.github/cypress_tests.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -ex # Run agent in the background to bring the webui up /usr/bin/kairos-agent webui & diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 78ebe00f..d4692f8e 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: # Match this version to the maintained FIPS version in packages at https://github.com/kairos-io/packages/blob/main/packages/toolchain-go/collection.yaml#L63 - go-version: ["1.19.10-alpine3.18", "1.20-alpine3.18", "1.21-alpine3.18"] + go-version: ["1.19.10-bookworm", "1.20-bookworm", "1.21-bookworm"] runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/.github/workflows/webui.yaml b/.github/workflows/webui.yaml index 9714b54f..27f7a220 100644 --- a/.github/workflows/webui.yaml +++ b/.github/workflows/webui.yaml @@ -13,7 +13,7 @@ jobs: strategy: matrix: # Match this version to the maintained FIPS version in packages at https://github.com/kairos-io/packages/blob/main/packages/toolchain-go/collection.yaml#L63 - go-version: [ "1.19.10-alpine3.18", "1.20-alpine3.18", "1.21-alpine3.18" ] + go-version: [ "1.19.10-bookworm", "1.20-bookworm", "1.21-bookworm" ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/Earthfile b/Earthfile index 22f37c4d..1483f88b 100644 --- a/Earthfile +++ b/Earthfile @@ -3,13 +3,14 @@ FROM alpine # renovate: datasource=docker depName=golang ARG --global GOLINT_VERSION=1.52.2 # renovate: datasource=docker depName=golang -ARG --global GO_VERSION=1.20-alpine3.17 +ARG --global GO_VERSION=1.20-bookworm # renovate: datasource=docker depName=cypress/base ARG --global CYPRESS_VERSION=18.16.0 go-deps: ARG GO_VERSION FROM golang:$GO_VERSION + RUN apt-get update && apt-get install -y rsync gcc bash git WORKDIR /build COPY go.mod go.sum ./ RUN go mod download @@ -18,7 +19,6 @@ go-deps: test: FROM +go-deps - RUN apk add rsync gcc musl-dev bash WORKDIR /build COPY . . ARG TEST_PATHS=./... @@ -28,8 +28,7 @@ test: SAVE ARTIFACT coverage.out AS LOCAL coverage.out version: - FROM alpine - RUN apk add git + FROM +go-deps COPY . ./ RUN --no-cache echo $(git describe --always --tags --dirty) > VERSION RUN --no-cache echo $(git describe --always --dirty) > COMMIT @@ -40,7 +39,6 @@ version: build-kairos-agent: FROM +go-deps - RUN apk add upx COPY . . COPY +webui-deps/node_modules ./internal/webui/public/node_modules COPY github.com/kairos-io/kairos-docs:main+docs/public ./internal/webui/public/local @@ -50,16 +48,15 @@ build-kairos-agent: ARG COMMIT=$(cat COMMIT) RUN --no-cache echo "Building Version: ${VERSION} and Commit: ${COMMIT}" 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=${CGO_ENABLED} - RUN go build -o kairos-agent -ldflags "${LDFLAGS}" main.go && upx kairos-agent + 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 golint: - ARG GO_VERSION - FROM golang:$GO_VERSION + FROM +go-deps ARG GOLINT_VERSION RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v$GOLINT_VERSION WORKDIR /build