Skip to content

Commit 8c5bd3b

Browse files
authored
Apply pkl formatter to codebase (#1236)
This applies the Pkl formatter to `stdlib/` and `.circleci/`
1 parent 42dcad2 commit 8c5bd3b

File tree

19 files changed

+737
-613
lines changed

19 files changed

+737
-613
lines changed

.circleci/config.pkl

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
amends "package://pkg.pkl-lang.org/pkl-project-commons/pkl.impl.circleci@1.2.0#/PklCI.pkl"
1818

1919
import "jobs/BuildNativeJob.pkl"
20-
import "jobs/GradleCheckJob.pkl"
2120
import "jobs/DeployJob.pkl"
21+
import "jobs/GradleCheckJob.pkl"
2222
import "jobs/SimpleGradleJob.pkl"
2323

2424
local prbJobs: Listing<String> = gradleCheckJobs.keys.toListing()
@@ -130,18 +130,21 @@ jobs {
130130
[jobName] = job.job
131131
}
132132
["bench"] = new SimpleGradleJob { command = "bench:jmh" }.job
133-
["gradle-compatibility"] = new SimpleGradleJob {
134-
name = "gradle compatibility"
135-
command = #"""
136-
:pkl-gradle:build \
137-
:pkl-gradle:compatibilityTestReleases
138-
"""#
139-
}.job
133+
["gradle-compatibility"] =
134+
new SimpleGradleJob {
135+
name = "gradle compatibility"
136+
command =
137+
#"""
138+
:pkl-gradle:build \
139+
:pkl-gradle:compatibilityTestReleases
140+
"""#
141+
}.job
140142
["deploy-snapshot"] = new DeployJob { command = "publishToSonatype" }.job
141-
["deploy-release"] = new DeployJob {
142-
isRelease = true
143-
command = "publishToSonatype closeAndReleaseSonatypeStagingRepository"
144-
}.job
143+
["deploy-release"] =
144+
new DeployJob {
145+
isRelease = true
146+
command = "publishToSonatype closeAndReleaseSonatypeStagingRepository"
147+
}.job
145148
["github-release"] {
146149
docker {
147150
new { image = "maniator/gh:v2.40.1" }
@@ -150,7 +153,8 @@ jobs {
150153
new AttachWorkspaceStep { at = "." }
151154
new RunStep {
152155
name = "Publish release on GitHub"
153-
command = #"""
156+
command =
157+
#"""
154158
# exclude build_artifacts.txt from publish
155159
rm -f */build/executable/*.build_artifacts.txt
156160
find */build/executable/* -type d | xargs rm -rf

.circleci/jobs/BuildNativeJob.pkl

Lines changed: 64 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extends "GradleJob.pkl"
1919
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.5.0#/Config.pkl"
2020

2121
/// The architecture to use
22-
arch: "amd64"|"aarch64"
22+
arch: "amd64" | "aarch64"
2323

2424
/// Whether to link to musl. Otherwise, links to glibc.
2525
musl: Boolean = false
@@ -44,40 +44,45 @@ local setupLinuxEnvironment: Config.RunStep =
4444
new {
4545
name = "Set up environment"
4646
shell = "#!/bin/bash -exo pipefail"
47-
command = new Listing {
48-
#"""
49-
sed -ie '/\[ol8_codeready_builder\]/,/^$/s/enabled=0/enabled=1/g' /etc/yum.repos.d/oracle-linux-ol8.repo \
50-
&& microdnf -y install util-linux tree coreutils-single findutils curl tar gzip git zlib-devel gcc-c++ make openssl glibc-langpack-en libstdc++-static \
51-
&& microdnf clean all \
52-
&& rm -rf /var/cache/dnf
53-
54-
# install jdk
55-
curl -Lf \
56-
https://github.com/adoptium/temurin\#(module.majorJdkVersion)-binaries/releases/download/\#(module.jdkGitHubReleaseName)/OpenJDK\#(module.majorJdkVersion)U-jdk_\#(if (arch == "amd64") "x64" else "aarch64")_linux_hotspot_\#(module.jdkVersionAlt).tar.gz -o /tmp/jdk.tar.gz
57-
58-
mkdir /jdk \
59-
&& cd /jdk \
60-
&& cat /tmp/jdk.tar.gz | tar --strip-components=1 -xzC .
61-
62-
mkdir -p ~/staticdeps/bin
63-
64-
cp /usr/lib/gcc/\#(if (arch == "amd64") "x86_64" else "aarch64")-redhat-linux/8/libstdc++.a ~/staticdeps
65-
66-
# install zlib
67-
if [[ ! -f ~/staticdeps/include/zlib.h ]]; then
68-
curl -Lf https://github.com/madler/zlib/releases/download/v\#(zlibVersion)/zlib-\#(zlibVersion).tar.gz -o /tmp/zlib.tar.gz
69-
70-
mkdir -p /tmp/dep_zlib-\#(zlibVersion) \
71-
&& cd /tmp/dep_zlib-\#(zlibVersion) \
72-
&& cat /tmp/zlib.tar.gz | tar --strip-components=1 -xzC . \
73-
&& echo "zlib-\#(zlibVersion): configure..." && ./configure --static --prefix="$HOME"/staticdeps > /dev/null \
74-
&& echo "zlib-\#(zlibVersion): make..." && make -s -j4 \
75-
&& echo "zlib-\#(zlibVersion): make install..." && make -s install \
76-
&& rm -rf /tmp/dep_zlib-\#(zlibVersion)
77-
fi
78-
"""#
79-
// don't need musl on aarch because GraalVM only supports musl builds on x86
80-
when (arch == "amd64") {
47+
command =
48+
new Listing {
49+
#"""
50+
sed -ie '/\[ol8_codeready_builder\]/,/^$/s/enabled=0/enabled=1/g' /etc/yum.repos.d/oracle-linux-ol8.repo \
51+
&& microdnf -y install util-linux tree coreutils-single findutils curl tar gzip git zlib-devel gcc-c++ make openssl glibc-langpack-en libstdc++-static \
52+
&& microdnf clean all \
53+
&& rm -rf /var/cache/dnf
54+
55+
# install jdk
56+
curl -Lf \
57+
https://github.com/adoptium/temurin\#(module.majorJdkVersion)-binaries/releases/download/\#(module
58+
.jdkGitHubReleaseName)/OpenJDK\#(module.majorJdkVersion)U-jdk_\#(if (arch == "amd64")
59+
"x64"
60+
else
61+
"aarch64")_linux_hotspot_\#(module.jdkVersionAlt).tar.gz -o /tmp/jdk.tar.gz
62+
63+
mkdir /jdk \
64+
&& cd /jdk \
65+
&& cat /tmp/jdk.tar.gz | tar --strip-components=1 -xzC .
66+
67+
mkdir -p ~/staticdeps/bin
68+
69+
cp /usr/lib/gcc/\#(if (arch == "amd64") "x86_64" else "aarch64")-redhat-linux/8/libstdc++.a ~/staticdeps
70+
71+
# install zlib
72+
if [[ ! -f ~/staticdeps/include/zlib.h ]]; then
73+
curl -Lf https://github.com/madler/zlib/releases/download/v\#(zlibVersion)/zlib-\#(zlibVersion).tar.gz -o /tmp/zlib.tar.gz
74+
75+
mkdir -p /tmp/dep_zlib-\#(zlibVersion) \
76+
&& cd /tmp/dep_zlib-\#(zlibVersion) \
77+
&& cat /tmp/zlib.tar.gz | tar --strip-components=1 -xzC . \
78+
&& echo "zlib-\#(zlibVersion): configure..." && ./configure --static --prefix="$HOME"/staticdeps > /dev/null \
79+
&& echo "zlib-\#(zlibVersion): make..." && make -s -j4 \
80+
&& echo "zlib-\#(zlibVersion): make install..." && make -s install \
81+
&& rm -rf /tmp/dep_zlib-\#(zlibVersion)
82+
fi
83+
"""#
84+
// don't need musl on aarch because GraalVM only supports musl builds on x86
85+
when (arch == "amd64") {
8186
#"""
8287
# install musl
8388
if [[ ! -f ~/staticdeps/bin/x86_64-linux-musl-gcc ]]; then
@@ -95,25 +100,28 @@ local setupLinuxEnvironment: Config.RunStep =
95100
ln -s ~/staticdeps/bin/musl-gcc ~/staticdeps/bin/x86_64-linux-musl-gcc
96101
fi
97102
"""#
98-
}
99-
}.join("\n\n")
103+
}
104+
}.join("\n\n")
100105
}
101106

102-
local setupMacEnvironment: Config.RunStep =
103-
new {
104-
name = "Set up environment"
105-
shell = "#!/bin/bash -exo pipefail"
106-
command =
107-
#"""
108-
# install jdk
109-
curl -Lf \
110-
https://github.com/adoptium/temurin\#(module.majorJdkVersion)-binaries/releases/download/\#(module.jdkGitHubReleaseName)/OpenJDK\#(module.majorJdkVersion)U-jdk_\#(if (arch == "amd64") "x64" else "aarch64")_mac_hotspot_\#(module.jdkVersionAlt).tar.gz -o /tmp/jdk.tar.gz
111-
112-
mkdir $HOME/jdk \
113-
&& cd $HOME/jdk \
114-
&& cat /tmp/jdk.tar.gz | tar --strip-components=1 -xzC .
115-
"""#
116-
}
107+
local setupMacEnvironment: Config.RunStep = new {
108+
name = "Set up environment"
109+
shell = "#!/bin/bash -exo pipefail"
110+
command =
111+
#"""
112+
# install jdk
113+
curl -Lf \
114+
https://github.com/adoptium/temurin\#(module.majorJdkVersion)-binaries/releases/download/\#(module
115+
.jdkGitHubReleaseName)/OpenJDK\#(module.majorJdkVersion)U-jdk_\#(if (arch == "amd64")
116+
"x64"
117+
else
118+
"aarch64")_mac_hotspot_\#(module.jdkVersionAlt).tar.gz -o /tmp/jdk.tar.gz
119+
120+
mkdir $HOME/jdk \
121+
&& cd $HOME/jdk \
122+
&& cat /tmp/jdk.tar.gz | tar --strip-components=1 -xzC .
123+
"""#
124+
}
117125

118126
steps {
119127
when (os == "linux") {
@@ -134,7 +142,8 @@ steps {
134142
when (arch == "amd64") {
135143
new Config.RunStep {
136144
name = "Installing Rosetta 2"
137-
command = """
145+
command =
146+
"""
138147
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
139148
"""
140149
}
@@ -146,7 +155,8 @@ steps {
146155
when (module.os == "windows") {
147156
shell = "bash.exe"
148157
}
149-
command = #"""
158+
command =
159+
#"""
150160
export PATH=~/staticdeps/bin:$PATH
151161
./gradlew \#(module.gradleArgs) \#(project):buildNative
152162
"""#

.circleci/jobs/GradleJob.pkl

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ import "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1.0.3#/URI.pk
2222
isRelease: Boolean = false
2323

2424
/// The OS to run on
25-
os: "macOS"|"linux"|"windows"
25+
os: "macOS" | "linux" | "windows"
2626

2727
/// The version of Java to use.
28-
javaVersion: "17.0"|"21.0"
28+
javaVersion: "17.0" | "21.0"
2929

30-
fixed javaVersionFull =
31-
if (javaVersion == "17.0") "17.0.9+9"
32-
else "21.0.5+11"
30+
fixed javaVersionFull = if (javaVersion == "17.0") "17.0.9+9" else "21.0.5+11"
3331

3432
fixed jdkVersionAlt = javaVersionFull.replaceLast("+", "_")
3533

@@ -38,21 +36,24 @@ fixed majorJdkVersion = javaVersionFull.split(".").first
3836
fixed jdkGitHubReleaseName =
3937
let (ver =
4038
// 17.0.9+9 is missing some binaries (see https://github.com/adoptium/adoptium-support/issues/994)
41-
if (javaVersionFull == "17.0.9+9" && os == "windows") "jdk-17.0.9+9.1"
42-
else "jdk-\(javaVersionFull)"
39+
if (javaVersionFull == "17.0.9+9" && os == "windows")
40+
"jdk-17.0.9+9.1"
41+
else
42+
"jdk-\(javaVersionFull)"
4343
)
4444
URI.encodeComponent(ver)
4545

46-
fixed gradleArgs = new Listing {
47-
"--info"
48-
"--stacktrace"
49-
"-DtestReportsDir=${HOME}/test-results"
50-
"-DpklMultiJdkTesting=true"
51-
when (isRelease) {
52-
"-DreleaseBuild=true"
53-
}
54-
...extraGradleArgs
55-
}.join(" ")
46+
fixed gradleArgs =
47+
new Listing {
48+
"--info"
49+
"--stacktrace"
50+
"-DtestReportsDir=${HOME}/test-results"
51+
"-DpklMultiJdkTesting=true"
52+
when (isRelease) {
53+
"-DreleaseBuild=true"
54+
}
55+
...extraGradleArgs
56+
}.join(" ")
5657

5758
extraGradleArgs: Listing<String>
5859

@@ -84,7 +85,8 @@ job: Config.Job = new {
8485
new Config.RunStep {
8586
name = "Set up environment"
8687
shell = "bash.exe"
87-
command = #"""
88+
command =
89+
#"""
8890
# install jdk
8991
curl -Lf \
9092
https://github.com/adoptium/temurin\#(majorJdkVersion)-binaries/releases/download/\#(jdkGitHubReleaseName)/OpenJDK\#(majorJdkVersion)U-jdk_x64_windows_hotspot_\#(jdkVersionAlt).zip -o /tmp/jdk.zip

.circleci/jobs/SimpleGradleJob.pkl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ javaVersion = "21.0"
2828
steps {
2929
new Config.RunStep {
3030
name = module.name
31-
command = """
31+
command =
32+
"""
3233
./gradlew \(module.gradleArgs) \(module.command)
3334
"""
3435
}

0 commit comments

Comments
 (0)