|
29 | 29 | required: false |
30 | 30 | type: boolean |
31 | 31 | default: false |
| 32 | + snapshot_test_dir: |
| 33 | + description: Directory containing the snapshot tests |
| 34 | + required: true |
| 35 | + type: string |
32 | 36 |
|
33 | 37 | jobs: |
34 | 38 | get-functions: |
@@ -236,12 +240,21 @@ jobs: |
236 | 240 | } | tee -a "$VULNERABILITIES_SUMMARY_LOGFILE" |
237 | 241 | done |
238 | 242 |
|
| 243 | + docker save "${repo_name}:${COMMIT_HASH_TAG}" -o "${repo_name}:${COMMIT_HASH_TAG}".tar |
| 244 | +
|
239 | 245 | # Remove the image |
240 | 246 | docker rmi "${repo_name}:${COMMIT_HASH_TAG}" |
241 | 247 | docker rmi "${repo_name}:${PR_NUM_TAG}" |
242 | 248 | docker rmi "${repo_name}:${ENVIRONMENT_TAG}" |
243 | 249 | docker rmi ${PROJECT_NAME}-${function}:latest |
244 | 250 |
|
| 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 | + |
245 | 258 | - name: Compress SBOM report |
246 | 259 | shell: bash |
247 | 260 | run: | |
@@ -275,6 +288,51 @@ jobs: |
275 | 288 | path: ./${{ env.VULNERABILITIES_SUMMARY_LOGFILE }} |
276 | 289 | retention-days: 21 |
277 | 290 |
|
| 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 | + |
278 | 336 | aggregate-json: |
279 | 337 | runs-on: ubuntu-latest |
280 | 338 | needs: build-and-push |
|
0 commit comments