Skip to content

Commit c3c3106

Browse files
authored
[CI] GitHub Actions support for PR testing and automerger (#526)
* [CI] GitHub Actions support for PR testing and automerger * Fix python lint failures * Drop License header check and unacceptable lang from GitHub Actions * Don't run linux test in parallel * Update the linux actions to build only for now. * Split up the line to avoid length issue with python linter * Only build for Windows and disable the static sdk for now
1 parent dc45701 commit c3c3106

File tree

3 files changed

+92
-8
lines changed

3 files changed

+92
-8
lines changed

.github/workflows/automerge.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Create PR to merge release into main branch
2+
# In the first period after branching the release branch,
3+
# we typically want to include many changes from `main` in the release branch.
4+
# This workflow automatically creates a PR to merge the release branch into the main.
5+
# Later in the release cycle we should stop this practice to avoid landing risky changes by disabling this workflow.
6+
# To do so, disable the workflow as described in https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/disabling-and-enabling-a-workflow
7+
permissions:
8+
contents: read
9+
on:
10+
schedule:
11+
- cron: '0 9 * * MON'
12+
workflow_dispatch:
13+
jobs:
14+
create_merge_pr:
15+
name: Create PR to merge release into main branch
16+
uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@main
17+
with:
18+
head_branch: release/6.3
19+
base_branch: main
20+
permissions:
21+
contents: write
22+
pull-requests: write
23+
if: (github.event_name == 'schedule' && github.repository == 'swiftlang/swift-tools-support-core') || (github.event_name != 'schedule') # Ensure that we don't run this on a schedule in a fork

.github/workflows/pull_request.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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_swift_versions: '["nightly-main", "nightly-6.2"]'
21+
linux_build_command: 'swift build'
22+
windows_swift_versions: '["nightly-main"]'
23+
windows_build_command: 'Invoke-Program swift build'
24+
enable_android_sdk_build: true
25+
android_sdk_build_command: "swift build --build-tests"
26+
android_ndk_versions: '["r27d", "r29"]'
27+
enable_ios_checks: true
28+
enable_macos_checks: true
29+
macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]"
30+
31+
soundness:
32+
name: Soundness
33+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
34+
with:
35+
license_header_check_project_name: "Swift.org"
36+
license_header_check_enabled: false
37+
unacceptable_language_check_enabled: false
38+
api_breakage_check_enabled: false
39+
format_check_enabled: false

Utilities/build-script-helper.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,24 @@
1515
from __future__ import print_function
1616

1717
import argparse
18-
import json
18+
import errno
1919
import os
2020
import platform
21-
import re
22-
import shutil
23-
import subprocess
2421
import subprocess
2522
import sys
26-
import errno
23+
2724

2825
def note(message):
2926
print("--- %s: note: %s" % (os.path.basename(sys.argv[0]), message))
3027
sys.stdout.flush()
3128

29+
3230
def error(message):
3331
print("--- %s: error: %s" % (os.path.basename(sys.argv[0]), message))
3432
sys.stdout.flush()
3533
raise SystemExit(1)
3634

35+
3736
def mkdir_p(path):
3837
"""Create the given directory, if it does not exist."""
3938
try:
@@ -43,6 +42,7 @@ def mkdir_p(path):
4342
if e.errno != errno.EEXIST:
4443
raise
4544

45+
4646
def call(cmd, cwd=None, verbose=False):
4747
"""Calls a subprocess."""
4848
if verbose:
@@ -54,17 +54,22 @@ def call(cmd, cwd=None, verbose=False):
5454
print(' '.join(cmd))
5555
error(str(e))
5656

57+
5758
def call_output(cmd, cwd=None, stderr=False, verbose=False):
5859
"""Calls a subprocess for its return data."""
5960
if verbose:
6061
print(' '.join(cmd))
6162
try:
62-
return subprocess.check_output(cmd, cwd=cwd, stderr=stderr, universal_newlines=True).strip()
63+
return subprocess.check_output(cmd,
64+
cwd=cwd,
65+
stderr=stderr,
66+
universal_newlines=True).strip()
6367
except Exception as e:
6468
if not verbose:
6569
print(' '.join(cmd))
6670
error(str(e))
6771

72+
6873
def main():
6974
parser = argparse.ArgumentParser(description="""
7075
This script will build a TSC using CMake.
@@ -84,6 +89,7 @@ def main():
8489
# Argument parsing
8590
# -----------------------------------------------------------
8691

92+
8793
def add_global_args(parser):
8894
"""Configures the parser with the arguments necessary for all actions."""
8995
parser.add_argument(
@@ -100,6 +106,7 @@ def add_global_args(parser):
100106
action="store_true",
101107
help="whether to always reconfigure cmake")
102108

109+
103110
def add_build_args(parser):
104111
"""Configures the parser with the arguments necessary for build-related actions."""
105112
add_global_args(parser)
@@ -116,16 +123,22 @@ def add_build_args(parser):
116123
metavar='PATH',
117124
help='path to the ninja binary to use for building with CMake')
118125

126+
119127
def parse_global_args(args):
120128
"""Parses and cleans arguments necessary for all actions."""
121129
args.build_dir = os.path.abspath(args.build_dir)
122130
args.project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
123131

124132
if platform.system() == 'Darwin':
125-
args.sysroot = call_output(["xcrun", "--sdk", "macosx", "--show-sdk-path"], verbose=args.verbose)
133+
args.sysroot = call_output(["xcrun",
134+
"--sdk",
135+
"macosx",
136+
"--show-sdk-path"],
137+
verbose=args.verbose)
126138
else:
127139
args.sysroot = None
128140

141+
129142
def parse_build_args(args):
130143
"""Parses and cleans arguments necessary for build-related actions."""
131144
parse_global_args(args)
@@ -134,6 +147,7 @@ def parse_build_args(args):
134147
args.cmake_path = get_cmake_path(args)
135148
args.ninja_path = get_ninja_path(args)
136149

150+
137151
def get_swiftc_path(args):
138152
"""Returns the path to the Swift compiler."""
139153
if args.swiftc_path:
@@ -154,6 +168,7 @@ def get_swiftc_path(args):
154168

155169
return swiftc_path
156170

171+
157172
def get_cmake_path(args):
158173
"""Returns the path to CMake."""
159174
if args.cmake_path:
@@ -167,6 +182,7 @@ def get_cmake_path(args):
167182
else:
168183
return call_output(["which", "cmake"], verbose=args.verbose)
169184

185+
170186
def get_ninja_path(args):
171187
"""Returns the path to Ninja."""
172188
if args.ninja_path:
@@ -184,6 +200,7 @@ def get_ninja_path(args):
184200
# Actions
185201
# -----------------------------------------------------------
186202

203+
187204
def build(args):
188205
parse_build_args(args)
189206
build_tsc(args)
@@ -192,10 +209,13 @@ def build(args):
192209
# Build functions
193210
# -----------------------------------------------------------
194211

212+
195213
def build_with_cmake(args, cmake_args, source_path, build_dir):
196214
"""Runs CMake if needed, then builds with Ninja."""
197215
cache_path = os.path.join(build_dir, "CMakeCache.txt")
198-
if args.reconfigure or not os.path.isfile(cache_path) or not args.swiftc_path in open(cache_path).read():
216+
if args.reconfigure or \
217+
not os.path.isfile(cache_path) \
218+
or args.swiftc_path not in open(cache_path).read():
199219
swift_flags = ""
200220
if args.sysroot:
201221
swift_flags = "-sdk %s" % args.sysroot
@@ -222,6 +242,7 @@ def build_with_cmake(args, cmake_args, source_path, build_dir):
222242

223243
call(ninja_cmd, cwd=build_dir, verbose=args.verbose)
224244

245+
225246
def build_tsc(args):
226247
cmake_flags = []
227248
if platform.system() == 'Darwin':
@@ -230,5 +251,6 @@ def build_tsc(args):
230251

231252
build_with_cmake(args, cmake_flags, args.project_root, args.build_dir)
232253

254+
233255
if __name__ == '__main__':
234256
main()

0 commit comments

Comments
 (0)