Skip to content

Commit

Permalink
Add color to PklEvaluatorSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
bioball committed Jan 17, 2025
1 parent 64c66ae commit 0875c9f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 18 deletions.
4 changes: 2 additions & 2 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 Down Expand Up @@ -47,7 +47,7 @@ local class PklDistribution {
}

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

local pklDistributions: Listing<PklDistribution> = new {
Expand Down
28 changes: 14 additions & 14 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-1:
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.1-XXXXXX)
curl -L "https://github.com/apple/pkl/releases/download/0.27.1/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.1
- 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.1-XXXXXX)
curl -L "https://github.com/apple/pkl/releases/download/0.27.1/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.1
- run:
command: $PKL_EXEC project package --skip-publish-check --output-path out/pkl-package/ codegen/src/
- persist_to_workspace:
Expand Down Expand Up @@ -194,7 +194,7 @@ workflows:
requires:
- hold
- pr-approval/authenticate
- test-pkl-0-26-0:
- test-pkl-0-27-1:
requires:
- hold
- pr-approval/authenticate
Expand All @@ -205,7 +205,7 @@ workflows:
main:
jobs:
- test-pkl-0-25-3
- test-pkl-0-26-0
- test-pkl-0-27-1
when:
equal:
- main
Expand All @@ -218,7 +218,7 @@ workflows:
ignore: /.*/
tags:
only: /^v?\d+\.\d+\.\d+$/
- test-pkl-0-26-0:
- test-pkl-0-27-1:
filters:
branches:
ignore: /.*/
Expand All @@ -227,7 +227,7 @@ workflows:
- pkl-package:
requires:
- test-pkl-0-25-3
- test-pkl-0-26-0
- test-pkl-0-27-1
filters:
branches:
ignore: /.*/
Expand All @@ -236,7 +236,7 @@ workflows:
- pkl-gen-swift-macos:
requires:
- test-pkl-0-25-3
- test-pkl-0-26-0
- test-pkl-0-27-1
filters:
branches:
ignore: /.*/
Expand All @@ -245,7 +245,7 @@ workflows:
- pkl-gen-swift-linux-amd64:
requires:
- test-pkl-0-25-3
- test-pkl-0-26-0
- test-pkl-0-27-1
filters:
branches:
ignore: /.*/
Expand All @@ -254,7 +254,7 @@ workflows:
- pkl-gen-swift-linux-aarch64:
requires:
- test-pkl-0-25-3
- test-pkl-0-26-0
- test-pkl-0-27-1
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

0 comments on commit 0875c9f

Please sign in to comment.