Skip to content

Commit 9f992cc

Browse files
committed
internal imports by default, only enable warnings as errors in CI
1 parent 3cdb9f4 commit 9f992cc

29 files changed

+89
-47
lines changed

.github/workflows/Documentation.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ jobs:
1515
name: Ubuntu 24.04
1616

1717
steps:
18-
- name: Install Swift
18+
- name: 🤍 Install Swift 🤍
1919
uses: tayloraswift/swift-install-action@master
2020
with:
2121
swift-prefix: "swift-6.2.4-release/ubuntu2404/swift-6.2.4-RELEASE"
2222
swift-id: "swift-6.2.4-RELEASE-ubuntu24.04"
2323

24-
- name: Install Unidoc
24+
- name: 🤍 Install Unidoc 🤍
2525
uses: tayloraswift/swift-unidoc-action@master
2626

2727
# This clobbers everything in the current directory!
28-
- name: Checkout repository
29-
uses: actions/checkout@v3
28+
- name: 🤍 Checkout repository 🤍
29+
uses: actions/checkout@v6
3030

31-
- name: Validate documentation
31+
- name: 🤍 Validate documentation 🤍
3232
run: |
3333
unidoc compile \
3434
--swift-toolchain $SWIFT_INSTALLATION \
@@ -39,16 +39,16 @@ jobs:
3939
runs-on: macos-26
4040
name: macOS
4141
steps:
42-
- name: Install Unidoc
42+
- name: 🤍 Install Unidoc 🤍
4343
uses: tayloraswift/swift-unidoc-action@master
4444

45-
- name: Checkout repository
46-
uses: actions/checkout@v3
45+
- name: 🤍 Checkout repository 🤍
46+
uses: actions/checkout@v6
4747

48-
- name: Select Xcode 26.3
48+
- name: 🤍 Select Xcode 26.3 🤍
4949
run: sudo xcode-select -s /Applications/Xcode_26.3.app/Contents/Developer
5050

51-
- name: Validate documentation
51+
- name: 🤍 Validate documentation 🤍
5252
run: |
5353
unidoc build \
5454
--ci fail-on-errors \

.github/workflows/Tests.yml

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,56 @@ on:
77
branches: [ master ]
88

99
jobs:
10+
changes:
11+
runs-on: ubuntu-latest
12+
name: Assess changes
13+
steps:
14+
- name: 💖 Checkout repository 💖
15+
uses: actions/checkout@v6
16+
17+
- name: 💖 Decide checks 💖
18+
uses: tj-actions/changed-files@v47
19+
id: changes
20+
with:
21+
files_ignore: |
22+
README.md
23+
LICENSE
24+
NOTICE
25+
.mailmap
26+
.gitignore
27+
.github/FUNDING.yml
28+
outputs:
29+
code_changed: ${{ steps.changes.outputs.any_changed }}
30+
1031
linux:
1132
runs-on: ubuntu-24.04
1233
name: Ubuntu 24.04
34+
needs: changes
35+
if: ${{ needs.changes.outputs.code_changed == 'true' }}
1336
steps:
14-
- name: Install Swift
37+
- name: 💖 Install Swift 💖
1538
uses: tayloraswift/swift-install-action@master
1639
with:
1740
swift-prefix: "swift-6.2.4-release/ubuntu2404/swift-6.2.4-RELEASE"
1841
swift-id: "swift-6.2.4-RELEASE-ubuntu24.04"
1942

20-
- name: Checkout repository
21-
uses: actions/checkout@v3
43+
- name: 💖 Checkout repository 💖
44+
uses: actions/checkout@v6
2245

23-
- name: Run tests
46+
- name: 💖 Run tests 💖
2447
run: Scripts/TestAll
2548

2649
macos:
2750
runs-on: macos-26
2851
name: macOS
52+
needs: changes
53+
if: ${{ needs.changes.outputs.code_changed == 'true' }}
2954
steps:
30-
- name: Checkout repository
31-
uses: actions/checkout@v3
55+
- name: 💖 Checkout repository 💖
56+
uses: actions/checkout@v6
3257

33-
- name: Select Xcode 26.3
58+
- name: 💖 Select Xcode 26.3 💖
3459
run: sudo xcode-select -s /Applications/Xcode_26.3.app/Contents/Developer
3560

36-
- name: Run tests
61+
- name: 💖 Run tests 💖
3762
run: Scripts/TestAll

Package.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// swift-tools-version:6.2
2+
import class Foundation.ProcessInfo
23
import PackageDescription
34

45
let package: Package = .init(
@@ -85,6 +86,14 @@ let package: Package = .init(
8586
),
8687
]
8788
)
89+
90+
var WarningsAsErrors: Bool {
91+
switch ProcessInfo.processInfo.environment["WARNINGS_AS_ERRORS"] {
92+
case "true"?: true
93+
case "1"?: true
94+
default: false
95+
}
96+
}
8897
package.targets = package.targets.map {
8998
switch $0.type {
9099
case .plugin: return $0
@@ -95,8 +104,12 @@ package.targets = package.targets.map {
95104
var settings: [SwiftSetting] = $0 ?? []
96105

97106
settings.append(.enableUpcomingFeature("ExistentialAny"))
98-
settings.append(.treatWarning("ExistentialAny", as: .error))
99-
settings.append(.treatWarning("MutableGlobalVariable", as: .error))
107+
settings.append(.enableUpcomingFeature("InternalImportsByDefault"))
108+
109+
if WarningsAsErrors {
110+
settings.append(.treatWarning("ExistentialAny", as: .error))
111+
settings.append(.treatWarning("MutableGlobalVariable", as: .error))
112+
}
100113

101114
$0 = settings
102115
} (&$0.swiftSettings)

Scripts/TestAll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
2-
set -e
2+
set -euo pipefail
3+
4+
export WARNINGS_AS_ERRORS=1
5+
36
swift --version
47
swift test
5-
swift build -c release
8+
swift build -c release \
9+
--explicit-target-dependency-import-check=error

Sources/JSONDecoding/Decoding/JSON.DecodingError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import TraceableErrors
1+
public import TraceableErrors
22

33
extension JSON {
44
/// An error occurred while decoding a document field.

Sources/JSONParsing/JSON.Array (ext).swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Grammar
1+
internal import Grammar
22
import JSONAST
33

44
extension JSON.Array {

Sources/JSONParsing/JSON.Node (ext).swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Grammar
1+
internal import Grammar
22
import JSONAST
33

44
extension JSON.Node {

Sources/JSONParsing/JSON.Object (ext).swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Grammar
1+
internal import Grammar
22
import JSONAST
33

44
extension JSON.Object {

Sources/JSONParsing/Rules/JSON (ext).swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Grammar
1+
internal import Grammar
22

33
extension JSON {
44
typealias CommaRule<Location> =

Sources/JSONParsing/Rules/JSON.NodeRule.Array.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Grammar
1+
internal import Grammar
22

33
extension JSON.NodeRule {
44
/// Matches an array literal.

0 commit comments

Comments
 (0)