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
2840jobs :
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 :
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 
0 commit comments