Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions .github/workflows/swift-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ on:
required: false
type: string
default: Debug
build_flags:
description: |
Additional flags to pass to both `swift build` and `swift test` (e.g. --build-system native, -Xswiftc -warnings-as-errors).
required: false
type: string
default: ''
test_flags:
description: |
Additional flags to pass to `swift test` (e.g. --no-parallel, --filter, --skip).
Additional flags to pass to `swift test` only (e.g. --no-parallel, --filter, --skip).
required: false
type: string
default: ''
Expand Down Expand Up @@ -107,19 +113,31 @@ jobs:
GIT_CONFIG_COUNT: 1
GIT_CONFIG_KEY_0: url.https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/.insteadOf
GIT_CONFIG_VALUE_0: https://github.com/
BUILD_FLAGS: ${{ inputs.build_flags }}
run: |
build_configuration="$(printf '%s' "$BUILD_CONFIGURATION" | awk '{print tolower($0)}')"
build_args=()
if [ -n "$BUILD_FLAGS" ]; then
read -r -a build_args <<< "$BUILD_FLAGS"
fi

swift build \
--configuration "$build_configuration"
--configuration "$build_configuration" \
"${build_args[@]}"
- name: Run tests
env:
BUILD_CONFIGURATION: ${{ inputs.build_configuration }}
GIT_CONFIG_COUNT: 1
GIT_CONFIG_KEY_0: url.https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/.insteadOf
GIT_CONFIG_VALUE_0: https://github.com/
BUILD_FLAGS: ${{ inputs.build_flags }}
TEST_FLAGS: ${{ inputs.test_flags }}
run: |
build_configuration="$(printf '%s' "$BUILD_CONFIGURATION" | awk '{print tolower($0)}')"
build_args=()
if [ -n "$BUILD_FLAGS" ]; then
read -r -a build_args <<< "$BUILD_FLAGS"
fi
test_args=()
if [ -n "$TEST_FLAGS" ]; then
read -r -a test_args <<< "$TEST_FLAGS"
Expand All @@ -128,6 +146,7 @@ jobs:
swift test \
--enable-code-coverage \
--configuration "$build_configuration" \
"${build_args[@]}" \
"${test_args[@]}"
- name: Generate coverage report
if: ${{ (success() || failure()) && inputs.artifact_name != '' }}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!--

This source file is part of the Schmiedmayer Lab open-source organization
Expand Down Expand Up @@ -385,6 +385,7 @@

[`swift-test.yml`](.github/workflows/swift-test.yml) runs SwiftPM tests and can upload an LCOV artifact for later coverage merging.
Use it for Linux Swift package tests or simple SwiftPM test jobs.
Pass `build_flags` for options both `swift build` and `swift test` need, such as `--build-system native`, and `test_flags` for options only `swift test` accepts, such as `--filter`.

```yml
jobs:
Expand Down
Loading