Skip to content

Commit 5866c31

Browse files
committed
GitHub actions CI workflows
1 parent 30084e9 commit 5866c31

File tree

3 files changed

+135
-0
lines changed

3 files changed

+135
-0
lines changed

.github/scripts/prebuild.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
##===----------------------------------------------------------------------===##
2+
##
3+
## This source file is part of the Swift open source project
4+
##
5+
## Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
## Licensed under Apache License v2.0 with Runtime Library Exception
7+
##
8+
## See http://swift.org/LICENSE.txt for license information
9+
## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
##
11+
##===----------------------------------------------------------------------===##
12+
13+
param (
14+
[switch]$InstallCMake
15+
)
16+
17+
# winget isn't easily made available in containers, so use chocolatey
18+
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
19+
20+
if ($InstallCMake) {
21+
choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System' --apply-install-arguments-to-dependencies
22+
choco install -y ninja
23+
24+
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
25+
refreshenv
26+
27+
# Let swiftc find the path to link.exe in the CMake smoke test
28+
$env:Path += ";$(Split-Path -Path "$(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" "-latest" -products Microsoft.VisualStudio.Product.BuildTools -find VC\Tools\MSVC\*\bin\HostX64\x64\link.exe)" -Parent)"
29+
}

.github/scripts/prebuild.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the Swift open source project
5+
##
6+
## Copyright (c) 2025 Apple Inc. and the Swift project authors
7+
## Licensed under Apache License v2.0 with Runtime Library Exception
8+
##
9+
## See http://swift.org/LICENSE.txt for license information
10+
## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
11+
##
12+
##===----------------------------------------------------------------------===##
13+
14+
set -e
15+
16+
if [[ $(uname) == Darwin ]] ; then
17+
if [[ "$INSTALL_CMAKE" == "1" ]] ; then
18+
mkdir -p "$RUNNER_TOOL_CACHE"
19+
if ! command -v cmake >/dev/null 2>&1 ; then
20+
curl -fsSLO https://github.com/Kitware/CMake/releases/download/v4.1.2/cmake-4.1.2-macos-universal.tar.gz
21+
echo '3be85f5b999e327b1ac7d804cbc9acd767059e9f603c42ec2765f6ab68fbd367 cmake-4.1.2-macos-universal.tar.gz' > cmake-4.1.2-macos-universal.tar.gz.sha256
22+
sha256sum -c cmake-4.1.2-macos-universal.tar.gz.sha256
23+
tar -xf cmake-4.1.2-macos-universal.tar.gz
24+
ln -s "$PWD/cmake-4.1.2-macos-universal/CMake.app/Contents/bin/cmake" "$RUNNER_TOOL_CACHE/cmake"
25+
fi
26+
if ! command -v ninja >/dev/null 2>&1 ; then
27+
curl -fsSLO https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-mac.zip
28+
echo 'da7797794153629aca5570ef7c813342d0be214ba84632af886856e8f0063dd9 ninja-mac.zip' > ninja-mac.zip.sha256
29+
sha256sum -c ninja-mac.zip.sha256
30+
unzip ninja-mac.zip
31+
rm -f ninja-mac.zip
32+
mv ninja "$RUNNER_TOOL_CACHE/ninja"
33+
fi
34+
fi
35+
elif command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy
36+
export DEBIAN_FRONTEND=noninteractive
37+
38+
apt-get update -y
39+
40+
# Debug symbols
41+
apt-get install -y libc6-dbg
42+
43+
if [[ "$INSTALL_CMAKE" == "1" ]] ; then
44+
apt-get install -y cmake ninja-build
45+
fi
46+
elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9
47+
dnf update -y
48+
49+
# Debug symbols
50+
dnf debuginfo-install -y glibc
51+
elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2
52+
yum update -y
53+
54+
# Debug symbols
55+
yum install -y yum-utils
56+
debuginfo-install -y glibc
57+
fi

.github/workflows/pull_request.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Pull request
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request:
8+
types: [opened, reopened, synchronize]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
tests:
16+
name: Test
17+
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
18+
with:
19+
linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]'
20+
linux_pre_build_command: ./.github/scripts/prebuild.sh
21+
linux_swift_versions: '["nightly-main", "nightly-6.2"]'
22+
windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1'
23+
windows_swift_versions: '["nightly-main"]'
24+
enable_linux_static_sdk_build: true
25+
enable_macos_checks: true
26+
macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]"
27+
macos_pre_build_command: ./.github/scripts/prebuild.sh
28+
cmake-smoke-test:
29+
name: cmake-smoke-test
30+
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
31+
with:
32+
linux_os_versions: '["noble"]'
33+
linux_pre_build_command: INSTALL_CMAKE=1 ./.github/scripts/prebuild.sh
34+
linux_build_command: 'swift package -Xbuild-tools-swiftc -DUSE_PROCESS_SPAWNING_WORKAROUND cmake-smoke-test --disable-sandbox --cmake-path `which cmake` --ninja-path `which ninja` --extra-cmake-arg -DCMAKE_C_COMPILER=`which clang` --extra-cmake-arg -DCMAKE_CXX_COMPILER=`which clang++` --extra-cmake-arg -DCMAKE_Swift_COMPILER=`which swiftc`'
35+
linux_swift_versions: '["nightly-main"]'
36+
enable_macos_checks: true
37+
macos_xcode_versions: '["26.0"]'
38+
macos_pre_build_command: INSTALL_CMAKE=1 ./.github/scripts/prebuild.sh
39+
macos_build_command: 'export PATH=$PATH:$RUNNER_TOOL_CACHE && swift package cmake-smoke-test --disable-sandbox --cmake-path `which cmake` --ninja-path `which ninja` --extra-cmake-arg -DCMAKE_C_COMPILER=`which clang` --extra-cmake-arg -DCMAKE_CXX_COMPILER=`which clang++` --extra-cmake-arg -DCMAKE_Swift_COMPILER=`which swiftc`'
40+
windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1 -InstallCMake'
41+
windows_swift_versions: '["nightly-main"]'
42+
windows_build_command: 'Invoke-Program swift package cmake-smoke-test --disable-sandbox --cmake-path (Get-Command cmake).Path --ninja-path (Get-Command ninja).Path --extra-cmake-arg "-DCMAKE_C_COMPILER=$((Get-Command clang).Path)" --extra-cmake-arg "-DCMAKE_CXX_COMPILER=$((Get-Command clang).Path)" --extra-cmake-arg "-DCMAKE_Swift_COMPILER=$((Get-Command swiftc).Path)" --extra-cmake-arg "-DCMAKE_STATIC_LIBRARY_PREFIX_Swift=lib" --extra-cmake-arg "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL"'
43+
44+
soundness:
45+
name: Soundness
46+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
47+
with:
48+
license_header_check_project_name: "Swift"
49+
api_breakage_check_enabled: false

0 commit comments

Comments
 (0)