Add color to PklEvaluatorSettings (#32)

This adds a field that was added in Pkl 0.27
This commit is contained in:
Daniel Chao 2025-01-23 06:59:31 -08:00 committed by GitHub
parent 64c66aea8e
commit 52d5fbc5e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 45 additions and 21 deletions

View File

@ -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");
// 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
// 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"
@ -47,7 +47,7 @@ local class PklDistribution {
}
local pklCurrent: PklDistribution = new {
version = "0.26.0"
version = "0.27.2"
}
local pklDistributions: Listing<PklDistribution> = new {

View File

@ -29,16 +29,16 @@ jobs:
resource_class: xlarge
docker:
- image: swift:5.9-rhel-ubi9
test-pkl-0-26-0:
test-pkl-0-27-2:
steps:
- checkout
- run:
command: |-
PKL=$(mktemp /tmp/pkl-0.26.0-XXXXXX)
curl -L "https://github.com/apple/pkl/releases/download/0.26.0/pkl-linux-amd64" > $PKL
PKL=$(mktemp /tmp/pkl-0.27.2-XXXXXX)
curl -L "https://github.com/apple/pkl/releases/download/0.27.2/pkl-linux-amd64" > $PKL
chmod +x $PKL
echo "export PKL_EXEC=$PKL" >> $BASH_ENV
name: Downloading pkl-0.26.0
name: Downloading pkl-0.27.2
- run:
command: |-
mkdir -p .out/test-results/
@ -108,11 +108,11 @@ jobs:
- checkout
- run:
command: |-
PKL=$(mktemp /tmp/pkl-0.26.0-XXXXXX)
curl -L "https://github.com/apple/pkl/releases/download/0.26.0/pkl-linux-amd64" > $PKL
PKL=$(mktemp /tmp/pkl-0.27.2-XXXXXX)
curl -L "https://github.com/apple/pkl/releases/download/0.27.2/pkl-linux-amd64" > $PKL
chmod +x $PKL
echo "export PKL_EXEC=$PKL" >> $BASH_ENV
name: Downloading pkl-0.26.0
name: Downloading pkl-0.27.2
- run:
command: $PKL_EXEC project package --skip-publish-check --output-path out/pkl-package/ codegen/src/
- persist_to_workspace:
@ -193,11 +193,9 @@ workflows:
- test-pkl-0-25-3:
requires:
- hold
- pr-approval/authenticate
- test-pkl-0-26-0:
- test-pkl-0-27-2:
requires:
- hold
- pr-approval/authenticate
when:
matches:
value: << pipeline.git.branch >>
@ -205,7 +203,7 @@ workflows:
main:
jobs:
- test-pkl-0-25-3
- test-pkl-0-26-0
- test-pkl-0-27-2
when:
equal:
- main
@ -218,7 +216,7 @@ workflows:
ignore: /.*/
tags:
only: /^v?\d+\.\d+\.\d+$/
- test-pkl-0-26-0:
- test-pkl-0-27-2:
filters:
branches:
ignore: /.*/
@ -227,7 +225,7 @@ workflows:
- pkl-package:
requires:
- test-pkl-0-25-3
- test-pkl-0-26-0
- test-pkl-0-27-2
filters:
branches:
ignore: /.*/
@ -236,7 +234,7 @@ workflows:
- pkl-gen-swift-macos:
requires:
- test-pkl-0-25-3
- test-pkl-0-26-0
- test-pkl-0-27-2
filters:
branches:
ignore: /.*/
@ -245,7 +243,7 @@ workflows:
- pkl-gen-swift-linux-amd64:
requires:
- test-pkl-0-25-3
- test-pkl-0-26-0
- test-pkl-0-27-2
filters:
branches:
ignore: /.*/
@ -254,7 +252,7 @@ workflows:
- pkl-gen-swift-linux-aarch64:
requires:
- test-pkl-0-25-3
- test-pkl-0-26-0
- test-pkl-0-27-2
filters:
branches:
ignore: /.*/

View File

@ -26,8 +26,28 @@ public struct PklEvaluatorSettings: Decodable, Hashable {
let moduleCacheDir: String?
let rootDir: String?
let http: Http?
/// Added in Pkl 0.27
let externalModuleReaders: [String: ExternalReader]?
/// Added in Pkl 0.27
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.

View File

@ -28,6 +28,7 @@ class ProjectTest: XCTestCase {
let otherProjectFile = subDir.appendingPathComponent("PklProject")
try #"""
@ModuleInfo { minPklVersion = "0.25.0" }
amends "pkl:Project"
package {
@ -71,6 +72,7 @@ class ProjectTest: XCTestCase {
}
}
"""
let colorSetting = version < pklVersion0_27 ? "" : #"color = "always""#
let httpExpectation = version < pklVersion0_26 ? nil : Http(
caCertificates: nil,
proxy: .init(address: "http://localhost:1", noProxy: ["example.com", "foo.bar.org"])
@ -83,6 +85,7 @@ class ProjectTest: XCTestCase {
"scheme3": ExternalReader(executable: "reader3"),
"scheme4": ExternalReader(executable: "reader4", arguments: ["with", "args"]),
]
let color: PklEvaluatorSettingsColor? = version < pklVersion0_27 ? nil : .always
try #"""
amends "pkl:Project"
@ -129,6 +132,7 @@ class ProjectTest: XCTestCase {
rootDir = "/buzzy"
\#(externalReaderSettings)
\#(httpSetting)
\#(colorSetting)
}
dependencies {
@ -155,7 +159,8 @@ class ProjectTest: XCTestCase {
rootDir: "/buzzy",
http: httpExpectation,
externalModuleReaders: externalModuleReadersExpectation,
externalResourceReaders: externalResourceReadersExpectation
externalResourceReaders: externalResourceReadersExpectation,
color: color
)
let expectedPackage = PklSwift.Project.Package(
name: "hawk",
@ -212,7 +217,8 @@ class ProjectTest: XCTestCase {
rootDir: nil,
http: nil,
externalModuleReaders: nil,
externalResourceReaders: nil
externalResourceReaders: nil,
color: nil
),
projectFileUri: "\(otherProjectFile)",
tests: [],