-
Notifications
You must be signed in to change notification settings - Fork 7
/
Earthfile
70 lines (53 loc) · 1.93 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
VERSION 0.6
base-python:
FROM python:3.8-slim
ENV PIP_CACHE_DIR /pip-cache
requirements:
FROM +base-python
RUN --mount=type=cache,target=$PIP_CACHE_DIR \
pip install poetry
COPY pyproject.toml poetry.lock .
RUN poetry export -f requirements.txt -E tf -o requirements.txt
RUN poetry export -f requirements.txt -E tf --with dev -o dev-requirements.txt
RUN poetry export -f requirements.txt -E tf --with docs -o docs-requirements.txt
SAVE ARTIFACT requirements.txt /requirements.txt
SAVE ARTIFACT dev-requirements.txt /dev-requirements.txt
SAVE ARTIFACT docs-requirements.txt /docs-requirements.txt
build:
FROM +base-python
WORKDIR /app
COPY +requirements/requirements.txt .
RUN --mount=type=cache,target=$PIP_CACHE_DIR \
pip install -r requirements.txt
COPY tfga tfga
ENV PYTHONPATH /app:$PYTHONPATH
test:
FROM +build
COPY +requirements/dev-requirements.txt .
RUN --mount=type=cache,target=$PIP_CACHE_DIR \
pip install -r dev-requirements.txt
COPY tests tests
RUN pytest tests
publish:
FROM +base-python
ARG --required REPOSITORY
RUN --mount=type=cache,target=$PIP_CACHE_DIR \
pip install poetry
RUN poetry config repositories.pypi https://upload.pypi.org/legacy/
RUN poetry config repositories.testpypi https://test.pypi.org/legacy/
COPY pyproject.toml poetry.lock README.md .
COPY tfga tfga
RUN --mount=type=cache,target=$PIP_CACHE_DIR \
--secret PYPI_TOKEN=+secrets/PYPI_TOKEN \
poetry publish \
--build --skip-existing -r $REPOSITORY \
-u __token__ -p $PYPI_TOKEN
docs:
FROM +build
COPY +requirements/docs-requirements.txt .
RUN --mount=type=cache,target=$PIP_CACHE_DIR \
pip install -r docs-requirements.txt
COPY docs .
RUN sphinx-apidoc -o _build tfga
RUN sphinx-build -M html . _build
SAVE ARTIFACT _build/html /html