mirror of
https://github.com/swift-server/swift-aws-lambda-runtime.git
synced 2026-05-03 07:22:27 +00:00
1df89fd39b
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>
147 lines
5.0 KiB
YAML
147 lines
5.0 KiB
YAML
name: IntegrationTests
|
|
|
|
# As per Checkov CKV2_GHA_1
|
|
permissions: read-all
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
name:
|
|
type: string
|
|
description: "The name of the workflow used for the concurrency group."
|
|
required: true
|
|
# We pass the list of examples here, but we can't pass an array as argument
|
|
# Instead, we pass a String with a valid JSON array.
|
|
# The workaround is mentioned here https://github.com/orgs/community/discussions/11692
|
|
examples:
|
|
type: string
|
|
description: "The list of examples to run. Pass a String with a valid JSON array such as \"[ 'HelloWorld', 'APIGateway' ]\""
|
|
required: true
|
|
default: ""
|
|
examples_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the compilation of examples. Defaults to true."
|
|
default: true
|
|
archive_plugin_examples:
|
|
type: string
|
|
description: "The list of examples to run through the archive plugin test. Pass a String with a valid JSON array such as \"[ 'HelloWorld', 'APIGateway' ]\""
|
|
required: true
|
|
default: ""
|
|
archive_plugin_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the test of the archive plugin. Defaults to true."
|
|
default: true
|
|
check_foundation_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the check for Foundation dependency. Defaults to true."
|
|
default: true
|
|
matrix_linux_command:
|
|
type: string
|
|
description: "The command of the current Swift version linux matrix job to execute."
|
|
required: true
|
|
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"
|
|
default: "swift:6.2"
|
|
|
|
## We are cancelling previously triggered workflow runs
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.name }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test-examples:
|
|
name: Test Examples/${{ matrix.examples }} on ${{ matrix.swift.image }}
|
|
if: ${{ inputs.examples_enabled }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
examples: ${{ fromJson(inputs.examples) }}
|
|
|
|
# We are using only one Swift version
|
|
swift:
|
|
- image: ${{ inputs.matrix_linux_swift_container_image }}
|
|
container:
|
|
image: ${{ matrix.swift.image }}
|
|
steps:
|
|
- 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: |
|
|
apt-get -qq update && apt-get -qq -y install libssl-dev
|
|
|
|
- name: Run matrix job
|
|
env:
|
|
COMMAND: ${{ inputs.matrix_linux_command }}
|
|
EXAMPLE: ${{ matrix.examples }}
|
|
run: |
|
|
.github/workflows/scripts/integration_tests.sh
|
|
|
|
test-archive-plugin:
|
|
name: Test archive plugin
|
|
if: ${{ inputs.archive_plugin_enabled }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
examples: ${{ fromJson(inputs.archive_plugin_examples) }}
|
|
# These must run on Ubuntu and not in a container, because the plugin uses docker
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- 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:
|
|
EXAMPLE: ${{ matrix.examples }}
|
|
run: |
|
|
.github/workflows/scripts/check-archive-plugin.sh
|
|
|
|
check-foundation:
|
|
name: No dependencies on Foundation
|
|
if: ${{ inputs.check_foundation_enabled }}
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ${{ inputs.matrix_linux_swift_container_image }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- 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
|
|
run: |
|
|
.github/workflows/scripts/check-link-foundation.sh
|