Skip to content

Commit 1f2f8ac

Browse files
committed
feat: initial snapshot testing
1 parent 1f79922 commit 1f2f8ac

1 file changed

Lines changed: 82 additions & 62 deletions

File tree

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

Lines changed: 82 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ on:
3737
description: Directory containing the snapshot tests
3838
required: true
3939
type: string
40+
gh_registry:
41+
description: GitHub registry to push images for Snapshot Testing
42+
required: true
43+
type: string
44+
default: ghcr.io
4045

4146
jobs:
4247
get-functions:
@@ -77,6 +82,7 @@ jobs:
7782
id-token: write
7883
contents: read
7984
pull-requests: read
85+
packages: write
8086
needs: get-functions
8187
strategy:
8288
matrix:
@@ -99,6 +105,13 @@ jobs:
99105
path: templates
100106
ref: main
101107

108+
- name: Log in to the GitHub Container registry
109+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1
110+
with:
111+
registry: ${{ inputs.gh_registry }}
112+
username: ${{ github.actor }}
113+
password: ${{ secrets.GITHUB_TOKEN }}
114+
102115
- name: Az CLI login
103116
if: github.ref == 'refs/heads/main'
104117
uses: azure/login@v2
@@ -143,6 +156,7 @@ jobs:
143156
env:
144157
COMPOSE_FILE: ${{ inputs.docker_compose_file }}
145158
PROJECT_NAME: ${{ inputs.project_name }}
159+
GH_REGISTRY: ${{ inputs.gh_registry }}
146160
run: |
147161
function=${{ matrix.function }}
148162
@@ -181,11 +195,15 @@ jobs:
181195
docker push "${repo_name}:${ENVIRONMENT_TAG}"
182196
fi
183197
184-
echo Saving created docker image to a .tar file...
185-
docker save "${PROJECT_NAME}-${function}" -o "${PROJECT_NAME}-${function}".tar
186-
ls -l
187-
echo "ARTIFACT_NAME=${PROJECT_NAME}-${function}" >> $GITHUB_ENV
188-
echo $ARTIFACT_NAME
198+
# echo Saving created docker image to a .tar file...
199+
# docker save "${PROJECT_NAME}-${function}" -o "${PROJECT_NAME}-${function}".tar
200+
# echo "ARTIFACT_NAME=${PROJECT_NAME}-${function}" >> $GITHUB_ENV
201+
# echo $ARTIFACT_NAME
202+
203+
echo Pushing the image into GitHub Registry...
204+
docker push "${{ inputs.gh_registry }}/${PROJECT_NAME}/${PROJECT_NAME}-${function}:${COMMIT_HASH_TAG}"
205+
# echo "ARTIFACT_NAME=${PROJECT_NAME}-${function}" >> $GITHUB_ENV
206+
# echo $ARTIFACT_NAME
189207
190208
export SBOM_REPOSITORY_REPORT="sbom-${function}-repository-report"
191209
echo "SBOM_REPOSITORY_REPORT=$SBOM_REPOSITORY_REPORT" >> $GITHUB_ENV
@@ -256,11 +274,11 @@ jobs:
256274
docker rmi "${repo_name}:${ENVIRONMENT_TAG}"
257275
docker rmi ${PROJECT_NAME}-${function}:latest
258276
259-
- name: Upload docker image as an artifact
260-
uses: actions/upload-artifact@v4
261-
with:
262-
name: ${{ env.ARTIFACT_NAME }}.tar
263-
path: ./${{ env.ARTIFACT_NAME }}.tar
277+
# - name: Upload docker image as an artifact
278+
# uses: actions/upload-artifact@v4
279+
# with:
280+
# name: ${{ env.ARTIFACT_NAME }}.tar
281+
# path: ./${{ env.ARTIFACT_NAME }}.tar
264282

265283
- name: Compress SBOM report
266284
shell: bash
@@ -295,58 +313,60 @@ jobs:
295313
path: ./${{ env.VULNERABILITIES_SUMMARY_LOGFILE }}
296314
retention-days: 21
297315

298-
snapshot-tests:
299-
name: Snapshot tests
300-
runs-on: ubuntu-latest-4-cores
301-
needs: build-and-push
302-
env:
303-
SNAPSHOT_TEST_DIR: ${{ inputs.snapshot_test_dir }}
304-
APP_DIR: ${{ inputs.app_dir }}
305-
steps:
306-
- name: Checkout code
307-
uses: actions/checkout@v4
308-
with:
309-
submodules: true
310-
311-
- name: Check runner resources before download
312-
run: |
313-
echo "--- DISK SPACE ---"
314-
df -h
315-
echo "--- MEMORY ---"
316-
free -h
317-
318-
- name: Download Docker images artifact
319-
uses: actions/download-artifact@v4
320-
with:
321-
pattern: cohort-manager-*.tar
322-
path: ${{ env.APP_DIR }}
323-
324-
- name: Load Docker images
325-
working-directory: ${{ env.APP_DIR }}
326-
run: |
327-
# Find all .tar files within the download directory and its subdirectories
328-
find -name '*.tar' -exec docker load -i {} \;
329-
echo "--- Images loaded successfully ---"
330-
docker images
331-
332-
- name: Run dependencies
333-
working-directory: ${{ env.APP_DIR }}
334-
run: |
335-
docker compose -f compose.deps.yaml up -d
336-
sleep 20
337-
338-
- name: Run application
339-
working-directory: ${{ env.APP_DIR }}
340-
run: |
341-
docker compose up -d
342-
sleep 20
343-
344-
- name: Run snapshot tests
345-
run: ./tests/snapshot-tests/run-snapshot-tests.sh
346-
347-
- name: teardown application
348-
working-directory: ${{ env.APP_DIR }}
349-
run: docker compose down && docker compose -f compose.deps.yaml down
316+
# snapshot-tests:
317+
# name: Snapshot tests
318+
# runs-on: ubuntu-latest-4-cores
319+
# permissions:
320+
# packages: read
321+
# needs: build-and-push
322+
# env:
323+
# SNAPSHOT_TEST_DIR: ${{ inputs.snapshot_test_dir }}
324+
# APP_DIR: ${{ inputs.app_dir }}
325+
# steps:
326+
# - name: Checkout code
327+
# uses: actions/checkout@v4
328+
# with:
329+
# submodules: true
330+
331+
# - name: Check runner resources before download
332+
# run: |
333+
# echo "--- DISK SPACE ---"
334+
# df -h
335+
# echo "--- MEMORY ---"
336+
# free -h
337+
338+
# - name: Download Docker images artifact
339+
# uses: actions/download-artifact@v4
340+
# with:
341+
# pattern: cohort-manager-*.tar
342+
# path: ${{ env.APP_DIR }}
343+
344+
# - name: Load Docker images
345+
# working-directory: ${{ env.APP_DIR }}
346+
# run: |
347+
# # Find all .tar files within the download directory and its subdirectories
348+
# find -name '*.tar' -exec docker load -i {} \;
349+
# echo "--- Images loaded successfully ---"
350+
# docker images
351+
352+
# - name: Run dependencies
353+
# working-directory: ${{ env.APP_DIR }}
354+
# run: |
355+
# docker compose -f compose.deps.yaml up -d
356+
# sleep 20
357+
358+
# - name: Run application
359+
# working-directory: ${{ env.APP_DIR }}
360+
# run: |
361+
# docker compose up -d
362+
# sleep 20
363+
364+
# - name: Run snapshot tests
365+
# run: ./tests/snapshot-tests/run-snapshot-tests.sh
366+
367+
# - name: teardown application
368+
# working-directory: ${{ env.APP_DIR }}
369+
# run: docker compose down && docker compose -f compose.deps.yaml down
350370

351371

352372
aggregate-json:

0 commit comments

Comments
 (0)