Skip to content

Commit 6c3f2a1

Browse files
committed
feat: initial snapshot testing
1 parent c8c557e commit 6c3f2a1

3 files changed

Lines changed: 74 additions & 15 deletions

File tree

.github/workflows/cicd-1-pull-request.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ jobs:
128128
if: needs.metadata.outputs.does_pull_request_exist == 'true' || github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened'))
129129
with:
130130
docker_compose_file: application/CohortManager/compose.yaml
131+
snapshot_test_dir: tests/snapshot-tests
131132
excluded_containers_csv_list: azurite,azurite-setup,sql-server
132133
environment_tag: ${{ needs.metadata.outputs.environment_tag }}
133134
function_app_source_code_path: application/CohortManager/src

.github/workflows/stage-2-test.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -218,24 +218,24 @@ jobs:
218218
with:
219219
submodules: true
220220

221-
- name: Run dependencies
222-
working-directory: ${{ env.APP_DIR }}
223-
run: |
224-
docker compose -f compose.deps.yaml up -d
225-
sleep 20
221+
# - name: Run dependencies
222+
# working-directory: ${{ env.APP_DIR }}
223+
# run: |
224+
# docker compose -f compose.deps.yaml up -d
225+
# sleep 20
226226

227-
- name: Run application
228-
working-directory: ${{ env.APP_DIR }}
229-
run: |
230-
docker compose up -d
231-
sleep 20
227+
# - name: Run application
228+
# working-directory: ${{ env.APP_DIR }}
229+
# run: |
230+
# docker compose up -d
231+
# sleep 20
232232

233-
- name: Run snapshot tests
234-
run: ./tests/snapshot-tests/run-snapshot-tests.sh
233+
# - name: Run snapshot tests
234+
# run: ./tests/snapshot-tests/run-snapshot-tests.sh
235235

236-
- name: teardown application
237-
working-directory: ${{ env.APP_DIR }}
238-
run: docker compose down && docker compose -f compose.deps.yaml down
236+
# - name: teardown application
237+
# working-directory: ${{ env.APP_DIR }}
238+
# run: docker compose down && docker compose -f compose.deps.yaml down
239239

240240
aggregate-test-results:
241241
name: Aggregate results and report

.github/workflows/stage-3-build-images.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ on:
2929
required: false
3030
type: boolean
3131
default: false
32+
snapshot_test_dir:
33+
description: Directory containing the snapshot tests
34+
required: true
35+
type: string
3236

3337
jobs:
3438
get-functions:
@@ -236,12 +240,21 @@ jobs:
236240
} | tee -a "$VULNERABILITIES_SUMMARY_LOGFILE"
237241
done
238242
243+
docker save "${repo_name}:${COMMIT_HASH_TAG}" -o "${repo_name}:${COMMIT_HASH_TAG}".tar
244+
239245
# Remove the image
240246
docker rmi "${repo_name}:${COMMIT_HASH_TAG}"
241247
docker rmi "${repo_name}:${PR_NUM_TAG}"
242248
docker rmi "${repo_name}:${ENVIRONMENT_TAG}"
243249
docker rmi ${PROJECT_NAME}-${function}:latest
244250
251+
- name: Upload docker image as an artifact
252+
working-directory: ${{ steps.get-function-names.outputs.DOCKER_COMPOSE_DIR }}
253+
uses: actions/upload-artifact@v4
254+
with:
255+
name: docker-images
256+
path: "*.tar"
257+
245258
- name: Compress SBOM report
246259
shell: bash
247260
run: |
@@ -275,6 +288,51 @@ jobs:
275288
path: ./${{ env.VULNERABILITIES_SUMMARY_LOGFILE }}
276289
retention-days: 21
277290

291+
snapshot-tests:
292+
name: Snapshot tests
293+
runs-on: ubuntu-latest
294+
env:
295+
SNAPSHOT_TEST_DIR: ${{ inputs.snapshot_test_dir }}
296+
APP_DIR: ${{ steps.get-function-names.outputs.DOCKER_COMPOSE_DIR }}
297+
steps:
298+
- name: Checkout code
299+
uses: actions/checkout@v4
300+
with:
301+
submodules: true
302+
303+
- name: Download Docker images artifact
304+
uses: actions/download-artifact@v4
305+
with:
306+
name: docker-images
307+
path: ${{ env.APP_DIR }}
308+
309+
- name: Load Docker images
310+
working-directory: ${{ env.APP_DIR }}
311+
run: |
312+
for tar in ${{ env.APP_DIR }}/*.tar; do
313+
docker load -i $tar
314+
done
315+
316+
- name: Run dependencies
317+
working-directory: ${{ env.APP_DIR }}
318+
run: |
319+
docker compose -f compose.deps.yaml up -d
320+
sleep 20
321+
322+
- name: Run application
323+
working-directory: ${{ env.APP_DIR }}
324+
run: |
325+
docker compose up -d
326+
sleep 20
327+
328+
- name: Run snapshot tests
329+
run: ./tests/snapshot-tests/run-snapshot-tests.sh
330+
331+
- name: teardown application
332+
working-directory: ${{ env.APP_DIR }}
333+
run: docker compose down && docker compose -f compose.deps.yaml down
334+
335+
278336
aggregate-json:
279337
runs-on: ubuntu-latest
280338
needs: build-and-push

0 commit comments

Comments
 (0)