diff --git a/.github/workflows/examples_matrix.yml b/.github/workflows/integration_tests.yml similarity index 51% rename from .github/workflows/examples_matrix.yml rename to .github/workflows/integration_tests.yml index fb9cca41..71b6382a 100644 --- a/.github/workflows/examples_matrix.yml +++ b/.github/workflows/integration_tests.yml @@ -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." @@ -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: @@ -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 diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index e12e4593..7e1c61b8 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -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