diff --git a/.github/scripts/prebuild.ps1 b/.github/scripts/prebuild.ps1 new file mode 100644 index 000000000..8c96dba05 --- /dev/null +++ b/.github/scripts/prebuild.ps1 @@ -0,0 +1,29 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift open source project +## +## Copyright (c) 2025 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See http://swift.org/LICENSE.txt for license information +## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## + +param ( + [switch]$InstallCMake +) + +# winget isn't easily made available in containers, so use chocolatey +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')) + +if ($InstallCMake) { + choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System' --apply-install-arguments-to-dependencies + choco install -y ninja + + Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 + refreshenv + + # Let swiftc find the path to link.exe in the CMake smoke test + $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)" +} diff --git a/.github/scripts/prebuild.sh b/.github/scripts/prebuild.sh new file mode 100755 index 000000000..b92d2d606 --- /dev/null +++ b/.github/scripts/prebuild.sh @@ -0,0 +1,57 @@ +#!/bin/bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift open source project +## +## Copyright (c) 2025 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See http://swift.org/LICENSE.txt for license information +## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## + +set -e + +if [[ $(uname) == Darwin ]] ; then + if [[ "$INSTALL_CMAKE" == "1" ]] ; then + mkdir -p "$RUNNER_TOOL_CACHE" + if ! command -v cmake >/dev/null 2>&1 ; then + curl -fsSLO https://github.com/Kitware/CMake/releases/download/v4.1.2/cmake-4.1.2-macos-universal.tar.gz + echo '3be85f5b999e327b1ac7d804cbc9acd767059e9f603c42ec2765f6ab68fbd367 cmake-4.1.2-macos-universal.tar.gz' > cmake-4.1.2-macos-universal.tar.gz.sha256 + sha256sum -c cmake-4.1.2-macos-universal.tar.gz.sha256 + tar -xf cmake-4.1.2-macos-universal.tar.gz + ln -s "$PWD/cmake-4.1.2-macos-universal/CMake.app/Contents/bin/cmake" "$RUNNER_TOOL_CACHE/cmake" + fi + if ! command -v ninja >/dev/null 2>&1 ; then + curl -fsSLO https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-mac.zip + echo 'da7797794153629aca5570ef7c813342d0be214ba84632af886856e8f0063dd9 ninja-mac.zip' > ninja-mac.zip.sha256 + sha256sum -c ninja-mac.zip.sha256 + unzip ninja-mac.zip + rm -f ninja-mac.zip + mv ninja "$RUNNER_TOOL_CACHE/ninja" + fi + fi +elif command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy + export DEBIAN_FRONTEND=noninteractive + + apt-get update -y + + # Debug symbols + apt-get install -y libc6-dbg + + if [[ "$INSTALL_CMAKE" == "1" ]] ; then + apt-get install -y cmake ninja-build + fi +elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9 + dnf update -y + + # Debug symbols + dnf debuginfo-install -y glibc +elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2 + yum update -y + + # Debug symbols + yum install -y yum-utils + debuginfo-install -y glibc +fi diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 000000000..2f2adae66 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,49 @@ +name: Pull request + +permissions: + contents: read + +on: + pull_request: + types: [opened, reopened, synchronize] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + name: Test + uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main + with: + linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]' + linux_pre_build_command: ./.github/scripts/prebuild.sh + linux_swift_versions: '["nightly-main", "nightly-6.2"]' + windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1' + windows_swift_versions: '["nightly-main"]' + enable_linux_static_sdk_build: true + enable_macos_checks: true + macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]" + macos_pre_build_command: ./.github/scripts/prebuild.sh + cmake-smoke-test: + name: cmake-smoke-test + uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main + with: + linux_os_versions: '["noble"]' + linux_pre_build_command: INSTALL_CMAKE=1 ./.github/scripts/prebuild.sh + 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`' + linux_swift_versions: '["nightly-main"]' + enable_macos_checks: true + macos_xcode_versions: '["26.0"]' + macos_pre_build_command: INSTALL_CMAKE=1 ./.github/scripts/prebuild.sh + 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`' + windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1 -InstallCMake' + windows_swift_versions: '["nightly-main"]' + 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"' + + soundness: + name: Soundness + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main + with: + license_header_check_project_name: "Swift" + api_breakage_check_enabled: false