Skip to content

Commit 7f13111

Browse files
authored
Upgrade to Pkl 0.30, enforce formatting (#82)
1 parent eec5948 commit 7f13111

Some content is hidden

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

42 files changed

+960
-771
lines changed

.circleci/config.pkl

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import "pkl:semver"
1919

2020
local swiftTest = new RunStep {
2121
name = "swift test"
22-
command = """
22+
command =
23+
"""
2324
mkdir -p .out/test-results/
2425
swift test -vv --parallel --num-workers 1 --xunit-output .out/test-results/xunit.xml -Xswiftc -warnings-as-errors
2526
"""
@@ -33,11 +34,13 @@ local class PklDistribution {
3334
fixed normalizedVersion: String = version.replaceAll(".", "-")
3435

3536
/// The URL to download this distribution
36-
fixed downloadUrl: String = "https://github.com/apple/pkl/releases/download/\(version)/pkl-linux-amd64"
37+
fixed downloadUrl: String =
38+
"https://github.com/apple/pkl/releases/download/\(version)/pkl-linux-amd64"
3739

3840
fixed downloadRunStep: RunStep = new {
3941
name = "Downloading pkl-\(version)"
40-
command = """
42+
command =
43+
"""
4144
PKL=$(mktemp /tmp/pkl-\(version)-XXXXXX)
4245
curl -L "\(downloadUrl)" > $PKL
4346
chmod +x $PKL
@@ -47,26 +50,28 @@ local class PklDistribution {
4750
}
4851

4952
local pklCurrent: PklDistribution = new {
50-
version = "0.29.0"
53+
version = "0.30.0"
5154
}
5255

5356
local pklDistributions: Listing<PklDistribution> = new {
5457
new { version = "0.25.3" }
5558
pklCurrent
5659
}
5760

58-
local typealias Platform ="iOS Simulator"|"watchOS Simulator"|"tvOS Simulator"|"visionOS Simulator"|"Mac Catalyst"
61+
local typealias Platform =
62+
"iOS Simulator" | "watchOS Simulator" | "tvOS Simulator" | "visionOS Simulator" | "Mac Catalyst"
5963

6064
local class SimulatorRuntime {
6165
name: String
6266
platform: Platform
63-
fixed sdk: String = Map(
64-
"iOS Simulator", "iphonesimulator",
65-
"watchOS Simulator", "watchsimulator",
66-
"tvOS Simulator", "appletvsimulator",
67-
"visionOS Simulator", "xrsimulator",
68-
"Mac Catalyst", "macosx"
69-
)[platform]
67+
fixed sdk: String =
68+
Map(
69+
"iOS Simulator", "iphonesimulator",
70+
"watchOS Simulator", "watchsimulator",
71+
"tvOS Simulator", "appletvsimulator",
72+
"visionOS Simulator", "xrsimulator",
73+
"Mac Catalyst", "macosx"
74+
)[platform]
7075
hidden destination: String = "platform=\(platform),name=\(name)"
7176
settings: Mapping<String, Any> = new {
7277
["ONLY_ACTIVE_ARCH"] = "YES"
@@ -239,8 +244,8 @@ jobs {
239244
}
240245
}
241246
}
242-
243-
["test-format"] {
247+
248+
["test-format-swift"] {
244249
docker {
245250
new {
246251
image = "swift:6.1-rhel-ubi9"
@@ -254,6 +259,22 @@ jobs {
254259
}
255260
}
256261

262+
["test-format-pkl"] {
263+
docker {
264+
new {
265+
image = "cimg/base:2024.01"
266+
}
267+
}
268+
steps {
269+
"checkout"
270+
pklCurrent.downloadRunStep
271+
new RunStep {
272+
name = "Check Formatting"
273+
command = "make pkl-format-lint"
274+
}
275+
}
276+
}
277+
257278
["pkl-gen-swift-macos"] {
258279
macos {
259280
xcode = "16.4.0"
@@ -263,7 +284,8 @@ jobs {
263284
"checkout"
264285
new RunStep {
265286
name = "Build pkl-gen-swift"
266-
command = """
287+
command =
288+
"""
267289
make pkl-gen-swift-release
268290
mkdir -p out/pkl-gen-swift/
269291
cp $(make pkl-gen-swift-release-output) out/pkl-gen-swift/pkl-gen-swift-macos.bin
@@ -285,7 +307,8 @@ jobs {
285307
"checkout"
286308
new RunStep {
287309
name = "Build pkl-gen-swift"
288-
command = """
310+
command =
311+
"""
289312
make pkl-gen-swift-release
290313
mkdir -p out/pkl-gen-swift/
291314
cp $(make pkl-gen-swift-release-output) out/pkl-gen-swift/pkl-gen-swift-linux-\(arch).bin
@@ -305,7 +328,8 @@ jobs {
305328
pklCurrent.downloadRunStep
306329
new RunStep {
307330
// TODO remove skip-publish-check after initial release
308-
command = #"$PKL_EXEC project package --skip-publish-check --output-path out/pkl-package/ codegen/src/"#
331+
command =
332+
#"$PKL_EXEC project package --skip-publish-check --output-path out/pkl-package/ codegen/src/"#
309333
}
310334
new PersistToWorkspaceStep {
311335
paths {
@@ -326,7 +350,8 @@ jobs {
326350
new RunStep {
327351
name = "Do release"
328352
// language=bash
329-
command = #"""
353+
command =
354+
#"""
330355
EXPECTED_VERSION=$(cat VERSION.txt)
331356
332357
if [ "${EXPECTED_VERSION}" != "${CIRCLE_TAG}" ]; then

.circleci/config.yml

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ jobs:
2525
resource_class: xlarge
2626
docker:
2727
- image: swift:6.1-rhel-ubi9
28-
test-pkl-0-29-0:
28+
test-pkl-0-30-0:
2929
steps:
3030
- checkout
3131
- run:
3232
command: |-
33-
PKL=$(mktemp /tmp/pkl-0.29.0-XXXXXX)
34-
curl -L "https://github.com/apple/pkl/releases/download/0.29.0/pkl-linux-amd64" > $PKL
33+
PKL=$(mktemp /tmp/pkl-0.30.0-XXXXXX)
34+
curl -L "https://github.com/apple/pkl/releases/download/0.30.0/pkl-linux-amd64" > $PKL
3535
chmod +x $PKL
3636
echo "export PKL_EXEC=$PKL" >> $BASH_ENV
37-
name: Downloading pkl-0.29.0
37+
name: Downloading pkl-0.30.0
3838
- run:
3939
command: |-
4040
mkdir -p .out/test-results/
@@ -120,13 +120,28 @@ jobs:
120120
command: /bin/hawkeye check --fail-if-unknown
121121
docker:
122122
- image: ghcr.io/korandoru/hawkeye
123-
test-format:
123+
test-format-swift:
124124
steps:
125125
- checkout
126126
- run:
127127
command: make swiftformat-lint
128128
docker:
129129
- image: swift:6.1-rhel-ubi9
130+
test-format-pkl:
131+
steps:
132+
- checkout
133+
- run:
134+
command: |-
135+
PKL=$(mktemp /tmp/pkl-0.30.0-XXXXXX)
136+
curl -L "https://github.com/apple/pkl/releases/download/0.30.0/pkl-linux-amd64" > $PKL
137+
chmod +x $PKL
138+
echo "export PKL_EXEC=$PKL" >> $BASH_ENV
139+
name: Downloading pkl-0.30.0
140+
- run:
141+
command: make pkl-format-lint
142+
name: Check Formatting
143+
docker:
144+
- image: cimg/base:2024.01
130145
pkl-gen-swift-macos:
131146
steps:
132147
- checkout
@@ -180,11 +195,11 @@ jobs:
180195
- checkout
181196
- run:
182197
command: |-
183-
PKL=$(mktemp /tmp/pkl-0.29.0-XXXXXX)
184-
curl -L "https://github.com/apple/pkl/releases/download/0.29.0/pkl-linux-amd64" > $PKL
198+
PKL=$(mktemp /tmp/pkl-0.30.0-XXXXXX)
199+
curl -L "https://github.com/apple/pkl/releases/download/0.30.0/pkl-linux-amd64" > $PKL
185200
chmod +x $PKL
186201
echo "export PKL_EXEC=$PKL" >> $BASH_ENV
187-
name: Downloading pkl-0.29.0
202+
name: Downloading pkl-0.30.0
188203
- run:
189204
command: $PKL_EXEC project package --skip-publish-check --output-path out/pkl-package/ codegen/src/
190205
- persist_to_workspace:
@@ -265,7 +280,7 @@ workflows:
265280
- test-pkl-0-25-3:
266281
requires:
267282
- hold
268-
- test-pkl-0-29-0:
283+
- test-pkl-0-30-0:
269284
requires:
270285
- hold
271286
- test-ios-simulator:
@@ -283,7 +298,10 @@ workflows:
283298
- test-license-headers:
284299
requires:
285300
- hold
286-
- test-format:
301+
- test-format-swift:
302+
requires:
303+
- hold
304+
- test-format-pkl:
287305
requires:
288306
- hold
289307
when:
@@ -293,13 +311,14 @@ workflows:
293311
main:
294312
jobs:
295313
- test-pkl-0-25-3
296-
- test-pkl-0-29-0
314+
- test-pkl-0-30-0
297315
- test-ios-simulator
298316
- test-watchos-simulator
299317
- test-tvos-simulator
300318
- test-mac-catalyst
301319
- test-license-headers
302-
- test-format
320+
- test-format-swift
321+
- test-format-pkl
303322
when:
304323
equal:
305324
- main
@@ -312,7 +331,7 @@ workflows:
312331
ignore: /.*/
313332
tags:
314333
only: /^v?\d+\.\d+\.\d+$/
315-
- test-pkl-0-29-0:
334+
- test-pkl-0-30-0:
316335
filters:
317336
branches:
318337
ignore: /.*/
@@ -348,7 +367,13 @@ workflows:
348367
ignore: /.*/
349368
tags:
350369
only: /^v?\d+\.\d+\.\d+$/
351-
- test-format:
370+
- test-format-swift:
371+
filters:
372+
branches:
373+
ignore: /.*/
374+
tags:
375+
only: /^v?\d+\.\d+\.\d+$/
376+
- test-format-pkl:
352377
filters:
353378
branches:
354379
ignore: /.*/
@@ -357,13 +382,14 @@ workflows:
357382
- pkl-package:
358383
requires:
359384
- test-pkl-0-25-3
360-
- test-pkl-0-29-0
385+
- test-pkl-0-30-0
361386
- test-ios-simulator
362387
- test-watchos-simulator
363388
- test-tvos-simulator
364389
- test-mac-catalyst
365390
- test-license-headers
366-
- test-format
391+
- test-format-swift
392+
- test-format-pkl
367393
filters:
368394
branches:
369395
ignore: /.*/
@@ -372,13 +398,14 @@ workflows:
372398
- pkl-gen-swift-macos:
373399
requires:
374400
- test-pkl-0-25-3
375-
- test-pkl-0-29-0
401+
- test-pkl-0-30-0
376402
- test-ios-simulator
377403
- test-watchos-simulator
378404
- test-tvos-simulator
379405
- test-mac-catalyst
380406
- test-license-headers
381-
- test-format
407+
- test-format-swift
408+
- test-format-pkl
382409
filters:
383410
branches:
384411
ignore: /.*/
@@ -387,13 +414,14 @@ workflows:
387414
- pkl-gen-swift-linux-amd64:
388415
requires:
389416
- test-pkl-0-25-3
390-
- test-pkl-0-29-0
417+
- test-pkl-0-30-0
391418
- test-ios-simulator
392419
- test-watchos-simulator
393420
- test-tvos-simulator
394421
- test-mac-catalyst
395422
- test-license-headers
396-
- test-format
423+
- test-format-swift
424+
- test-format-pkl
397425
filters:
398426
branches:
399427
ignore: /.*/
@@ -402,13 +430,14 @@ workflows:
402430
- pkl-gen-swift-linux-aarch64:
403431
requires:
404432
- test-pkl-0-25-3
405-
- test-pkl-0-29-0
433+
- test-pkl-0-30-0
406434
- test-ios-simulator
407435
- test-watchos-simulator
408436
- test-tvos-simulator
409437
- test-mac-catalyst
410438
- test-license-headers
411-
- test-format
439+
- test-format-swift
440+
- test-format-pkl
412441
filters:
413442
branches:
414443
ignore: /.*/

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,10 @@ swiftformat-lint:
123123
license-format: .build/tools/hawkeye
124124
.build/tools/hawkeye format
125125

126-
format: swiftformat license-format
126+
pkl-format:
127+
$(PKL_EXEC) format --grammar-version 1 --write .
128+
129+
pkl-format-lint:
130+
$(PKL_EXEC) format --grammar-version 1 --diff-name-only .
131+
132+
format: swiftformat license-format pkl-format

Tests/PklSwiftTests/Fixtures/AnyType.pkl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
class Bird {
32
species: String
43
}

Tests/PklSwiftTests/Fixtures/Collections.pkl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
21
res1: List<Int> = List(1, 2, 3)
32

4-
res2: Listing<Int> = new { 2; 3; 4; }
3+
res2: Listing<Int> = new { 2; 3; 4 }
54

65
res3: List<List<Int>> = List(List(1), List(2), List(3))
76

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
res: Bytes = Bytes(1, 2, 3, 255)
1+
res: Bytes = Bytes(1, 2, 3, 255)

Tests/PklSwiftTests/Fixtures/ExtendedModule.pkl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ extends "OpenModule.pkl"
22

33
foo = "foo"
44

5-
bar = 10
5+
bar = 10
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
typealias ReferencedAlias = String
22

3-
class ThisClassShouldAlsoGenerate {
4-
}
3+
class ThisClassShouldAlsoGenerate {}

Tests/PklSwiftTests/Fixtures/OpenModule.pkl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ open module OpenModule
1717

1818
foo: String
1919

20-
bar: Int
20+
bar: Int

0 commit comments

Comments
 (0)