11name : CI Build
22
33on :
4+ workflow_dispatch :
5+ inputs :
6+ push-docker-image-to-harbor :
7+ description : ' Push Docker Image to Harbor'
8+ type : boolean
9+ default : false
410 pull_request :
511 push :
612 branches :
1723 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
1824
1925 - name : Setup Node.js
20- uses : actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
26+ uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
2127 with :
2228 node-version : 20
2329 cache : ' yarn'
@@ -34,13 +40,13 @@ jobs:
3440
3541 - name : Upload coverage reports to Codecov
3642 if : success()
37- uses : codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5
43+ uses : codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5
3844 with :
3945 token : ${{ secrets.CODECOV_TOKEN }}
4046
4147 - name : Upload test results to Codecov
4248 if : ${{ !cancelled() }}
43- uses : codecov/test-results-action@4e79e65778be1cecd5df25e14af1eafb6df80ea9 # v1
49+ uses : codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 # v1
4450 with :
4551 token : ${{ secrets.CODECOV_TOKEN }}
4652
5359 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
5460
5561 - name : Setup Node.js
56- uses : actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
62+ uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
5763 with :
5864 node-version : 20
5965 cache : ' yarn'
6773
6874 - name : Upload Cypress screenshots
6975 if : failure()
70- uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
76+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
7177 with :
7278 name : Inventory management system Screenshots
7379 path : cypress/screenshots
@@ -77,31 +83,31 @@ jobs:
7783 runs-on : ubuntu-latest
7884
7985 steps :
80- - name : Clone api repo
81- uses : actions/checkout@cbb722410c2e876e24abbe8de2cc27693e501dcb
86+ - name : Clone IMS api repo
87+ uses : actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
8288 with :
8389 repository : ral-facilities/inventory-management-system-api
8490 ref : develop
8591
8692 - name : Set up Python
87- uses : actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3 .0
93+ uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6 .0
8894 with :
8995 python-version : ' 3.12'
9096
9197 # This is required as need to setup api in a different directory as checkout will attempt delete
9298 # all existing files which in this case will include a data directory created by docker causing
9399 # a permission error (checkout action also can't specify a different directory to clone into)
94- - name : Move api repo
100+ - name : Move IMS api repo
95101 run : |
96102 cd ..
97103 mkdir inventory-management-system-api
98104 mv -v inventory-management-system/* inventory-management-system-api/
99105 cd inventory-management-system-api/
100106
101- - name : Setup MongoDB
107+ - name : Start MongoDB (For inventory-management-system-api)
102108 working-directory : ../inventory-management-system-api
103109 run : |
104- python ./scripts/dev_cli.py --ci db-init --replicaSetMemberHost localhost
110+ docker compose up --detach mongo-db
105111
106112 # Use docker run here to test the actual built image
107113 # Use same network as the MongoDB instance (which is generated by docker compose based on the folder
@@ -121,16 +127,72 @@ jobs:
121127 --env API__ALLOWED_CORS_HEADERS='["*"]' \
122128 --env API__ALLOWED_CORS_ORIGINS='["*"]' \
123129 --env API__ALLOWED_CORS_METHODS='["*"]' \
124- --env OBJECT_STORAGE__ENABLED=false \
130+ --env OBJECT_STORAGE__ENABLED=true \
125131 --env OBJECT_STORAGE__API_REQUEST_TIMEOUT_SECONDS=10 \
126132 --env OBJECT_STORAGE__API_URL=http://localhost:8002 \
127133 harbor.stfc.ac.uk/inventory-management-system/ims-api:develop
128134
135+ - name : Clone Object Storage api repo
136+ uses : actions/checkout@cbb722410c2e876e24abbe8de2cc27693e501dcb
137+ with :
138+ repository : ral-facilities/object-storage-api
139+ ref : develop
140+ path : object-storage-api
141+
142+ - name : Move Object Storage api repo
143+ run : |
144+ cd ..
145+ mkdir object-storage-api
146+ mv -v inventory-management-system/* .
147+ cd object-storage-api/
148+
149+ - name : Start MongoDB and MinIO (For object-storage-api)
150+ working-directory : ../object-storage-api
151+ run : |
152+ docker compose up --detach mongo-db minio
153+ sleep 10
154+
155+ - name : Create MinIO buckets (For object-storage-api)
156+ working-directory : ../object-storage-api
157+ run : |
158+ docker compose up minio-create-buckets
159+
160+ - name : Start object-storage-api
161+ run : |
162+ docker run -d -p 8002:8000 \
163+ --name object_storage_api_container \
164+ --network object-storage-api_default \
165+ --env AUTHENTICATION__ENABLED=false \
166+ --env API__TITLE="Object Storage Service API" \
167+ --env API__DESCRIPTION="This is the API for the Object Storage Service" \
168+ --env DATABASE__PROTOCOL="mongodb" \
169+ --env DATABASE__USERNAME="root" \
170+ --env DATABASE__PASSWORD="example" \
171+ --env DATABASE__HOST_AND_OPTIONS="object-storage-api-mongodb:27017" \
172+ --env DATABASE__NAME="object-storage" \
173+ --env API__ALLOWED_CORS_HEADERS='["*"]' \
174+ --env API__ALLOWED_CORS_ORIGINS='["*"]' \
175+ --env API__ALLOWED_CORS_METHODS='["*"]' \
176+ --env OBJECT_STORAGE__ENDPOINT_URL="http://localhost:9000" \
177+ --env OBJECT_STORAGE__ACCESS_KEY="root" \
178+ --env OBJECT_STORAGE__SECRET_ACCESS_KEY="example_password" \
179+ --env OBJECT_STORAGE__BUCKET_NAME="object-storage" \
180+ --env OBJECT_STORAGE__PRESIGNED_URL_EXPIRY_SECONDS=1800 \
181+ --env ATTACHMENT__MAX_SIZE_BYTES=104857600 \
182+ --env IMAGE__THUMBNAIL_MAX_SIZE_PIXELS=300 \
183+ --env ATTACHMENT__ALLOWED_FILE_EXTENSIONS='[".csv", ".doc", ".docx", ".ods", ".odt", ".rtf", ".pdf", ".txt", ".xls", ".xlsx"]' \
184+ --env ATTACHMENT__UPLOAD_LIMIT=50 \
185+ --env IMAGE__ALLOWED_FILE_EXTENSIONS='[".bmp", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff", ".webp"]' \
186+ --env IMAGE__UPLOAD_LIMIT=100 \
187+ --add-host "localhost:host-gateway" \
188+ -v /home/runner/work/inventory-management-system/object-storage-api/object_storage_api/logging.example.ini:/app/object_storage_api/logging.ini \
189+ harbor.stfc.ac.uk/scd-object-storage-api/object-storage-api:develop
190+
129191 - name : Checkout repo
130192 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
131193
132194 - name : Setup Node.js
133- uses : actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
195+ uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
134196 with :
135197 node-version : 20
136198 cache : ' yarn'
@@ -142,17 +204,29 @@ jobs:
142204 - name : Run e2e tests
143205 run : yarn e2e:api
144206
145- - name : Output docker logs (mongodb)
207+ - name : Output docker logs (ims mongodb)
146208 if : failure()
147209 run : docker logs ims_api_mongodb_container
148210
149- - name : Output docker logs (api)
211+ - name : Output docker logs (ims api)
150212 if : failure()
151213 run : docker logs inventory_management_system_api_container
214+
215+ - name : Output docker logs (object-storage mongodb)
216+ if : failure()
217+ run : docker logs object-storage-api-mongodb
218+
219+ - name : Output docker logs (object-storage minio)
220+ if : failure()
221+ run : docker logs object-storage-minio
222+
223+ - name : Output docker logs (object-storage api)
224+ if : failure()
225+ run : docker logs object_storage_api_container
152226
153227 - name : Upload Cypress screenshots
154228 if : failure()
155- uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
229+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
156230 with :
157231 name : Inventory management system (with api) Screenshots
158232 path : cypress/screenshots
@@ -167,7 +241,7 @@ jobs:
167241 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
168242
169243 - name : Setup Node.js
170- uses : actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
244+ uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
171245 with :
172246 node-version : 20
173247 cache : ' yarn'
@@ -187,28 +261,30 @@ jobs:
187261 needs : [lint-and-unit-test, e2e-tests, e2e-tests-api]
188262 name : Docker
189263 runs-on : ubuntu-latest
264+ env :
265+ PUSH_DOCKER_IMAGE_TO_HARBOR : ${{ inputs.push-docker-image-to-harbor != null && inputs.push-docker-image-to-harbor || 'false' }}
190266 steps :
191267 - name : Check out repo
192268 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
193269
194270 - name : Login to Harbor
195- uses : docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3 .0
271+ uses : docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4 .0
196272 with :
197273 registry : ${{ secrets.HARBOR_URL }}
198274 username : ${{ secrets.HARBOR_USERNAME }}
199275 password : ${{ secrets.HARBOR_TOKEN }}
200276
201277 - name : Extract metadata (tags, labels) for Docker
202278 id : meta
203- uses : docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
279+ uses : docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
204280 with :
205281 images : ${{ secrets.HARBOR_URL }}/ims
206282
207- - name : Build and push Docker image to Harbor
208- uses : docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11 .0
283+ - name : ${{ fromJSON(env.PUSH_DOCKER_IMAGE_TO_HARBOR) && ' Build and push Docker image to Harbor' || 'Build Docker image' }}
284+ uses : docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6.16 .0
209285 with :
210286 context : .
211287 file : ./Dockerfile.prod
212- push : true
288+ push : ${{ fromJSON(env.PUSH_DOCKER_IMAGE_TO_HARBOR) }}
213289 tags : ${{ steps.meta.outputs.tags }}
214290 labels : ${{ steps.meta.outputs.labels }}
0 commit comments