-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (140 loc) · 4.98 KB
/
ci-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
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
name: CI Build
on:
pull_request:
push:
branches:
- main
- develop
jobs:
lint-and-unit-test:
name: Lint & Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: 20
cache: 'yarn'
- name: Install dependencies
run: |
sudo apt-get install libgconf-2-4
yarn --immutable
- name: Run linting
run: yarn lint
- name: Run unit tests
run: yarn test
- name: Upload coverage reports to Codecov
if: success()
uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
e2e-tests:
name: End-to-End (with mock data) Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: 20
cache: 'yarn'
- name: Install dependencies
run: |
sudo apt-get install libgconf-2-4
yarn --immutable
- name: Run e2e tests
run: yarn e2e
- name: Upload Cypress screenshots
if: failure()
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4
with:
name: Inventory management system Screenshots
path: cypress/screenshots
e2e-tests-api:
name: End-to-End (with api) Tests
runs-on: ubuntu-latest
services:
ims-api:
image: harbor.stfc.ac.uk/inventory-management-system/ims-api:develop
ports:
- 8000:8000
env:
AUTHENTICATION__ENABLED: false
API__TITLE: Inventory Management System API
API__DESCRIPTION: This is the API for the Inventory Management System
API__ROOT_PATH: /inventory-management-system-api
DATABASE__PROTOCOL: mongodb
DATABASE__USERNAME: root
DATABASE__PASSWORD: example
DATABASE__HOSTNAME: mongodb
DATABASE__PORT: 27017
DATABASE__NAME: ims
API__ALLOWED_CORS_HEADERS: '["*"]'
API__ALLOWED_CORS_ORIGINS: '["*"]'
API__ALLOWED_CORS_METHODS: '["*"]'
options: --name inventory-management-system-api
steps:
- name: Clone api repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
repository: ral-facilities/inventory-management-system-api
ref: add-common-dev-task-script-#235
- name: Set up Python
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: '3.12'
cache: 'pip'
- name: Setup MongoDB
run: |
python ./scripts/dev_cli.py db-init --replicaSetMemberHost localhost
python ./scripts/dev_cli.py db-import
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: 20
cache: 'yarn'
- name: Install dependencies
run: |
sudo apt-get install libgconf-2-4
yarn --immutable
- name: Run e2e tests
run: yarn e2e:api
- name: Upload Cypress screenshots
if: failure()
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4
with:
name: Inventory management system (with api) Screenshots
path: cypress/screenshots
docker:
# This job triggers only if all the other jobs succeed. It builds the Docker image and if successful,
# it pushes it to Harbor.
needs: [lint-and-unit-test, e2e-tests, e2e-tests-api]
name: Docker
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Login to Harbor
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
registry: ${{ secrets.HARBOR_URL }}
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@dbef88086f6cef02e264edb7dbf63250c17cef6c # v5.5.0
with:
images: ${{ secrets.HARBOR_URL }}/ims
- name: Build and push Docker image to Harbor
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
context: .
file: ./Dockerfile.prod
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}