-
Notifications
You must be signed in to change notification settings - Fork 12
171 lines (145 loc) · 5.28 KB
/
ows-config-test-build.yaml
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
name: OWS CFG Lint, Test and Build
on:
push:
branches: [ master ]
paths:
- 'services/**'
- .github/workflows/ows-config-test-build.yaml
pull_request:
paths:
- 'services/**'
- .github/workflows/ows-config-test-build.yaml
release:
types: [created, edited, published]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v5
with:
python-version: 3.10.12
- name: flake8 Lint
uses: py-actions/flake8@v2
with:
ignore: E501
path: services/ows_refactored
test:
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout code
uses: actions/checkout@v1
with:
fetch-depth: 0
- name: Prepare the DB
run: |
echo "Starting up the DB"
docker compose -f docker-compose.ows.yaml up --detach postgres
echo "Initialising the DB"
docker compose -f docker-compose.ows.yaml run -T ows datacube system init
echo "Initialising OWS"
docker compose -f docker-compose.ows.yaml run -T ows datacube-ows-update --schema --role postgres
echo "Starting OWS"
docker compose -f docker-compose.ows.yaml up --detach ows
- name: Log error from previous steps
if: failure()
run: |
docker compose -f docker-compose.ows.yaml logs ows
- name: Test DEV config
run: |
docker compose -f docker-compose.ows.yaml run \
-e DATACUBE_OWS_CFG=ows_refactored.dev_af_ows_root_cfg.ows_cfg \
-T ows \
datacube-ows-cfg check -i /env/config/inventory/dev_af/inventory.json
- name: Test PROD config
run: |
docker compose -f docker-compose.ows.yaml run \
-e DATACUBE_OWS_CFG=ows_refactored.prod_af_ows_root_cfg.ows_cfg \
-T ows \
datacube-ows-cfg check -i /env/config/inventory/prod_af/inventory.json
- name: Remove the DB
run: |
docker compose -f docker-compose.ows.yaml down
upload-translation:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v5
with:
python-version: 3.10.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poeditor
mkdir output
- name: Prepare the DB
run: |
echo "Starting up the DB"
docker compose -f docker-compose.ows.yaml up --detach postgres
echo "Initialising the DB"
docker compose -f docker-compose.ows.yaml run -T ows datacube system init
echo "Initialising OWS"
docker compose -f docker-compose.ows.yaml run -T ows datacube-ows-update --schema --role postgres
echo "Starting OWS"
docker compose -f docker-compose.ows.yaml up --detach ows
- name: Generate English Terms translation file
run: |
docker compose -f docker-compose.ows.yaml exec \
-e DATACUBE_OWS_CFG=ows_refactored.prod_af_ows_root_cfg.ows_cfg \
-T ows \
datacube-ows-cfg extract -m /env/config/output/messages.po
- name: Copy messages.po from Docker container to host
run: |
docker cp $(docker compose -f docker-compose.ows.yaml ps -q ows):/env/config/output/messages.po ./output/messages.po
- name: Set file permissions for messages.po
run: |
sudo chmod 644 ./output/messages.po
- name: Upload terms to POEditor.com
if: github.ref == 'refs/heads/master' || github.event_name == 'release' || github.event_name == 'pull_request'
env:
POEDITOR_API_TOKEN: ${{ secrets.POEDITOR_API_TOKEN }}
POEDITOR_PROJECT_ID: "747296"
run: |
python .github/workflows/scripts/upload-po.py
- name: Remove the DB
run: |
docker compose -f docker-compose.ows.yaml down
build-and-push:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poeditor
- name: Download translation from POEditor.com
env:
POEDITOR_API_TOKEN: ${{ secrets.POEDITOR_API_TOKEN }}
POEDITOR_PROJECT_ID: "747296"
run: |
python .github/workflows/scripts/download-mo.py
- name: Push to DockerHub (master branch or tagged release only)
if: github.ref == 'refs/heads/master' || github.event_name == 'release'
env:
DOCKER_USER: deafricadockersvs
run: |
echo "Login to DockerHub as ${DOCKER_USER}"
echo "${{ secrets.DEAFRICA_DOCKER_PASSWORD }}" | docker login -u "${DOCKER_USER}" --password-stdin
# figure out extra tag
git fetch --prune --unshallow 2> /dev/null || true
tag=$(git describe --tags)
DOCKER_IMAGE=digitalearthafrica/deafrica-config
# build local docker image
docker build -t ${DOCKER_IMAGE}:latest .
# tag and push images
docker tag ${DOCKER_IMAGE}:latest ${DOCKER_IMAGE}:${tag}
docker push ${DOCKER_IMAGE}:latest
docker push ${DOCKER_IMAGE}:${tag}