forked from earthly/actions-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEarthfile
More file actions
99 lines (85 loc) · 3.09 KB
/
Earthfile
File metadata and controls
99 lines (85 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
VERSION 0.8
ARG EARTHBUILD_LIB_VERSION=3.0.1
IMPORT github.com/EarthBuild/lib/utils/git:$EARTHBUILD_LIB_VERSION AS git
npm-base:
FROM node:24.14.0-alpine3.23@sha256:7fddd9ddeae8196abf4a3ef2de34e11f7b1a722119f91f28ddf1e99dcafdf114
# renovate: datasource=npm packageName=npm
ENV npm_version=11.11.0
RUN npm i -g npm@$npm_version
WORKDIR /code
COPY package.json package-lock.json .
RUN npm ci
code:
FROM +npm-base
COPY --dir src .
COPY tsconfig.json .
lint:
FROM +code
COPY --dir .github .
COPY \
.editorconfig \
.gitignore \
.prettierignore \
action.yml \
Earthfile \
eslint.config.js \
package.json \
README.md \
vite.config.ts \
vitest.config.ts \
.
RUN npm run-script lint
fmt:
LOCALLY
RUN npx prettier --write .
compile:
FROM +code
RUN npm run-script package
SAVE ARTIFACT dist AS LOCAL dist
test-compile-was-run:
FROM alpine:3.23@sha256:25109184c71bdad752c8312a8623239686a9a2071e8825f20acb8f2198c3f659
COPY +compile/dist /from-git
COPY +compile/dist /from-compile
RUN diff -r /from-git /from-compile >/dev/null || (echo "dist and +compile/dist are different, did you forget to run earth +compile?" && exit 1)
test:
FROM +code
COPY vite.config.ts vitest.config.ts .
RUN --secret GITHUB_TOKEN npm test
test-run:
FROM +npm-base
COPY --dir +compile/dist .
ENV RUNNER_TOOL_CACHE=/tmp/cache-dir
RUN node dist/setup/index.js | tee output
RUN ! grep 'Found tool in cache' output
RUN cat output | grep '^::add-path::' | sed 's/::add-path:://g' > earthbuild-path
RUN test "$(cat earthbuild-path)" = "/root/.earth/bin"
# [a-zA-Z0-9]* attempt to match a commit hash
RUN export PATH="$(cat earthbuild-path):$PATH" && earth --version | tee version.output
RUN grep -E '^earth version v.*linux/(arm|amd)64; Alpine Linux' version.output
# validate cache was used
RUN node dist/setup/index.js | tee output2
RUN grep 'Found tool in cache' output2
merge-release-to-major-branch:
FROM alpine/git:v2.52.0@sha256:d453f54c83320412aa89c391b076930bd8569bc1012285e8c68ce2d4435826a3
RUN git config --global user.name "littleredcorvette" && \
git config --global user.email "littleredcorvette@users.noreply.github.com" && \
git config --global url."git@github.com:".insteadOf "https://github.com/"
ARG git_repo="earthbuild/actions-setup"
ARG git_url="git@github.com:$git_repo"
ARG SECRET_PATH=littleredcorvette-id_rsa
DO --pass-args git+DEEP_CLONE --GIT_URL=$git_url --SECRET_PATH=$SECRET_PATH
ARG --required RELEASE_TAG
LET tag=${RELEASE_TAG#refs/tags/}
LET major=$tag
SET major=$(echo ${major%.*})
SET major=$(echo ${major%.*})
RUN --mount=type=secret,id=$SECRET_PATH,mode=0400,target=/root/.ssh/id_rsa \
git checkout $major && git merge --ff-only $tag
RUN --push --mount=type=secret,id=$SECRET_PATH,mode=0400,target=/root/.ssh/id_rsa \
git push origin $major
all:
BUILD +lint
BUILD +compile
BUILD +test
BUILD +test-run
BUILD +test-compile-was-run