Skip to content

Commit 1df89fd

Browse files
sebstoSebastien Stormacq0xTim
authored
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>
1 parent 748ced2 commit 1df89fd

1 file changed

Lines changed: 36 additions & 56 deletions

File tree

‎.github/workflows/integration_tests.yml‎

Lines changed: 36 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ on:
4242
matrix_linux_swift_container_image:
4343
type: string
4444
# Note: we don't use Amazon Linux 2 here because zip is not installed by default.
45-
description: "Container image for the matrix test jobs. Defaults to Swift 6.2 on Amazon Linux 2."
46-
default: "swift:6.2-amazonlinux2"
45+
description: "Container image for the matrix test jobs. Defaults to Swift 6.2"
46+
default: "swift:6.2"
4747

4848
## We are cancelling previously triggered workflow runs
4949
concurrency:
@@ -66,35 +66,24 @@ jobs:
6666
container:
6767
image: ${{ matrix.swift.image }}
6868
steps:
69-
# GitHub checkout action has a dep on NodeJS 20 which is not running on Amazonlinux2
70-
# workaround is to manually checkout the repository
71-
# https://github.com/actions/checkout/issues/1487
72-
- name: Manually Clone repository and checkout PR
73-
env:
74-
PR_NUMBER: ${{ github.event.pull_request.number }}
75-
run: |
76-
# Clone the repository
77-
git clone https://github.com/${{ github.repository }}
78-
cd ${{ github.event.repository.name }}
79-
80-
# Fetch the pull request
81-
git fetch origin +refs/pull/$PR_NUMBER/merge:
82-
83-
# Checkout the pull request
84-
git checkout -qf FETCH_HEAD
69+
- name: Checkout repository
70+
uses: actions/checkout@v6
71+
with:
72+
persist-credentials: false
8573

86-
# - name: Checkout repository
87-
# uses: actions/checkout@v4
88-
# with:
89-
# persist-credentials: false
74+
- name: Cache SPM dependencies
75+
uses: actions/cache@v5
76+
with:
77+
path: Examples/${{ matrix.examples }}/.build
78+
key: spm-${{ runner.os }}-${{ matrix.examples }}-${{ hashFiles(format('Examples/{0}/Package.swift', matrix.examples)) }}
79+
restore-keys: |
80+
spm-${{ runner.os }}-${{ matrix.examples }}-
9081
91-
- name: Mark the workspace as safe
92-
working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4
93-
# https://github.com/actions/checkout/issues/766
94-
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
82+
- name: Install dependencies
83+
run: |
84+
apt-get -qq update && apt-get -qq -y install libssl-dev
9585
9686
- name: Run matrix job
97-
working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4
9887
env:
9988
COMMAND: ${{ inputs.matrix_linux_command }}
10089
EXAMPLE: ${{ matrix.examples }}
@@ -116,9 +105,15 @@ jobs:
116105
with:
117106
persist-credentials: false
118107

119-
- name: Mark the workspace as safe
120-
# https://github.com/actions/checkout/issues/766
121-
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
108+
- name: Cache SPM dependencies
109+
uses: actions/cache@v5
110+
with:
111+
path: |
112+
Examples/${{ matrix.examples }}/.build/checkouts
113+
Examples/${{ matrix.examples }}/.build/repositories
114+
key: spm-${{ runner.os }}-${{ matrix.examples }}-${{ hashFiles(format('Examples/{0}/Package.swift', matrix.examples)) }}
115+
restore-keys: |
116+
spm-${{ runner.os }}-${{ matrix.examples }}-
122117
123118
- name: Test the archive plugin
124119
env:
@@ -133,34 +128,19 @@ jobs:
133128
container:
134129
image: ${{ inputs.matrix_linux_swift_container_image }}
135130
steps:
136-
# GitHub checkout action has a dep on NodeJS 20 which is not running on Amazonlinux2
137-
# workaround is to manually checkout the repository
138-
# https://github.com/actions/checkout/issues/1487
139-
- name: Manually Clone repository and checkout PR
140-
env:
141-
PR_NUMBER: ${{ github.event.pull_request.number }}
142-
run: |
143-
# Clone the repository
144-
git clone https://github.com/${{ github.repository }}
145-
cd ${{ github.event.repository.name }}
146-
147-
# Fetch the pull request
148-
git fetch origin +refs/pull/$PR_NUMBER/merge:
149-
150-
# Checkout the pull request
151-
git checkout -qf FETCH_HEAD
152-
153-
# - name: Checkout repository
154-
# uses: actions/checkout@v4
155-
# with:
156-
# persist-credentials: false
131+
- name: Checkout repository
132+
uses: actions/checkout@v6
133+
with:
134+
persist-credentials: false
157135

158-
- name: Mark the workspace as safe
159-
working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4
160-
# https://github.com/actions/checkout/issues/766
161-
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
136+
- name: Cache SPM dependencies
137+
uses: actions/cache@v5
138+
with:
139+
path: Examples/APIGatewayV2/.build
140+
key: spm-foundation-${{ runner.os }}-${{ hashFiles('Examples/APIGatewayV2/Package.swift') }}
141+
restore-keys: |
142+
spm-foundation-${{ runner.os }}-
162143
163144
- name: Check for Foundation or ICU dependency
164-
working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4
165145
run: |
166146
.github/workflows/scripts/check-link-foundation.sh

0 commit comments

Comments
 (0)