Skip to content
Closed
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
117 changes: 32 additions & 85 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,93 +8,40 @@ on:
types: [opened, reopened, synchronize]

jobs:
tests:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
linux_os_versions: '["amazonlinux2023", "bookworm", "noble", "jammy", "rhel-ubi9"]'
linux_swift_versions: '["6.2", "nightly-main"]'
linux_pre_build_command: |
if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy
# Test dependencies
if command -v sudo &> /dev/null && [ "$EUID" -ne 0 ]; then
sudo apt-get update -y
sudo apt-get install -y procps
else
apt-get update -y
apt-get install -y procps
fi
elif command -v dnf >/dev/null 2>&1 ; then # amazonlinux2023, rhel-ubi9
dnf update -y

# Test dependencies
dnf install -y procps
fi
linux_exclude_swift_versions: '[{"swift_version": "6.2", "os_version": "amazonlinux2023"}]'
linux_static_sdk_exclude_swift_versions: '[{"swift_version": "6.2", "os_version": "amazonlinux2023"}]'
linux_build_command: "swift test && swift test -c release && swift test --disable-default-traits"
enable_freebsd_checks: true
freebsd_build_command: "swift test && swift test -c release && swift test --disable-default-traits"
windows_swift_versions: '["6.2", "nightly-main"]'
windows_build_command: |
Invoke-Program swift test
Invoke-Program swift test -c release
Invoke-Program swift test --disable-default-traits
enable_macos_checks: true
macos_xcode_versions: '["26.4"]'
macos_build_command: "xcrun swift test && xcrun swift test -c release && xcrun swift test --disable-default-traits"
enable_linux_static_sdk_build: true
enable_android_sdk_build: true
enable_android_sdk_checks: true
android_ndk_versions: '["r27d", "r29"]'
linux_static_sdk_versions: '["6.2", "nightly-main"]'
linux_static_sdk_build_command: |
for triple in aarch64-swift-linux-musl x86_64-swift-linux-musl ; do
swift build --swift-sdk "\$triple"
swift build --swift-sdk "\$triple" --disable-default-traits
done
# empty line to ignore the --swift-sdk given by swiftlang/github-workflows/.github/workflows/scripts/install-and-build-with-sdk.sh \

test_linux_kernel:
name: Test Linux Kernel / ${{ matrix.dist-kern }}
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
# These are specific distro and kernel versions that the test qemu script supports from here: https://images.linuxcontainers.org
dist-kern: ["al2-4.18", "al2-5.10"]
container:
image: ubuntu:24.04
test_macos_root:
name: Test macOS (root)
runs-on: macos-26
timeout-minutes: 30
env:
ROOT_SUITE: SubprocessUnixRootTests
steps:
- name: Remove leftover root build
run: sudo -n rm -rf "${GITHUB_WORKSPACE}/.build-root" || true

- name: Checkout repository
uses: actions/checkout@v7
- name: Run Test
run: bash -c './scripts/test-using-qemu.sh ${{ matrix.dist-kern }} -- swift test'

soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@0.0.12
with:
license_header_check_project_name: "Swift.org"
docs_check_enabled: false
format_check_enabled: true
unacceptable_language_check_enabled: false
api_breakage_check_enabled: false
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_26.4.app

cmake_build:
name: CMake Build
runs-on: ubuntu-latest
container: swiftlang/swift:nightly-noble
steps:
- name: checkout sources
uses: actions/checkout@v7
- name: Install dependencies
shell: bash
run: apt update && apt install -y cmake ninja-build
- name: Configure Project
shell: bash
run: cmake -G 'Ninja' -B build -S . -DCMAKE_C_COMPILER=clang -DCMAKE_Swift_COMPILER=swiftc -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=YES
- name: Build Project
shell: bash
run: cmake --build build
- name: Verify passwordless sudo
run: |
uid="$(sudo -n id -u)" || { echo "::error::passwordless sudo unavailable"; exit 1; }
[ "$uid" -eq 0 ] || { echo "::error::sudo did not elevate to root (uid=$uid)"; exit 1; }

- name: Build root test suite
run: sudo -n xcrun swift build --build-tests --scratch-path "${GITHUB_WORKSPACE}/.build-root"

- name: Discover root test suite
run: |
sudo -n xcrun swift test list --scratch-path "${GITHUB_WORKSPACE}/.build-root" > "$RUNNER_TEMP/root-list.txt"
count="$(grep -c "${ROOT_SUITE}/" "$RUNNER_TEMP/root-list.txt" || true)"
echo "discovered ${count} ${ROOT_SUITE} test(s)"
[ "${count:-0}" -ge 1 ] || { echo "::error::${ROOT_SUITE} not found"; cat "$RUNNER_TEMP/root-list.txt"; exit 1; }

- name: Run root test suite
run: sudo -n xcrun swift test --scratch-path "${GITHUB_WORKSPACE}/.build-root" --filter "$ROOT_SUITE"

- name: Clean up root test suite
if: always()
run: sudo -n rm -rf "${GITHUB_WORKSPACE}/.build-root" || true
17 changes: 11 additions & 6 deletions Tests/SubprocessTests/UnixTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ import System
import SystemPackage
#endif

@Suite(.serialized)
struct SubprocessUnixRootTests {
init() {
_ = globallyIgnoredSIGPIPE
}
}

@Suite(.serialized)
struct SubprocessUnixTests {
init() {
Expand All @@ -42,8 +49,7 @@ struct SubprocessUnixTests {
}

// MARK: - PlatformOption Tests
extension SubprocessUnixTests {
// Run this test with sudo
extension SubprocessUnixRootTests {
@Test(
.enabled(
if: getgid() == 0,
Expand All @@ -61,7 +67,6 @@ extension SubprocessUnixTests {
)
}

// Run this test with sudo
@Test(
.enabled(
if: getgid() == 0,
Expand All @@ -79,7 +84,6 @@ extension SubprocessUnixTests {
)
}

// Run this test with sudo
@Test(
.enabled(
if: getgid() == 0,
Expand Down Expand Up @@ -107,7 +111,6 @@ extension SubprocessUnixTests {
)
}

// Run this test with sudo
@Test(
.enabled(
if: getgid() == 0,
Expand Down Expand Up @@ -171,7 +174,9 @@ extension SubprocessUnixTests {
// PGID should == PID
#expect(match.output.pid == match.output.pgid)
}
}

extension SubprocessUnixTests {
@Test(
.enabled(
"This test requires ps (install procps package on Debian or RedHat Linux distros)",
Expand Down Expand Up @@ -893,7 +898,7 @@ extension SubprocessUnixTests {
}

// MARK: - Utils
extension SubprocessUnixTests {
extension SubprocessUnixRootTests {
private func assertID(
withArgument argument: String,
platformOptions: PlatformOptions,
Expand Down
Loading