From a3ac6e8f776ded46eafb466de76e2f834cf569fe Mon Sep 17 00:00:00 2001 From: Franz Busch Date: Thu, 10 Oct 2024 13:26:16 +0200 Subject: [PATCH] [CI] Adopt soundess workflow from swiftlang --- .github/ISSUE_TEMPLATE/issue-report.yml | 4 +- .github/workflows/examples_matrix.yml | 73 ++++++++++++------------- .github/workflows/pull_request.yml | 62 ++++++++++----------- Examples/APIGateway/template.yaml | 4 +- Examples/S3_AWSSDK/template.yaml | 12 ++-- Examples/S3_Soto/template.yaml | 13 ++--- 6 files changed, 83 insertions(+), 85 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/issue-report.yml b/.github/ISSUE_TEMPLATE/issue-report.yml index e5f5d4e9..ae6e0ba3 100644 --- a/.github/ISSUE_TEMPLATE/issue-report.yml +++ b/.github/ISSUE_TEMPLATE/issue-report.yml @@ -17,7 +17,7 @@ body: attributes: label: Actual behavior description: What actually happened - placeholder: Describe + placeholder: Describe validations: required: true - type: textarea @@ -55,7 +55,7 @@ body: attributes: label: Swift version description: Swift environment version. - placeholder: | + placeholder: | Open a Terminal and execute the following command swift --version && uname -a diff --git a/.github/workflows/examples_matrix.yml b/.github/workflows/examples_matrix.yml index 15e4e859..fb9cca41 100644 --- a/.github/workflows/examples_matrix.yml +++ b/.github/workflows/examples_matrix.yml @@ -24,58 +24,57 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.name }} cancel-in-progress: true - + jobs: linux: - name: Example/${{ matrix.examples }} on Linux ${{ matrix.swift.swift_version }} + name: Example/${{ matrix.examples }} on Linux ${{ matrix.swift.swift_version }} 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: ["HelloWorld", "APIGateway", "S3_AWSSDK", "S3_Soto"] # examples: ${{ inputs.examples }} - # We are using only one Swift version + # We are using only one Swift version swift: - - image: ${{ inputs.matrix_linux_swift_container_image }} - swift_version: "6.0.1-amazonlinux2" + - image: ${{ inputs.matrix_linux_swift_container_image }} + swift_version: "6.0.1-amazonlinux2" container: image: ${{ matrix.swift.image }} steps: + # GitHub checkout action has a dep on NodeJS 20 which is not running on Amazonlinux2 + # workaround is to manually checkout the repository + # https://github.com/actions/checkout/issues/1487 + - name: Manually Clone repository and checkout PR + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + # Clone the repository + git clone https://github.com/${{ github.repository }} + cd ${{ github.event.repository.name }} - # GitHub checkout action has a dep on NodeJS 20 which is not running on Amazonlinux2 - # workaround is to manually checkout the repository - # https://github.com/actions/checkout/issues/1487 - - name: Manually Clone repository and checkout PR - env: - PR_NUMBER: ${{ github.event.pull_request.number }} - run: | - # Clone the repository - git clone https://github.com/${{ github.repository }} - cd ${{ github.event.repository.name }} + # Fetch the pull request + git fetch origin +refs/pull/$PR_NUMBER/merge: - # Fetch the pull request - git fetch origin +refs/pull/$PR_NUMBER/merge: - - # Checkout the pull request - git checkout -qf FETCH_HEAD + # Checkout the pull request + git checkout -qf FETCH_HEAD - # - name: Checkout repository - # uses: actions/checkout@v4 - # with: - # persist-credentials: false + # - name: Checkout repository + # uses: actions/checkout@v4 + # with: + # persist-credentials: false - - name: Mark the workspace as safe - working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4 - # https://github.com/actions/checkout/issues/766 - run: git config --global --add safe.directory ${GITHUB_WORKSPACE} + - name: Mark the workspace as safe + working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4 + # https://github.com/actions/checkout/issues/766 + run: git config --global --add safe.directory ${GITHUB_WORKSPACE} - - name: Run matrix job - working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4 - env: - SWIFT_VERSION: ${{ matrix.swift.swift_version }} - COMMAND: ${{ inputs.matrix_linux_command }} - EXAMPLE: ${{ matrix.examples }} - run: | - ./scripts/integration_tests.sh \ No newline at end of file + - name: Run matrix job + working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4 + env: + SWIFT_VERSION: ${{ matrix.swift.swift_version }} + COMMAND: ${{ inputs.matrix_linux_command }} + EXAMPLE: ${{ matrix.examples }} + run: | + ./scripts/integration_tests.sh diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 77f9a5af..bcd2104e 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,38 +1,38 @@ name: PR on: - pull_request: - types: [opened, reopened, synchronize] + pull_request: + types: [opened, reopened, synchronize] jobs: - soundness: - name: Soundness - uses: apple/swift-nio/.github/workflows/soundness.yml@main - with: - license_header_check_project_name: "SwiftAWSLambdaRuntime" - shell_check_enabled: false - api_breakage_check_container_image: "swift:6.0-noble" - docs_check_container_image: "swift:6.0-noble" + soundness: + name: Soundness + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main + with: + license_header_check_project_name: "SwiftAWSLambdaRuntime" + shell_check_enabled: false + api_breakage_check_container_image: "swift:6.0-noble" + docs_check_container_image: "swift:6.0-noble" - unit-tests: - name: Unit tests - uses: apple/swift-nio/.github/workflows/unit_tests.yml@main - with: - linux_5_8_enabled: false - linux_5_9_enabled: false - linux_5_10_enabled: false - linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error" - linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error" + unit-tests: + name: Unit tests + uses: apple/swift-nio/.github/workflows/unit_tests.yml@main + with: + linux_5_8_enabled: false + linux_5_9_enabled: false + linux_5_10_enabled: false + linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error" + linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error" - integration-tests: - name: Integration Tests - uses: ./.github/workflows/examples_matrix.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" - matrix_linux_command: "LAMBDA_USE_LOCAL_DEPS=../.. swift build" - - swift-6-language-mode: - name: Swift 6 Language Mode - uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main + integration-tests: + name: Integration Tests + uses: ./.github/workflows/examples_matrix.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" + matrix_linux_command: "LAMBDA_USE_LOCAL_DEPS=../.. swift build" + + swift-6-language-mode: + name: Swift 6 Language Mode + uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main diff --git a/Examples/APIGateway/template.yaml b/Examples/APIGateway/template.yaml index 99a00da9..0d7a6af4 100644 --- a/Examples/APIGateway/template.yaml +++ b/Examples/APIGateway/template.yaml @@ -9,7 +9,7 @@ Resources: Properties: CodeUri: .build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/APIGatewayLambda/APIGatewayLambda.zip Timeout: 60 - Handler: swift.bootstrap # ignored by the Swift runtime + Handler: swift.bootstrap # ignored by the Swift runtime Runtime: provided.al2 MemorySize: 512 Architectures: @@ -22,7 +22,7 @@ Resources: LOG_LEVEL: debug Events: HttpApiEvent: - Type: HttpApi + Type: HttpApi Outputs: # print API Gateway endpoint diff --git a/Examples/S3_AWSSDK/template.yaml b/Examples/S3_AWSSDK/template.yaml index b1e02416..46e29ec8 100644 --- a/Examples/S3_AWSSDK/template.yaml +++ b/Examples/S3_AWSSDK/template.yaml @@ -9,7 +9,7 @@ Resources: Properties: CodeUri: .build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/AWSSDKExample/AWSSDKExample.zip Timeout: 60 - Handler: swift.bootstrap # ignored by the Swift runtime + Handler: swift.bootstrap # ignored by the Swift runtime Runtime: provided.al2 MemorySize: 512 Architectures: @@ -30,11 +30,11 @@ Resources: # It grants the function permissions to read the list of buckets in your account. Policies: - Statement: - - Sid: ListAllS3BucketsInYourAccount - Effect: Allow - Action: - - s3:ListAllMyBuckets - Resource: '*' + - Sid: ListAllS3BucketsInYourAccount + Effect: Allow + Action: + - s3:ListAllMyBuckets + Resource: '*' # print API endpoint Outputs: diff --git a/Examples/S3_Soto/template.yaml b/Examples/S3_Soto/template.yaml index 50093169..bfc04d1e 100644 --- a/Examples/S3_Soto/template.yaml +++ b/Examples/S3_Soto/template.yaml @@ -1,4 +1,3 @@ - AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: SAM Template for AWS SDK Example @@ -10,7 +9,7 @@ Resources: Properties: CodeUri: .build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/SotoExample/SotoExample.zip Timeout: 60 - Handler: swift.bootstrap # ignored by the Swift runtime + Handler: swift.bootstrap # ignored by the Swift runtime Runtime: provided.al2 MemorySize: 512 Architectures: @@ -31,11 +30,11 @@ Resources: # It grants the function permissions to read the list of buckets in your account. Policies: - Statement: - - Sid: ListAllS3BucketsInYourAccount - Effect: Allow - Action: - - s3:ListAllMyBuckets - Resource: '*' + - Sid: ListAllS3BucketsInYourAccount + Effect: Allow + Action: + - s3:ListAllMyBuckets + Resource: '*' # print API endpoint Outputs: