-
Notifications
You must be signed in to change notification settings - Fork 178
182 lines (160 loc) · 4.79 KB
/
main.yml
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: build
on:
pull_request:
paths:
- '**'
push:
paths:
- '**'
- '!docs/**'
- '!contrib/**'
workflow_dispatch:
env:
DOCKER_USER: gadockersvc
DOCKER_IMAGE: opendatacube/datacube-tests:latest1.9
# NB Restore standard image name when merge into develop
# DOCKER_IMAGE: opendatacube/datacube-tests:latest
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Config
id: cfg
run: |
push_test_pypi=no
push_pypi=no
if [[ "${GITHUB_REF}" =~ refs/tags/.* ]]; then
echo "push_test_pypi=yes" >> $GITHUB_OUTPUT
echo "push_pypi=yes" >> $GITHUB_OUTPUT
fi
- uses: dorny/paths-filter@v3
id: changes
if: |
github.event_name == 'push'
with:
filters: |
docker:
- 'docker/**'
- name: Pull Docker
if: steps.changes.outputs.docker == 'false'
run: |
docker pull "${{ env.DOCKER_IMAGE }}"
- name: Set up Docker Buildx
if: steps.changes.outputs.docker == 'true'
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
if: steps.changes.outputs.docker == 'true'
uses: pat-s/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: DockerHub Login
id: login
if: |
github.event_name == 'push'
&& github.ref == 'refs/heads/develop'
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USER }}
password: ${{ secrets.GADOCKERSVC_PASSWORD }}
- name: Build Docker
uses: docker/build-push-action@v6
with:
file: docker/Dockerfile
context: .
tags: ${{ env.DOCKER_IMAGE }}
load: true
- name: Verify and Run Tests
run: |
echo "Verify that twine is installed"
docker run --rm ${{ env.DOCKER_IMAGE }} twine --version
echo "Run tests"
cat <<EOF | docker run --rm -i -v $(pwd):/code ${{ env.DOCKER_IMAGE }} bash -
pip install -e /code/tests/drivers/fail_drivers --no-deps
pip install -e /code/examples/io_plugin --no-deps
pytest -r a \
--cov datacube \
--cov-report=xml \
--doctest-ignore-import-errors \
--durations=5 \
datacube \
tests \
integration_tests
EOF
- name: DockerHub Push
if: |
github.event_name == 'push'
&& github.ref == 'refs/heads/develop'
&& steps.changes.outputs.docker == 'true'
uses: docker/build-push-action@v6
with:
file: docker/Dockerfile
context: .
push: true
tags: ${{env.DOCKER_IMAGE}}
- name: Build Packages
run: |
cat <<EOF | docker run --rm -i \
-v $(pwd):/code \
-e SKIP_DB=yes \
${{ env.DOCKER_IMAGE }} bash -
python setup.py bdist_wheel sdist
ls -lh ./dist/
twine check ./dist/*
EOF
- name: Publish to Test PyPi
if: |
steps.cfg.outputs.push_test_pypi == 'yes'
run: |
if [ -n "${TWINE_PASSWORD}" ]; then
docker run --rm \
-v $(pwd):/code \
-e SKIP_DB=yes \
${{ env.DOCKER_IMAGE }} \
twine upload \
--verbose \
--non-interactive \
--disable-progress-bar \
--username=__token__ \
--password=${TWINE_PASSWORD} \
--repository-url=${TWINE_REPOSITORY_URL} \
--skip-existing dist/* || true
else
echo "Skipping upload as 'TestPyPiToken' is not set"
fi
env:
TWINE_PASSWORD: ${{ secrets.TestPyPiToken }}
TWINE_REPOSITORY_URL: 'https://test.pypi.org/legacy/'
- name: Publish to PyPi
if: |
github.event_name == 'push'
&& steps.cfg.outputs.push_pypi == 'yes'
run: |
if [ -n "${TWINE_PASSWORD}" ]; then
docker run --rm \
-v $(pwd):/code \
-e SKIP_DB=yes \
${{ env.DOCKER_IMAGE }} \
twine upload \
--verbose \
--non-interactive \
--disable-progress-bar \
--username=__token__ \
--password=${TWINE_PASSWORD} \
--skip-existing dist/*
else
echo "Skipping upload as 'PyPiToken' is not set"
fi
env:
TWINE_PASSWORD: ${{ secrets.PyPiToken }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}