Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add color to PklEvaluatorSettings #32

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/config.pkl
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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"

Expand Down Expand Up @@ -47,7 +47,7 @@ local class PklDistribution {
}

local pklCurrent: PklDistribution = new {
version = "0.26.0"
version = "0.27.2"
}

local pklDistributions: Listing<PklDistribution> = new {
Expand Down
30 changes: 14 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -193,19 +193,17 @@ 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 >>
pattern: ^pull/\d+(/head)?$
main:
jobs:
- test-pkl-0-25-3
- test-pkl-0-26-0
- test-pkl-0-27-2
when:
equal:
- main
Expand All @@ -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: /.*/
Expand All @@ -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: /.*/
Expand All @@ -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: /.*/
Expand All @@ -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: /.*/
Expand All @@ -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: /.*/
Expand Down
20 changes: 20 additions & 0 deletions Sources/PklSwift/PklEvaluatorSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 8 additions & 2 deletions Tests/PklSwiftTests/ProjectTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ProjectTest: XCTestCase {
let otherProjectFile = subDir.appendingPathComponent("PklProject")

try #"""
@ModuleInfo { minPklVersion = "0.25.0" }
amends "pkl:Project"

package {
Expand Down Expand Up @@ -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"])
Expand All @@ -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"

Expand Down Expand Up @@ -129,6 +132,7 @@ class ProjectTest: XCTestCase {
rootDir = "/buzzy"
\#(externalReaderSettings)
\#(httpSetting)
\#(colorSetting)
}

dependencies {
Expand All @@ -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",
Expand Down Expand Up @@ -212,7 +217,8 @@ class ProjectTest: XCTestCase {
rootDir: nil,
http: nil,
externalModuleReaders: nil,
externalResourceReaders: nil
externalResourceReaders: nil,
color: nil
),
projectFileUri: "\(otherProjectFile)",
tests: [],
Expand Down