-
Notifications
You must be signed in to change notification settings - Fork 19
251 lines (246 loc) · 9.17 KB
/
ci.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: CI
run-name: CI pipeline triggered by @${{ github.actor }}
on:
push:
paths:
- '.github/workflows/**'
- 'setup.py'
- 'setup.cfg'
- 'MANIFEST.in'
- 'pyproject.toml'
- 'eoxserver/**'
- 'autotest/**'
jobs:
build-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the eoxserver docker image
run: |
docker pull eoxa/eoxserver:latest || true
docker build --cache-from eoxa/eoxserver:latest -t eoxserver .
docker save eoxserver | gzip > eoxserver.tar.gz
- name: Save image to cache
uses: actions/cache/save@v3
with:
path: eoxserver.tar.gz
key: eoxserver.tar.gz-${{ github.run_id }}-${{ github.run_number }}
- name: Slack Notify
uses: 8398a7/[email protected]
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
command:
- "-m eoxserver.services.ows.wps.test_data_types"
- "-m eoxserver.services.ows.wps.test_allowed_values"
- "manage.py test --pythonpath=./eoxserver/ eoxserver.core -v2"
- "manage.py test --pythonpath=./eoxserver/ eoxserver.backends -v2"
- "manage.py test --pythonpath=./eoxserver/ eoxserver.services -v2"
- "manage.py test --pythonpath=./eoxserver/ eoxserver.resources.coverages -v2"
- "manage.py test autotest_services --tag wcs20 -v2"
- "manage.py test autotest_services --tag wcs11 -v2"
- "manage.py test autotest_services --tag wcs10 -v2"
- "manage.py test autotest_services --tag wms -v2"
- "manage.py test autotest_services --tag wps -v2"
- "manage.py test autotest_services --tag opensearch -v2"
needs: build-docker
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
id: cache
with:
path: eoxserver.tar.gz
key: eoxserver.tar.gz-${{ github.run_id }}-${{ github.run_number }}
- name: Import docker image and name it autotest
run: |
docker load --input eoxserver.tar.gz
docker tag eoxserver:latest eoxserver:autotest
- name: Start the services and install test dependencies
run: |
echo "DB=spatialite" >> sample.env
docker-compose config
docker-compose up -d
docker-compose ps
docker exec -i eoxserver_autotest_1 pip3 install scipy
- name: Run the tests
env:
COMPOSE_INTERACTIVE_NO_CLI: 1
run: |
docker exec -i eoxserver_autotest_1 python3 ${{ matrix.command }}
- name: Upload logs and outputs of failed tests
uses: 'actions/upload-artifact@v2'
with:
name: logs ${{ matrix.command }}
path: |
autotest/autotest/logs/*.log
autotest/autotest/responses/*
retention-days: 5
if: failure()
- name: Slack Notify
uses: 8398a7/[email protected]
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
publish-docker:
runs-on: ubuntu-latest
needs: test
if: contains(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
id: cache
with:
path: eoxserver.tar.gz
key: eoxserver.tar.gz-${{ github.run_id }}-${{ github.run_number }}
- name: Branch name
id: branch_name
run: |
echo ::set-output name=SOURCE_TAG::$([[ $GITHUB_REF == refs/tags/* ]] && echo ${GITHUB_REF#refs/tags/} || echo "")
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: success()
- name: Import docker image
run: |
docker load --input eoxserver.tar.gz
- name: Tag docker latest image
run: |
docker tag eoxserver eoxa/eoxserver:latest
if: github.ref == 'refs/heads/master'
- name: Tag docker release image
run: |
docker tag eoxserver eoxa/eoxserver:${{ steps.branch_name.outputs.SOURCE_TAG }}
if: steps.branch_name.outputs.SOURCE_TAG
- name: Push docker images
run: |
# TODO: --all-tags does not seem to work with the version on github-actions
# docker push --all-tags eoxa/eoxserver
for tag in $(docker image ls --format "{{.Tag}}" eoxa/eoxserver) ; do docker push "eoxa/eoxserver:$tag" ; done
if: success()
- name: Slack Notify
uses: 8398a7/[email protected]
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
publish-pypi:
runs-on: ubuntu-latest
needs: test
if: contains(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- name: Branch name
id: branch_name
run: |
echo ::set-output name=SOURCE_TAG::$([[ $GITHUB_REF == refs/tags/* ]] && echo ${GITHUB_REF#refs/tags/} || echo "")
- name: Build Python package
id: build_python_release
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
sudo apt-get install -y gdal-bin
python setup.py sdist bdist_wheel
- uses: actions/upload-artifact@v3
with:
name: eoxserver-dist
path: ./dist/
retention-days: 2
- name: Push package to pypi
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
if: success()
- name: Slack Notify
uses: 8398a7/[email protected]
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
publish-github:
runs-on: ubuntu-latest
needs: publish-pypi
if: contains(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
name: eoxserver-dist
- name: Branch name
id: branch_name
run: |
echo ::set-output name=SOURCE_TAG::$([[ $GITHUB_REF == refs/tags/* ]] && echo ${GITHUB_REF#refs/tags/} || echo "")
echo ::set-output name=WHEEL_FILE::$(ls *.whl)
echo ::set-output name=SRC_DIST_FILE::$(ls *.tar.gz)
- name: Draft Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ steps.branch_name.outputs.SOURCE_TAG }}
draft: true
- name: Upload Release Asset Wheel
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.branch_name.outputs.WHEEL_FILE }}
asset_name: ${{ steps.branch_name.outputs.WHEEL_FILE }}
asset_content_type: application/x-wheel+zip
if: success()
- name: Upload Release Asset Source Dist
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{ steps.branch_name.outputs.SRC_DIST_FILE }}
asset_name: ${{ steps.branch_name.outputs.SRC_DIST_FILE }}
asset_content_type: application/tar+gzip
if: success()
- name: Slack Notify
uses: 8398a7/[email protected]
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
notify:
runs-on: ubuntu-20.04
needs: [publish-github, publish-docker]
steps:
- name: Slack Notify
uses: 8398a7/[email protected]
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
custom_payload: |
{
attachments: [{
text: `Publish tag finished`,
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()