-
Notifications
You must be signed in to change notification settings - Fork 4
/
Earthfile
110 lines (95 loc) · 3.17 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
VERSION 0.8
tox:
FROM python:3.12.6-alpine
DO github.com/genestack/earthly-libs+PYTHON_PREPARE
CACHE /root/.cache
COPY requirements-tox.txt tox.ini .
RUN \
--secret NEXUS_USER \
--secret NEXUS_PASSWORD \
pypi-login.sh && \
python3 -m pip install --no-cache-dir -r requirements-tox.txt && \
pypi-clean.sh
SAVE IMAGE --cache-hint
test:
FROM +tox
COPY --dir requirements-internal.txt.envtpl requirements-build.txt requirements-test.txt requirements.txt \
MANIFEST.in README.md LICENSE.txt \
setup.py odm_sdk \
.
ARG --required OPENAPI_VERSION
RUN \
--secret NEXUS_USER \
--secret NEXUS_PASSWORD \
pypi-login.sh && \
cat requirements-internal.txt.envtpl | envsubst > requirements-internal.txt && \
python3 -m tox run-parallel && \
pypi-clean.sh
SAVE IMAGE --cache-hint
build:
FROM +test
ARG --required SDK_VERSION
RUN \
python3 -m pip install --no-cache-dir envsubst && \
cat odm_sdk/version.py.envtpl | envsubst > odm_sdk/version.py && \
python3 setup.py sdist
SAVE IMAGE --cache-hint
push:
FROM +build
RUN \
--secret NEXUS_USER \
--secret NEXUS_PASSWORD \
pypi-login.sh && \
python3 -m pip install --no-cache-dir -r requirements-build.txt && \
pypi-clean.sh
ARG --required SDK_VERSION
IF echo ${SDK_VERSION} | grep -Exq "^([0-9]+(.)?){3}$"
ARG PYPI_REPOSITORY_INTERNAL="nexus-pypi-releases"
ARG PYPI_REPOSITORY_PUBLIC="pypi"
ELSE
ARG PYPI_REPOSITORY_INTERNAL="nexus-pypi-snapshots"
ARG PYPI_REPOSITORY_PUBLIC="testpypi"
END
# Push sdk
RUN --push \
--secret PYPI_TOKEN \
--secret PYPI_TOKEN_TEST \
--secret NEXUS_USER \
--secret NEXUS_PASSWORD \
pypi-login.sh && \
twine upload dist/* -r ${PYPI_REPOSITORY_INTERNAL} && \
twine upload dist/* -r ${PYPI_REPOSITORY_PUBLIC} && \
pypi-clean.sh
docs:
FROM python:3.12.6
DO github.com/genestack/earthly-libs+PYTHON_PREPARE
# Build
COPY --dir docs setup.py odm_sdk .
WORKDIR docs
RUN \
--secret NEXUS_USER \
--secret NEXUS_PASSWORD \
pypi-login.sh && \
python3 -m pip install --no-cache-dir -r requirements.txt && \
make markdown && \
pypi-clean.sh
# Push
WORKDIR build/markdown
ARG --required RAW_REGISTRY_SNAPSHOTS
ARG --required SDK_VERSION
RUN \
--push \
--secret NEXUS_USER \
--secret NEXUS_PASSWORD \
export DOC_ARCHIVE=odm-sdk-${SDK_VERSION}.tar.gz && \
tar cf ${DOC_ARCHIVE} * && \
curl -v --fail --user ${NEXUS_USER}:${NEXUS_PASSWORD} \
-H 'Content-Type: application/gzip' \
--upload-file ${DOC_ARCHIVE} \
${RAW_REGISTRY_SNAPSHOTS}/docs/odm-sdk/${DOC_ARCHIVE}
sonarcloud:
FROM sonarsource/sonar-scanner-cli:5.0.1
DO --pass-args github.com/genestack/earthly-libs+SONARCLOUD_RUN
main:
BUILD +push
BUILD +docs