-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEarthfile
67 lines (50 loc) · 1.73 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
VERSION 0.6
base-python:
FROM python:3.8
# Install Poetry
ENV PIP_CACHE_DIR /pip-cache
RUN --mount=type=cache,target=$PIP_CACHE_DIR \
pip install poetry==1.6.1
RUN --mount=type=cache,target=$PIP_CACHE_DIR \
poetry config virtualenvs.create false
# Install graphviz which the tests use
RUN apt-get update && apt-get install -y graphviz && apt-get clean
build:
FROM +base-python
WORKDIR /app
# Copy poetry files
COPY pyproject.toml poetry.lock README.md .
# We only want to install the dependencies once, so if we copied
# our code here now, we'd reinstall the dependencies ever ytime
# the code changes. Instead, comment out the line making us depend
# on our code, install, then copy our code and install again
# with the line not commented.
RUN sed -e '/packages/ s/^#*/#/' -i pyproject.toml
# Install dependencies
RUN poetry install
# Copy without the commented out packages line and install again
COPY --dir egga .
COPY pyproject.toml .
RUN poetry install
test:
FROM +build
# Run tests
COPY --dir tests .
RUN poetry run pytest -n auto
test-examples:
FROM +build
# Run examples
COPY --dir examples .
FOR example IN $(ls examples/*.py)
RUN poetry run python "$example"
END
publish:
FROM +build
ARG --required REPOSITORY
RUN poetry config repositories.pypi https://upload.pypi.org/legacy/
RUN poetry config repositories.testpypi https://test.pypi.org/legacy/
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