Skip to content

Commit 2fad042

Browse files
authored
[CI] add integration test for the archive plugin (#406)
* add integration test for the archive plugin
1 parent 8eddc28 commit 2fad042

File tree

2 files changed

+67
-12
lines changed

2 files changed

+67
-12
lines changed

.github/workflows/examples_matrix.yml renamed to .github/workflows/integration_tests.yml

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,22 @@ on:
77
type: string
88
description: "The name of the workflow used for the concurrency group."
99
required: true
10-
# examples:
11-
# type: sequence
12-
# description: "The examples to run."
13-
# required: true
10+
# We pass the list of examples here, but we can't pass an array as argument
11+
# Instead, we pass a String with a valid JSON array.
12+
# The workaround is mentioned here https://github.com/orgs/community/discussions/11692
13+
examples:
14+
type: string
15+
description: "The list of examples to run. Pass a String with a valid JSON array such as \"[ 'HelloWorld', 'APIGateway' ]\""
16+
required: true
17+
default: ""
18+
examples_enabled:
19+
type: boolean
20+
description: "Boolean to enable the compilation of examples. Defaults to true."
21+
default: true
22+
archive_plugin_enabled:
23+
type: boolean
24+
description: "Boolean to enable the test of the archive plugin. Defaults to true."
25+
default: true
1426
matrix_linux_command:
1527
type: string
1628
description: "The command of the current Swift version linux matrix job to execute."
@@ -26,15 +38,14 @@ concurrency:
2638
cancel-in-progress: true
2739

2840
jobs:
29-
linux:
30-
name: Example/${{ matrix.examples }} on Linux ${{ matrix.swift.swift_version }}
41+
test-examples:
42+
name: Test Examples/${{ matrix.examples }} on ${{ matrix.swift.swift_version }}
43+
if: ${{ inputs.examples_enabled }}
3144
runs-on: ubuntu-latest
3245
strategy:
3346
fail-fast: false
3447
matrix:
35-
# This should be passed as an argument in input. Can we pass arrays as argument ?
36-
examples: ["HelloWorld", "APIGateway", "S3_AWSSDK", "S3_Soto"]
37-
# examples: ${{ inputs.examples }}
48+
examples: ${{ fromJson(inputs.examples) }}
3849

3950
# We are using only one Swift version
4051
swift:
@@ -78,3 +89,42 @@ jobs:
7889
EXAMPLE: ${{ matrix.examples }}
7990
run: |
8091
./scripts/integration_tests.sh
92+
echo "✅ The examples compile correctly"
93+
94+
test-archive-plugin:
95+
name: Test archive plugin
96+
if: ${{ inputs.archive_plugin_enabled }}
97+
runs-on: ubuntu-latest
98+
strategy:
99+
fail-fast: false
100+
steps:
101+
- name: Checkout repository
102+
uses: actions/checkout@v4
103+
with:
104+
persist-credentials: false
105+
- name: Mark the workspace as safe
106+
# https://github.com/actions/checkout/issues/766
107+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
108+
- name: Test the archive plugin
109+
env:
110+
EXAMPLE: HelloWorld
111+
OUTPUT_FILE: .build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/MyLambda/bootstrap
112+
ZIP_FILE: .build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/MyLambda/MyLambda.zip
113+
run: |
114+
pushd Examples/${EXAMPLE}
115+
116+
# package the example (docker and swift toolchain are installed on the GH runner)
117+
echo yes | swift package archive --allow-network-connections docker
118+
119+
# did the plugin generated a Linux binary?
120+
[ -f ${OUTPUT_FILE} ]
121+
file ${OUTPUT_FILE} | grep --silent ELF
122+
123+
# did the plugin created a ZIP file?
124+
[ -f ${ZIP_FILE} ]
125+
126+
# does the ZIP file contain the bootstrap?
127+
unzip -l ${ZIP_FILE} | grep --silent bootstrap
128+
129+
echo "✅ The archive plugin is OK"
130+
popd

.github/workflows/pull_request.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ jobs:
2828

2929
integration-tests:
3030
name: Integration Tests
31-
uses: ./.github/workflows/examples_matrix.yml
31+
uses: ./.github/workflows/integration_tests.yml
3232
with:
33-
# We should pass the list of examples here, but we can't pass an array as argument
34-
# examples: [ "HelloWorld", "APIGateway" ]
3533
name: "Integration tests"
34+
examples_enabled: true
3635
matrix_linux_command: "LAMBDA_USE_LOCAL_DEPS=../.. swift build"
36+
# We pass the list of examples here, but we can't pass an array as argument
37+
# Instead, we pass a String with a valid JSON array.
38+
# The workaround is mentioned here https://github.com/orgs/community/discussions/11692
39+
examples: "[ 'HelloWorld', 'APIGateway','S3_AWSSDK', 'S3_Soto' ]"
40+
41+
archive_plugin_enabled: true
3742

3843
swift-6-language-mode:
3944
name: Swift 6 Language Mode

0 commit comments

Comments
 (0)