-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathEarthfile
More file actions
99 lines (86 loc) · 3.04 KB
/
Earthfile
File metadata and controls
99 lines (86 loc) · 3.04 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
IMPORT github.com/Konubinix/Earthfile AS e
pre-commit-base:
# ruamel does not provide wheels that work for alpine. Therefore we use debian here
FROM e+debian-python-user-venv --extra_packages="git" --packages="pre-commit"
export-pre-commit-update:
FROM +pre-commit-base
RUN git init
COPY --dir .pre-commit-config.yaml .
RUN --no-cache pre-commit autoupdate
SAVE ARTIFACT .pre-commit-config.yaml AS LOCAL .pre-commit-config.yaml
pre-commit-cache:
FROM +pre-commit-base
RUN git init
COPY --dir .pre-commit-config.yaml .
RUN pre-commit run -a
SAVE ARTIFACT ${HOME}/.cache/pre-commit cache
quality-base:
FROM +pre-commit-base
COPY --dir .pre-commit-config.yaml .
COPY +pre-commit-cache/cache $HOME/.cache/pre-commit
COPY . .
check-quality:
FROM +quality-base
RUN pre-commit run -a
fix-quality:
FROM +quality-base
RUN pre-commit run -a || echo OK
SAVE ARTIFACT . AS LOCAL fixed
test-base:
FROM earthly/dind:ubuntu-24.04-docker-27.3.1-1
ARG shell=bash
ARG extra_packages=""
RUN apt-get update && apt-get install --yes git wget python3-venv coreutils httpie ${extra_packages}
DO e+USE_USER --uid=1001
ARG from=source
WORKDIR /app
RUN python3 -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
RUN mkdir -p /home/sam/.local/bin/
ENV PATH="/home/sam/.local/bin/:$PATH"
IF [ "${from}" = "source" ]
RUN wget -O - https://clk-project.org/install.sh | ${shell}
COPY --dir bin python tilt-extensions clk.json version.txt /k8s/
RUN clk extension install /k8s
ELSE
RUN wget -O - https://clk-project.org/install.sh | env CLK_EXTENSIONS=k8s ${shell}
END
ARG distribution=kind
ARG dependencies="kind kubectl"
FOR dependency IN ${dependencies}
RUN clk k8s --distribution=$distribution install-dependency ${dependency}
END
RUN clk parameter set k8s.create-cluster --use-public-dns # needed to workaround image pull issues in mac->colima->docker->earthlybuildkit->docker->kind
RUN_TEST:
FUNCTION
ARG args # could be --debug
USER root
ARG distribution=kind
ARG from=source
ARG base="flow minimal --flow-from k8s.create-cluster"
ARG directfail=no
WITH DOCKER
RUN --no-cache clk --flow-verbose ${args} k8s --distribution=$distribution ${base} && bash test.sh
END
SAVE ARTIFACT --if-exists /tmp/out AS LOCAL out/${distribution}-${from}
test:
ARG distribution=kind
ARG from=source
FROM +test-base --distribution=$distribution --from=$from --dependencies="all"
COPY hello hello
COPY test.sh ./test.sh
ARG directfail=no
WAIT
DO +RUN_TEST --distribution=$distribution --from=$from --directfail="${directfail}"
END
RUN ! test -e /tmp/out/fail # make the target fail if the tests failed
test-all:
BUILD +check-quality
BUILD +test --distribution=kind
test-all-amd64:
BUILD --platform linux/amd64 +test-all
test-all-arm64:
BUILD --platform linux/arm64 +test-all
test-interactive:
BUILD +test --directfail=yes