mirror of https://github.com/apple/pkl-swift
Add color to PklEvaluatorSettings (#32)
This adds a field that was added in Pkl 0.27
This commit is contained in:
parent
64c66aea8e
commit
52d5fbc5e1
|
@ -1,5 +1,5 @@
|
||||||
// ===----------------------------------------------------------------------===//
|
// ===----------------------------------------------------------------------===//
|
||||||
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
// Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
// ===----------------------------------------------------------------------===//
|
// ===----------------------------------------------------------------------===//
|
||||||
amends "package://pkg.pkl-lang.org/pkl-project-commons/pkl.impl.circleci@1.0.1#/PklCI.pkl"
|
amends "package://pkg.pkl-lang.org/pkl-project-commons/pkl.impl.circleci@1.1.1#/PklCI.pkl"
|
||||||
|
|
||||||
import "pkl:semver"
|
import "pkl:semver"
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ local class PklDistribution {
|
||||||
}
|
}
|
||||||
|
|
||||||
local pklCurrent: PklDistribution = new {
|
local pklCurrent: PklDistribution = new {
|
||||||
version = "0.26.0"
|
version = "0.27.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
local pklDistributions: Listing<PklDistribution> = new {
|
local pklDistributions: Listing<PklDistribution> = new {
|
||||||
|
|
|
@ -29,16 +29,16 @@ jobs:
|
||||||
resource_class: xlarge
|
resource_class: xlarge
|
||||||
docker:
|
docker:
|
||||||
- image: swift:5.9-rhel-ubi9
|
- image: swift:5.9-rhel-ubi9
|
||||||
test-pkl-0-26-0:
|
test-pkl-0-27-2:
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
command: |-
|
command: |-
|
||||||
PKL=$(mktemp /tmp/pkl-0.26.0-XXXXXX)
|
PKL=$(mktemp /tmp/pkl-0.27.2-XXXXXX)
|
||||||
curl -L "https://github.com/apple/pkl/releases/download/0.26.0/pkl-linux-amd64" > $PKL
|
curl -L "https://github.com/apple/pkl/releases/download/0.27.2/pkl-linux-amd64" > $PKL
|
||||||
chmod +x $PKL
|
chmod +x $PKL
|
||||||
echo "export PKL_EXEC=$PKL" >> $BASH_ENV
|
echo "export PKL_EXEC=$PKL" >> $BASH_ENV
|
||||||
name: Downloading pkl-0.26.0
|
name: Downloading pkl-0.27.2
|
||||||
- run:
|
- run:
|
||||||
command: |-
|
command: |-
|
||||||
mkdir -p .out/test-results/
|
mkdir -p .out/test-results/
|
||||||
|
@ -108,11 +108,11 @@ jobs:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
command: |-
|
command: |-
|
||||||
PKL=$(mktemp /tmp/pkl-0.26.0-XXXXXX)
|
PKL=$(mktemp /tmp/pkl-0.27.2-XXXXXX)
|
||||||
curl -L "https://github.com/apple/pkl/releases/download/0.26.0/pkl-linux-amd64" > $PKL
|
curl -L "https://github.com/apple/pkl/releases/download/0.27.2/pkl-linux-amd64" > $PKL
|
||||||
chmod +x $PKL
|
chmod +x $PKL
|
||||||
echo "export PKL_EXEC=$PKL" >> $BASH_ENV
|
echo "export PKL_EXEC=$PKL" >> $BASH_ENV
|
||||||
name: Downloading pkl-0.26.0
|
name: Downloading pkl-0.27.2
|
||||||
- run:
|
- run:
|
||||||
command: $PKL_EXEC project package --skip-publish-check --output-path out/pkl-package/ codegen/src/
|
command: $PKL_EXEC project package --skip-publish-check --output-path out/pkl-package/ codegen/src/
|
||||||
- persist_to_workspace:
|
- persist_to_workspace:
|
||||||
|
@ -193,11 +193,9 @@ workflows:
|
||||||
- test-pkl-0-25-3:
|
- test-pkl-0-25-3:
|
||||||
requires:
|
requires:
|
||||||
- hold
|
- hold
|
||||||
- pr-approval/authenticate
|
- test-pkl-0-27-2:
|
||||||
- test-pkl-0-26-0:
|
|
||||||
requires:
|
requires:
|
||||||
- hold
|
- hold
|
||||||
- pr-approval/authenticate
|
|
||||||
when:
|
when:
|
||||||
matches:
|
matches:
|
||||||
value: << pipeline.git.branch >>
|
value: << pipeline.git.branch >>
|
||||||
|
@ -205,7 +203,7 @@ workflows:
|
||||||
main:
|
main:
|
||||||
jobs:
|
jobs:
|
||||||
- test-pkl-0-25-3
|
- test-pkl-0-25-3
|
||||||
- test-pkl-0-26-0
|
- test-pkl-0-27-2
|
||||||
when:
|
when:
|
||||||
equal:
|
equal:
|
||||||
- main
|
- main
|
||||||
|
@ -218,7 +216,7 @@ workflows:
|
||||||
ignore: /.*/
|
ignore: /.*/
|
||||||
tags:
|
tags:
|
||||||
only: /^v?\d+\.\d+\.\d+$/
|
only: /^v?\d+\.\d+\.\d+$/
|
||||||
- test-pkl-0-26-0:
|
- test-pkl-0-27-2:
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
ignore: /.*/
|
ignore: /.*/
|
||||||
|
@ -227,7 +225,7 @@ workflows:
|
||||||
- pkl-package:
|
- pkl-package:
|
||||||
requires:
|
requires:
|
||||||
- test-pkl-0-25-3
|
- test-pkl-0-25-3
|
||||||
- test-pkl-0-26-0
|
- test-pkl-0-27-2
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
ignore: /.*/
|
ignore: /.*/
|
||||||
|
@ -236,7 +234,7 @@ workflows:
|
||||||
- pkl-gen-swift-macos:
|
- pkl-gen-swift-macos:
|
||||||
requires:
|
requires:
|
||||||
- test-pkl-0-25-3
|
- test-pkl-0-25-3
|
||||||
- test-pkl-0-26-0
|
- test-pkl-0-27-2
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
ignore: /.*/
|
ignore: /.*/
|
||||||
|
@ -245,7 +243,7 @@ workflows:
|
||||||
- pkl-gen-swift-linux-amd64:
|
- pkl-gen-swift-linux-amd64:
|
||||||
requires:
|
requires:
|
||||||
- test-pkl-0-25-3
|
- test-pkl-0-25-3
|
||||||
- test-pkl-0-26-0
|
- test-pkl-0-27-2
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
ignore: /.*/
|
ignore: /.*/
|
||||||
|
@ -254,7 +252,7 @@ workflows:
|
||||||
- pkl-gen-swift-linux-aarch64:
|
- pkl-gen-swift-linux-aarch64:
|
||||||
requires:
|
requires:
|
||||||
- test-pkl-0-25-3
|
- test-pkl-0-25-3
|
||||||
- test-pkl-0-26-0
|
- test-pkl-0-27-2
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
ignore: /.*/
|
ignore: /.*/
|
||||||
|
|
|
@ -26,8 +26,28 @@ public struct PklEvaluatorSettings: Decodable, Hashable {
|
||||||
let moduleCacheDir: String?
|
let moduleCacheDir: String?
|
||||||
let rootDir: String?
|
let rootDir: String?
|
||||||
let http: Http?
|
let http: Http?
|
||||||
|
|
||||||
|
/// Added in Pkl 0.27
|
||||||
let externalModuleReaders: [String: ExternalReader]?
|
let externalModuleReaders: [String: ExternalReader]?
|
||||||
|
|
||||||
|
/// Added in Pkl 0.27
|
||||||
let externalResourceReaders: [String: ExternalReader]?
|
let externalResourceReaders: [String: ExternalReader]?
|
||||||
|
|
||||||
|
/// Whether to format messages and test results with ANSI color colors.
|
||||||
|
///
|
||||||
|
/// Added in Pkl 0.27
|
||||||
|
let color: PklEvaluatorSettingsColor?
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PklEvaluatorSettingsColor: String, CaseIterable, Decodable, Hashable {
|
||||||
|
/// Never format.
|
||||||
|
case never = "never"
|
||||||
|
|
||||||
|
/// Format if the process' stdin, stdout, or stderr are connected to a console.
|
||||||
|
case auto = "auto"
|
||||||
|
|
||||||
|
/// Always format.
|
||||||
|
case always = "always"
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Settings that control how Pkl talks to HTTP(S) servers.
|
/// Settings that control how Pkl talks to HTTP(S) servers.
|
||||||
|
|
|
@ -28,6 +28,7 @@ class ProjectTest: XCTestCase {
|
||||||
let otherProjectFile = subDir.appendingPathComponent("PklProject")
|
let otherProjectFile = subDir.appendingPathComponent("PklProject")
|
||||||
|
|
||||||
try #"""
|
try #"""
|
||||||
|
@ModuleInfo { minPklVersion = "0.25.0" }
|
||||||
amends "pkl:Project"
|
amends "pkl:Project"
|
||||||
|
|
||||||
package {
|
package {
|
||||||
|
@ -71,6 +72,7 @@ class ProjectTest: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
let colorSetting = version < pklVersion0_27 ? "" : #"color = "always""#
|
||||||
let httpExpectation = version < pklVersion0_26 ? nil : Http(
|
let httpExpectation = version < pklVersion0_26 ? nil : Http(
|
||||||
caCertificates: nil,
|
caCertificates: nil,
|
||||||
proxy: .init(address: "http://localhost:1", noProxy: ["example.com", "foo.bar.org"])
|
proxy: .init(address: "http://localhost:1", noProxy: ["example.com", "foo.bar.org"])
|
||||||
|
@ -83,6 +85,7 @@ class ProjectTest: XCTestCase {
|
||||||
"scheme3": ExternalReader(executable: "reader3"),
|
"scheme3": ExternalReader(executable: "reader3"),
|
||||||
"scheme4": ExternalReader(executable: "reader4", arguments: ["with", "args"]),
|
"scheme4": ExternalReader(executable: "reader4", arguments: ["with", "args"]),
|
||||||
]
|
]
|
||||||
|
let color: PklEvaluatorSettingsColor? = version < pklVersion0_27 ? nil : .always
|
||||||
try #"""
|
try #"""
|
||||||
amends "pkl:Project"
|
amends "pkl:Project"
|
||||||
|
|
||||||
|
@ -129,6 +132,7 @@ class ProjectTest: XCTestCase {
|
||||||
rootDir = "/buzzy"
|
rootDir = "/buzzy"
|
||||||
\#(externalReaderSettings)
|
\#(externalReaderSettings)
|
||||||
\#(httpSetting)
|
\#(httpSetting)
|
||||||
|
\#(colorSetting)
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -155,7 +159,8 @@ class ProjectTest: XCTestCase {
|
||||||
rootDir: "/buzzy",
|
rootDir: "/buzzy",
|
||||||
http: httpExpectation,
|
http: httpExpectation,
|
||||||
externalModuleReaders: externalModuleReadersExpectation,
|
externalModuleReaders: externalModuleReadersExpectation,
|
||||||
externalResourceReaders: externalResourceReadersExpectation
|
externalResourceReaders: externalResourceReadersExpectation,
|
||||||
|
color: color
|
||||||
)
|
)
|
||||||
let expectedPackage = PklSwift.Project.Package(
|
let expectedPackage = PklSwift.Project.Package(
|
||||||
name: "hawk",
|
name: "hawk",
|
||||||
|
@ -212,7 +217,8 @@ class ProjectTest: XCTestCase {
|
||||||
rootDir: nil,
|
rootDir: nil,
|
||||||
http: nil,
|
http: nil,
|
||||||
externalModuleReaders: nil,
|
externalModuleReaders: nil,
|
||||||
externalResourceReaders: nil
|
externalResourceReaders: nil,
|
||||||
|
color: nil
|
||||||
),
|
),
|
||||||
projectFileUri: "\(otherProjectFile)",
|
projectFileUri: "\(otherProjectFile)",
|
||||||
tests: [],
|
tests: [],
|
||||||
|
|
Loading…
Reference in New Issue