-
Notifications
You must be signed in to change notification settings - Fork 3
141 lines (132 loc) · 3.93 KB
/
test-and-build.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
name: Test & Build Images
on:
push:
branches: [master]
pull_request_target:
branches: [master]
env:
REGISTRY: registry.cern.ch
IMAGE_UI: cern-sis/cat-ui
IMAGE_BACKEND: cern-sis/cat-backend
IMAGE_HARVEST: cern-sis/cat-harvest
jobs:
backend_build_test:
name: Backend Build and Test
runs-on: ubuntu-latest
outputs:
image_backend: ${{ steps.build.outputs.image-digest }}
defaults:
run:
working-directory: backend
strategy:
matrix:
python-version: [3.9]
services:
elasticsearch:
image: elasticsearch:7.10.1
env:
bootstrap.memory_lock: true
ES_JAVA_OPTS: -Xms1024m -Xmx1024m
discovery.type: single-node
ports:
- 9200:9200
postgresql:
image: postgres:9.6
env:
POSTGRES_USER: cat
POSTGRES_PASSWORD: cat
POSTGRES_DB: cat
ports:
- 5432:5432
steps:
- name: Checkout
uses: actions/checkout@v2
with:
python-version: ${{ matrix.python-version }}
- name: Build Image
id: build
uses: cern-sis/gh-workflows/.github/actions/docker-build@v6
with:
registry: ${{ env.REGISTRY }}
image: ${{ env.IMAGE_BACKEND }}
cache: false
context: ./backend/
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_PASSWORD }}
- name: Run tests
run: >
docker run
--network=host
--name=cat-backend
$REGISTRY/$IMAGE_BACKEND@${{ steps.build.outputs.image-digest }}
python manage.py test
ui_build_test:
name: UI Build and Test
runs-on: ubuntu-latest
outputs:
image_ui: ${{ steps.build.outputs.image-digest }}
defaults:
run:
working-directory: ui
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build Image
id: build
uses: cern-sis/gh-workflows/.github/actions/docker-build@v6
with:
registry: ${{ env.REGISTRY }}
image: ${{ env.IMAGE_UI }}
cache: false
context: ./ui/
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_PASSWORD }}
harvest_build_test:
name: Harvest Build and Test
runs-on: ubuntu-latest
outputs:
image_harvest: ${{ steps.build.outputs.image-digest }}
defaults:
run:
working-directory: harvest
strategy:
matrix:
python-version: [3.9]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
python-version: ${{ matrix.python-version }}
- name: Build Image
id: build
uses: cern-sis/gh-workflows/.github/actions/docker-build@v6
with:
registry: ${{ env.REGISTRY }}
image: ${{ env.IMAGE_HARVEST }}
cache: false
context: ./harvest/
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_PASSWORD }}
- name: Run tests
run: >
docker run
--network=host
--name=cat-harvest
--entrypoint poetry
$REGISTRY/$IMAGE_HARVEST@${{ steps.build.outputs.image-digest }}
run pytest tests
push_to_QA:
name: Push to QA
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: [backend_build_test, ui_build_test, harvest_build_test]
steps:
- name: send event
uses: cern-sis/gh-workflows/.github/actions/kubernetes-project-new-images@v6
with:
event-type: update
images: |
$REGISTRY/$IMAGE_BACKEND:${{needs.backend_build_test.outputs.image_backend}}
$REGISTRY/$IMAGE_UI:${{needs.ui_build_test.outputs.image_ui}}
$REGISTRY/$IMAGE_HARVEST:${{needs.harvest_build_test.outputs.image_harvest}}
token: ${{ secrets.PAT_FIRE_EVENTS_ON_CERN_SIS_KUBERNETES }}