mirror of
https://github.com/swift-server/swift-aws-lambda-runtime.git
synced 2026-06-02 07:27:33 +00:00
When including resources in the package and packaging on Ubuntu, `FileManager` throws a FilePermission error. The docker daemon runs as root and files to be copied are owned by `root` while the archiver runs as the current user (`ubuntu` on EC2 Ubuntu). The `FileManager` manages to copy the files but throws an error after the copy. We suspect the `FileManager` to perform some kind of operation after the copy and it fails because of the `root` permission of the files. See https://github.com/swift-server/swift-aws-lambda-runtime/issues/449#issuecomment-2595978246 for a description of the problem. This PR contains code to reproduce the problem, a very simple workaround, and an integration test. The workaround consists of - trapping all errors - verify if the error is the permission error (Code = 513) - verify if the files have been copied or not - if the two above conditions are met, ignore the error, otherwise re-throw it I would rather prefer a solution that solves the root cause rather than just ignoring the error. We're still investigating the root cause (see [this thread](https://forums.swift.org/t/filemanager-copyitem-on-linux-fails-after-copying-the-files/77282) on the Swift Forum and this issue on Swift Foundation https://github.com/swiftlang/swift-foundation/issues/1125
139 lines
5.1 KiB
YAML
139 lines
5.1 KiB
YAML
name: IntegrationTests
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
name:
|
|
type: string
|
|
description: "The name of the workflow used for the concurrency group."
|
|
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_examples:
|
|
type: string
|
|
description: "The list of examples to run through the archive plugin test. Pass a String with a valid JSON array such as \"[ 'HelloWorld', 'APIGateway' ]\""
|
|
required: true
|
|
default: ""
|
|
archive_plugin_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the test of the archive plugin. Defaults to true."
|
|
default: true
|
|
check_foundation_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the check for Foundation dependency. Defaults to true."
|
|
default: true
|
|
matrix_linux_command:
|
|
type: string
|
|
description: "The command of the current Swift version linux matrix job to execute."
|
|
required: true
|
|
matrix_linux_swift_container_image:
|
|
type: string
|
|
description: "Container image for the matrix job. Defaults to matching latest Swift Ubuntu image."
|
|
default: "swift:amazonlinux2"
|
|
|
|
## We are cancelling previously triggered workflow runs
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.name }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
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:
|
|
examples: ${{ fromJson(inputs.examples) }}
|
|
|
|
# We are using only one Swift version
|
|
swift:
|
|
- image: ${{ inputs.matrix_linux_swift_container_image }}
|
|
swift_version: "6.0.3-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 }}
|
|
|
|
# Fetch the pull request
|
|
git fetch origin +refs/pull/$PR_NUMBER/merge:
|
|
|
|
# Checkout the pull request
|
|
git checkout -qf FETCH_HEAD
|
|
|
|
# - 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: 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: |
|
|
.github/workflows/scripts/integration_tests.sh
|
|
|
|
test-archive-plugin:
|
|
name: Test archive plugin
|
|
if: ${{ inputs.archive_plugin_enabled }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
examples: ${{ fromJson(inputs.archive_plugin_examples) }}
|
|
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: ${{ matrix.examples }}
|
|
run: |
|
|
.github/workflows/scripts/check-archive-plugin.sh
|
|
|
|
check-foundation:
|
|
name: No dependencies on Foundation
|
|
if: ${{ inputs.check_foundation_enabled }}
|
|
runs-on: ubuntu-latest
|
|
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: Check for Foundation or ICU dependency
|
|
run: |
|
|
.github/workflows/scripts/check-link-foundation.sh
|