Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] add integration test for the archive plugin #406

Merged
merged 19 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ on:
type: string
description: "The name of the workflow used for the concurrency group."
required: true
# examples:
# type: sequence
# description: "The examples to run."
# 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_enabled:
type: boolean
description: "Boolean to enable the test of the archive plugin. Defaults to true."
default: true
matrix_linux_command:
type: string
description: "The command of the current Swift version linux matrix job to execute."
Expand All @@ -26,15 +38,14 @@ concurrency:
cancel-in-progress: true

jobs:
linux:
name: Example/${{ matrix.examples }} on Linux ${{ matrix.swift.swift_version }}
test-examples:
name: Test Examples/${{ matrix.examples }} on ${{ matrix.swift.swift_version }}
if: ${{ inputs.examples_enabled }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# This should be passed as an argument in input. Can we pass arrays as argument ?
examples: ["HelloWorld", "APIGateway", "S3_AWSSDK", "S3_Soto"]
# examples: ${{ inputs.examples }}
examples: ${{ fromJson(inputs.examples) }}

# We are using only one Swift version
swift:
Expand Down Expand Up @@ -78,3 +89,42 @@ jobs:
EXAMPLE: ${{ matrix.examples }}
run: |
./scripts/integration_tests.sh
echo "✅ The examples compile correctly"

test-archive-plugin:
name: Test archive plugin
if: ${{ inputs.archive_plugin_enabled }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
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: Test the archive plugin
env:
EXAMPLE: HelloWorld
OUTPUT_FILE: .build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/MyLambda/bootstrap
ZIP_FILE: .build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/MyLambda/MyLambda.zip
run: |
pushd Examples/${EXAMPLE}

# package the example (docker and swift toolchain are installed on the GH runner)
echo yes | swift package archive --allow-network-connections docker

# did the plugin generated a Linux binary?
[ -f ${OUTPUT_FILE} ]
file ${OUTPUT_FILE} | grep --silent ELF

# did the plugin created a ZIP file?
[ -f ${ZIP_FILE} ]

# does the ZIP file contain the bootstrap?
unzip -l ${ZIP_FILE} | grep --silent bootstrap

echo "✅ The archive plugin is OK"
popd
11 changes: 8 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ jobs:

integration-tests:
name: Integration Tests
uses: ./.github/workflows/examples_matrix.yml
uses: ./.github/workflows/integration_tests.yml
with:
# We should pass the list of examples here, but we can't pass an array as argument
# examples: [ "HelloWorld", "APIGateway" ]
name: "Integration tests"
examples_enabled: true
matrix_linux_command: "LAMBDA_USE_LOCAL_DEPS=../.. swift build"
# 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: "[ 'HelloWorld', 'APIGateway','S3_AWSSDK', 'S3_Soto' ]"

archive_plugin_enabled: true

swift-6-language-mode:
name: Swift 6 Language Mode
Expand Down
Loading