-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathEarthfile
81 lines (65 loc) · 2.02 KB
/
Earthfile
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
VERSION 0.7
# TypeScript build
FROM node:22.13.0
LABEL org.opencontainers.image.source=https://github.com/Kesin11/CIAnalyzer
LABEL [email protected]
WORKDIR /build
all:
BUILD +build
BUILD +test
BUILD +docker
BUILD +schema
deps:
COPY package.json package-lock.json .
RUN --mount=type=cache,target=/root/.npm npm ci
ENV TINI_VERSION v0.19.0
RUN curl -sSL https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini -o /tini
SAVE ARTIFACT /tini
SAVE IMAGE --cache-hint
build:
FROM +deps
COPY --dir src scripts tsconfig.json .
COPY ./proto+protoc/pb_types src/pb_types
RUN npm run build:clean
SAVE ARTIFACT dist AS LOCAL ./dist
SAVE IMAGE --cache-hint
proto:
BUILD ./proto+protoc
COPY ./proto+protoc/pb_types /tmp/pb_types
COPY ./proto+protoc/schema /tmp/schema
SAVE ARTIFACT /tmp/pb_types/* AS LOCAL ./src/pb_types/
SAVE ARTIFACT /tmp/schema/* AS LOCAL ./bigquery_schema/
test:
FROM +deps
COPY --dir src tsconfig.json \
__tests__ vitest.config.ts bigquery_schema ./
COPY ./proto+protoc/pb_types src/pb_types
COPY ./proto+protoc/schema bigquery_schema/
RUN npm run test:ci
SAVE ARTIFACT junit AS LOCAL ./junit
SAVE ARTIFACT coverage AS LOCAL ./coverage
docker:
FROM node:22.13.0-slim
WORKDIR /ci_analyzer
COPY package.json package-lock.json .
COPY README.md LICENSE ci_analyzer.yaml .
COPY ./proto+protoc/schema bigquery_schema/
COPY +build/dist ./dist
COPY --chmod=755 +deps/tini /tini
# Make "ci_analyzer" command alias
RUN cd dist && ln -s index.mjs ci_analyzer && chmod +x ci_analyzer
ENV PATH=/ci_analyzer/dist:$PATH
ENTRYPOINT [ "/tini", "--", "node", "--enable-source-maps", "/ci_analyzer/dist/index.mjs" ]
WORKDIR /app
SAVE IMAGE ghcr.io/kesin11/ci_analyzer:latest
docker-push:
FROM +docker
ARG --required TAGS
FOR TAG IN $TAGS
SAVE IMAGE --push $TAG
END
schema:
FROM +deps
COPY --dir src scripts ./
RUN npx tsx scripts/create_schema.ts schema.json
SAVE ARTIFACT schema.json AS LOCAL ./