Implement a cache for integration test (#649)

This PR divides the CI time by ~2

## Issue #

N/A

## Description of changes

This PR makes two changes to the integration tests workflow:

1. Replace the manual `git clone` checkout with `actions/checkout@v4` in
the `test-examples` job. The container image was updated from Amazon
Linux 2 to `swift:6.2` (Ubuntu-based), which supports Node.js-based
GitHub Actions. This also removes the now-unnecessary
`working-directory` overrides that pointed to the repository
subdirectory created by the manual clone.

2. Add SPM dependency caching (`actions/cache@v4`) to the
`test-examples`, `test-archive-plugin`, and `check-foundation` jobs.
Each example's `.build` directory is cached with a key scoped per
example name, avoiding cross-contamination between different dependency
sets.

## New/existing dependencies impact assessment, if applicable

No new dependencies were added to this change. This only adds the
`actions/cache@v4` GitHub Action to the CI workflow.

## Conventional Commits

`ci: switch to actions/checkout and add SPM dependency caching in
integration tests`

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Co-authored-by: Sebastien Stormacq <stormacq@amazon.lu>
Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
This commit is contained in:
Sébastien Stormacq
2026-02-24 18:55:34 +01:00
committed by GitHub
parent 748ced263c
commit 1df89fd39b
+37 -57
View File
@@ -42,8 +42,8 @@ on:
matrix_linux_swift_container_image:
type: string
# Note: we don't use Amazon Linux 2 here because zip is not installed by default.
description: "Container image for the matrix test jobs. Defaults to Swift 6.2 on Amazon Linux 2."
default: "swift:6.2-amazonlinux2"
description: "Container image for the matrix test jobs. Defaults to Swift 6.2"
default: "swift:6.2"
## We are cancelling previously triggered workflow runs
concurrency:
@@ -66,35 +66,24 @@ jobs:
container:
image: ${{ matrix.swift.image }}
steps:
# GitHub checkout action has a dep on NodeJS 20 which is not running on Amazonlinux2
# workaround is to manually checkout the repository
# https://github.com/actions/checkout/issues/1487
- name: Manually Clone repository and checkout PR
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Cache SPM dependencies
uses: actions/cache@v5
with:
path: Examples/${{ matrix.examples }}/.build
key: spm-${{ runner.os }}-${{ matrix.examples }}-${{ hashFiles(format('Examples/{0}/Package.swift', matrix.examples)) }}
restore-keys: |
spm-${{ runner.os }}-${{ matrix.examples }}-
- name: Install dependencies
run: |
# Clone the repository
git clone https://github.com/${{ github.repository }}
cd ${{ github.event.repository.name }}
# Fetch the pull request
git fetch origin +refs/pull/$PR_NUMBER/merge:
# Checkout the pull request
git checkout -qf FETCH_HEAD
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# persist-credentials: false
- name: Mark the workspace as safe
working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4
# https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
apt-get -qq update && apt-get -qq -y install libssl-dev
- name: Run matrix job
working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4
env:
COMMAND: ${{ inputs.matrix_linux_command }}
EXAMPLE: ${{ matrix.examples }}
@@ -116,9 +105,15 @@ jobs:
with:
persist-credentials: false
- name: Mark the workspace as safe
# https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Cache SPM dependencies
uses: actions/cache@v5
with:
path: |
Examples/${{ matrix.examples }}/.build/checkouts
Examples/${{ matrix.examples }}/.build/repositories
key: spm-${{ runner.os }}-${{ matrix.examples }}-${{ hashFiles(format('Examples/{0}/Package.swift', matrix.examples)) }}
restore-keys: |
spm-${{ runner.os }}-${{ matrix.examples }}-
- name: Test the archive plugin
env:
@@ -133,34 +128,19 @@ jobs:
container:
image: ${{ inputs.matrix_linux_swift_container_image }}
steps:
# GitHub checkout action has a dep on NodeJS 20 which is not running on Amazonlinux2
# workaround is to manually checkout the repository
# https://github.com/actions/checkout/issues/1487
- name: Manually Clone repository and checkout PR
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
# Clone the repository
git clone https://github.com/${{ github.repository }}
cd ${{ github.event.repository.name }}
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false
# Fetch the pull request
git fetch origin +refs/pull/$PR_NUMBER/merge:
# Checkout the pull request
git checkout -qf FETCH_HEAD
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# persist-credentials: false
- name: Mark the workspace as safe
working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4
# https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Cache SPM dependencies
uses: actions/cache@v5
with:
path: Examples/APIGatewayV2/.build
key: spm-foundation-${{ runner.os }}-${{ hashFiles('Examples/APIGatewayV2/Package.swift') }}
restore-keys: |
spm-foundation-${{ runner.os }}-
- name: Check for Foundation or ICU dependency
working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4
run: |
.github/workflows/scripts/check-link-foundation.sh