From 73074ca48d50e5d4ddd3edec226c456c9a8098e0 Mon Sep 17 00:00:00 2001 From: benbooth493 Date: Tue, 12 Nov 2024 14:24:06 +0000 Subject: [PATCH] Earthfile and blueprint.cue --- tools/github-job-checker/Earthfile | 69 ++++++++++++++++++++++++++ tools/github-job-checker/blueprint.cue | 31 ++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 tools/github-job-checker/Earthfile create mode 100644 tools/github-job-checker/blueprint.cue diff --git a/tools/github-job-checker/Earthfile b/tools/github-job-checker/Earthfile new file mode 100644 index 0000000..43722c1 --- /dev/null +++ b/tools/github-job-checker/Earthfile @@ -0,0 +1,69 @@ +VERSION 0.8 + +deps: + FROM golang:1.23.0-alpine3.19 + + WORKDIR /work + + RUN apk add git file + + RUN mkdir -p /go/cache && mkdir -p /go/modcache + ENV GOCACHE=/go/cache + ENV GOMODCACHE=/go/modcache + CACHE --persist --sharing shared /go + + COPY ../lib/project+src/src /lib/project + COPY ../lib/tools+src/src /lib/tools + + COPY go.mod go.sum . + RUN go mod download + +src: + FROM +deps + + CACHE --persist --sharing shared /go + + COPY . . + RUN go generate ./... + +check: + FROM +src + + RUN gofmt -l . | grep . && exit 1 || exit 0 + RUN go vet ./... + +build: + FROM +src + + ARG GOOS + ARG GOARCH + ARG version="0.0.0" + + ENV CGO_ENABLED=0 + RUN go build -ldflags="-extldflags=-static -X main.version=$version" -o bin/gh-job-checker main.go + RUN file bin/gh-job-checker + + SAVE ARTIFACT bin/gh-job-checker gh-job-checker + +test: + FROM +build + + RUN go test ./... + +github: + FROM scratch + + ARG version="dev" + + ARG TARGETOS + ARG TARGETARCH + ARG USERPLATFORM + + COPY \ + --platform=$USERPLATFORM \ + (+build/forge \ + --GOOS=$TARGETOS \ + --GOARCH=$TARGETARCH \ + --version=$version) bin/gh-job-checker + + SAVE ARTIFACT bin/gh-job-checker gh-job-checker diff --git a/tools/github-job-checker/blueprint.cue b/tools/github-job-checker/blueprint.cue new file mode 100644 index 0000000..9cbcdbc --- /dev/null +++ b/tools/github-job-checker/blueprint.cue @@ -0,0 +1,31 @@ +version: "1.0" +project: { + name: "gh-job-checker" + ci: targets: { + github: { + args: { + version: string | *"dev" @forge(name="GIT_TAG") + } + platforms: [ + "linux/amd64", + "linux/arm64", + "darwin/amd64", + "darwin/arm64", + ] + } + test: retries: 3 + } + release: { + github: { + on: tag: {} + config: { + name: string | *"dev" @forge(name="GIT_TAG") + prefix: project.name + token: { + provider: "env" + path: "GITHUB_TOKEN" + } + } + } + } +}