Skip to content

Commit 3abb067

Browse files
committed
Merge branch 'main' into remove-scripts
2 parents c8ac780 + 71f8d49 commit 3abb067

File tree

208 files changed

+42158
-10883
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+42158
-10883
lines changed

.github/workflows/pull_request.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Pull request
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
jobs:
8+
tests:
9+
name: Test
10+
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
11+
with:
12+
linux_exclude_swift_versions: '[{"swift_version": "5.9"}, {"swift_version": "5.10"}]'
13+
enable_windows_checks: false
14+
enable_macos_checks: false
15+
soundness:
16+
name: Soundness
17+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
18+
with:
19+
license_header_check_project_name: "Swift.org"
20+
unacceptable_language_check_enabled: false
21+
format_check_enabled: false
22+
bench:
23+
name: Benchmark
24+
runs-on: ubuntu-latest
25+
env:
26+
BUILD_CMD: swift build -c release
27+
BENCH_CMD: .build/release/RegexBenchmark
28+
BASELINE_FILE: benchmark-baseline
29+
COMPARE_FILE: benchmark-pr
30+
COMPARE_OUT_FILE: benchmark-results.txt
31+
steps:
32+
- name: Check out baseline branch
33+
uses: actions/checkout@v4
34+
with:
35+
ref: ${{ github.event.pull_request.base.sha }}
36+
path: base
37+
fetch-depth: 0
38+
- name: Build baseline branch
39+
working-directory: base
40+
run: |
41+
set -euo pipefail
42+
eval "$BUILD_CMD"
43+
- name: Run baseline benchmark
44+
working-directory: base
45+
run: |
46+
set -euo pipefail
47+
eval "$BENCH_CMD --save $RUNNER_TEMP/$BASELINE_FILE"
48+
test -s "$RUNNER_TEMP/$BASELINE_FILE" || { echo "Baseline not created at $BASELINE_FILE"; exit 1; }
49+
- name: Check out PR branch
50+
uses: actions/checkout@v4
51+
with:
52+
ref: ${{ github.event.pull_request.head.sha }}
53+
path: pr
54+
fetch-depth: 0
55+
- name: Build PR branch
56+
working-directory: pr
57+
run: |
58+
set -euo pipefail
59+
eval "$BUILD_CMD"
60+
- name: Run PR benchmark
61+
working-directory: pr
62+
run: |
63+
set -euo pipefail
64+
eval "$BENCH_CMD --save $RUNNER_TEMP/$COMPARE_FILE"
65+
test -s "$RUNNER_TEMP/$COMPARE_FILE" || { echo "Comparison not created at $COMPARE_FILE"; exit 1; }
66+
eval "$BENCH_CMD --compare $RUNNER_TEMP/$BASELINE_FILE" | tee "$RUNNER_TEMP/$COMPARE_OUT_FILE"
67+
- name: 📊 Compare benchmarks
68+
working-directory: pr
69+
run: |
70+
set -euo pipefail
71+
eval "$BENCH_CMD --load $RUNNER_TEMP/$COMPARE_FILE --compare $RUNNER_TEMP/$BASELINE_FILE --compare-compile-time $RUNNER_TEMP/$BASELINE_FILE" | tee "$RUNNER_TEMP/$COMPARE_OUT_FILE"
72+
- name: Upload benchmark artifacts
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: benchmark-results
76+
path: |
77+
${{ runner.temp }}/${{ env.BASELINE_FILE }}
78+
${{ runner.temp }}/${{ env.COMPARE_FILE }}
79+
${{ runner.temp }}/${{ env.COMPARE_OUT_FILE }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,6 @@ fastlane/test_output
9393
# https://github.com/johnno1962/injectionforxcode
9494

9595
iOSInjectionProject/
96+
97+
# DocC build folder
98+
*.docc-build

.license_header_template

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@@===----------------------------------------------------------------------===@@
2+
@@
3+
@@ This source file is part of the Swift.org open source project
4+
@@
5+
@@ Copyright (c) YEARS Apple Inc. and the Swift project authors
6+
@@ Licensed under Apache License v2.0 with Runtime Library Exception
7+
@@
8+
@@ See https://swift.org/LICENSE.txt for license information
9+
@@
10+
@@===----------------------------------------------------------------------===@@

.licenseignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.gitignore
2+
**/.gitignore
3+
.licenseignore
4+
.gitattributes
5+
.git-blame-ignore-revs
6+
.mailfilter
7+
.mailmap
8+
.spi.yml
9+
.swift-format
10+
.editorconfig
11+
.github/*
12+
.build
13+
*.py
14+
*.yml
15+
*.yaml
16+
*.cmake
17+
*.cmake.in
18+
Package.swift
19+
**/Package.swift
20+
Package@*.swift
21+
**/Package@*.swift
22+
Package.resolved
23+
**/Package.resolved
24+
.unacceptablelanguageignore
25+
-a*/Snapshots/*

CMakeLists.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

Documentation/ProgrammersManual.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Programmer's Manual
2+
3+
## Programming patterns
4+
5+
### Engine quick checks and fast paths
6+
7+
In the engine nomenclature, a quick-check results in a yes/no/maybe while a thorough check always results in a definite answer.
8+
9+
The nature of quick checks and fast paths is that they bifurcate testing coverage. One easy way to prevent this in simple cases is to assert that a definite quick result matches the thorough result.
10+
11+
One example of this pattern is matching against a builtin character class. The engine has a `_matchBuiltinCC`
12+
13+
```swift
14+
func _matchBuiltinCC(...) -> Input.Index? {
15+
// Calls _quickMatchBuiltinCC, if that gives a definite result
16+
// asserts that it is the same as the result of
17+
// _thoroughMatchBuiltinCC and returns it. Otherwise returns the
18+
// result of _thoroughMatchBuiltinCC
19+
}
20+
21+
@inline(__always)
22+
func _quickMatchBuiltinCC(...) -> QuickResult<Input.Index?>
23+
24+
@inline(never)
25+
func _thoroughMatchBuiltinCC(...) -> Input.Index?
26+
```
27+
28+
The thorough check is never inlined, as it is a lot of cold code. Note that quick and thorough functions should be pure, that is they shouldn't update processor state.
29+
30+

Package.swift

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,23 @@ let availabilityDefinition = PackageDescription.SwiftSetting.unsafeFlags([
77
"-Xfrontend",
88
"-define-availability",
99
"-Xfrontend",
10-
"SwiftStdlib 5.7:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999",
10+
"SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0",
11+
"-Xfrontend",
12+
"-define-availability",
13+
"-Xfrontend",
14+
"SwiftStdlib 5.8:macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4",
15+
"-Xfrontend",
16+
"-define-availability",
17+
"-Xfrontend",
18+
"SwiftStdlib 5.9:macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0",
19+
"-Xfrontend",
20+
"-define-availability",
21+
"-Xfrontend",
22+
"SwiftStdlib 5.10:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999",
23+
"-Xfrontend",
24+
"-define-availability",
25+
"-Xfrontend",
26+
"SwiftStdlib 6.0:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999",
1127
])
1228

1329
/// Swift settings for building a private stdlib-like module that is to be used
@@ -32,15 +48,20 @@ let package = Package(
3248
.library(
3349
name: "_StringProcessing",
3450
targets: ["_StringProcessing"]),
35-
.library(
36-
name: "Prototypes",
37-
targets: ["Prototypes"]),
51+
// FIXME: Disabled due to rdar://94763190.
52+
// .library(
53+
// name: "Prototypes",
54+
// targets: ["Prototypes"]),
3855
.library(
3956
name: "_RegexParser",
4057
targets: ["_RegexParser"]),
4158
.executable(
4259
name: "VariadicsGenerator",
43-
targets: ["VariadicsGenerator"])
60+
targets: ["VariadicsGenerator"]),
61+
// Disable to work around rdar://126877024
62+
.executable(
63+
name: "RegexBenchmark",
64+
targets: ["RegexBenchmark"])
4465
],
4566
dependencies: [
4667
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
@@ -67,24 +88,35 @@ let package = Package(
6788
name: "RegexBuilder",
6889
dependencies: ["_StringProcessing", "_RegexParser"],
6990
swiftSettings: publicStdlibSettings),
91+
.target(name: "TestSupport",
92+
swiftSettings: [availabilityDefinition]),
7093
.testTarget(
7194
name: "RegexTests",
72-
dependencies: ["_StringProcessing"],
95+
dependencies: ["_StringProcessing", "RegexBuilder", "TestSupport"],
7396
swiftSettings: [
74-
.unsafeFlags(["-Xfrontend", "-disable-availability-checking"]),
97+
availabilityDefinition
7598
]),
7699
.testTarget(
77100
name: "RegexBuilderTests",
78-
dependencies: ["_StringProcessing", "RegexBuilder"],
101+
dependencies: ["_StringProcessing", "RegexBuilder", "TestSupport"],
79102
swiftSettings: [
80-
.unsafeFlags(["-Xfrontend", "-disable-availability-checking"])
103+
availabilityDefinition
81104
]),
82105
.testTarget(
83-
name: "Prototypes",
84-
dependencies: ["_RegexParser", "_StringProcessing"],
106+
name: "DocumentationTests",
107+
dependencies: ["_StringProcessing", "RegexBuilder"],
85108
swiftSettings: [
86-
.unsafeFlags(["-Xfrontend", "-disable-availability-checking"])
109+
availabilityDefinition,
110+
.unsafeFlags(["-enable-bare-slash-regex"]),
87111
]),
112+
113+
// FIXME: Disabled due to rdar://94763190.
114+
// .testTarget(
115+
// name: "Prototypes",
116+
// dependencies: ["_RegexParser", "_StringProcessing"],
117+
// swiftSettings: [
118+
// .unsafeFlags(["-Xfrontend", "-disable-availability-checking"])
119+
// ]),
88120

89121
// MARK: Scripts
90122
.executableTarget(
@@ -105,6 +137,18 @@ let package = Package(
105137
.product(name: "ArgumentParser", package: "swift-argument-parser"),
106138
"_RegexParser",
107139
"_StringProcessing"
140+
],
141+
swiftSettings: [availabilityDefinition]),
142+
.executableTarget(
143+
name: "RegexBenchmark",
144+
dependencies: [
145+
.product(name: "ArgumentParser", package: "swift-argument-parser"),
146+
"_RegexParser",
147+
"_StringProcessing",
148+
"RegexBuilder"
149+
],
150+
swiftSettings: [
151+
.unsafeFlags(["-Xfrontend", "-disable-availability-checking"]),
108152
]),
109153

110154
// MARK: Exercises

0 commit comments

Comments
 (0)