Use packages for CircleCI definition (#95)

This commit is contained in:
Daniel Chao
2024-02-08 09:58:29 -08:00
committed by Dan Chao
parent 3a7ccc2128
commit bb90343ae0
6 changed files with 22 additions and 23 deletions

View File

@@ -14,7 +14,7 @@
// limitations under the License.
//===----------------------------------------------------------------------===//
// File gets rendered to .circleci/config.yml via git hook.
amends ".../pkl-project-commons/packages/pkl.impl.circleci/PklCI.pkl"
amends "package://pkg.pkl-lang.org/pkl-project-commons/pkl.impl.circleci@1.0.1#/PklCI.pkl"
import "jobs/BuildNativeJob.pkl"
import "jobs/GradleCheckJob.pkl"

View File

@@ -16,9 +16,8 @@
/// Builds the native `pkl` CLI
extends "GradleJob.pkl"
// TODO(oss) replace these with package imports
import ".../pkl-pantry/packages/com.circleci.v2/CircleCI.pkl"
import ".../pkl-pantry/packages/pkl.experimental.uri/URI.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.0.0#/Config.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1.0.0#/URI.pkl"
/// The OS to run on
os: "macOS"|"linux"
@@ -29,7 +28,7 @@ arch: "amd64"|"aarch64"
/// Whether to link to musl. Otherwise, links to glibc.
musl: Boolean = false
local setupLinuxEnvironment: CircleCI.RunStep =
local setupLinuxEnvironment: Config.RunStep =
let (jdkVersion = "11.0.20.1+1")
let (muslVersion = "1.2.2")
let (zlibVersion = "1.2.13")
@@ -96,12 +95,12 @@ local setupLinuxEnvironment: CircleCI.RunStep =
steps {
when (os == "linux") {
new CircleCI.RestoreCacheStep {
new Config.RestoreCacheStep {
name = "Restore static deps from cache"
key = "staticdeps-\(arch)"
}
setupLinuxEnvironment
new CircleCI.SaveCacheStep {
new Config.SaveCacheStep {
name = "Save statics deps to cache"
key = "staticdeps-\(arch)"
paths {
@@ -110,7 +109,7 @@ steps {
}
}
when (os == "macOS" && arch == "amd64") {
new CircleCI.RunStep {
new Config.RunStep {
name = "Installing Rosetta 2"
command = """
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
@@ -121,11 +120,11 @@ steps {
// We can't use GraalVM 23 for any other build because we need to support Java 11, which was
// dropped in GraalVM 23.
when (os == "macOS" && arch == "aarch64") {
new CircleCI.RunStep {
new Config.RunStep {
command = "git apply patches/graalVm23.patch"
}
}
new CircleCI.RunStep {
new Config.RunStep {
name = "gradle buildNative"
local _os =
if (os == "macOS") "mac"
@@ -137,7 +136,7 @@ steps {
./gradlew \#(module.gradleArgs) pkl-cli:\#(jobName) pkl-core:test\#(jobName.capitalize())
"""#
}
new CircleCI.PersistToWorkspaceStep {
new Config.PersistToWorkspaceStep {
root = "."
paths {
"pkl-cli/build/executable/"

View File

@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
extends "GradleJob.pkl"
import ".../pkl-pantry/packages/com.circleci.v2/CircleCI.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.0.0#/Config.pkl"
local self = this
@@ -28,8 +28,8 @@ job {
}
steps {
new CircleCI.AttachWorkspaceStep { at = "." }
new CircleCI.RunStep {
new Config.AttachWorkspaceStep { at = "." }
new Config.RunStep {
command = "./gradlew \(self.gradleArgs) \(module.command)"
}
}

View File

@@ -15,12 +15,12 @@
//===----------------------------------------------------------------------===//
extends "GradleJob.pkl"
import ".../pkl-pantry/packages/com.circleci.v2/CircleCI.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.0.0#/Config.pkl"
javaVersion: "11.0"|"17.0"
steps {
new CircleCI.RunStep {
new Config.RunStep {
name = "gradle check"
command = "./gradlew \(module.gradleArgs) check"
}

View File

@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
abstract module GradleJob
import ".../pkl-pantry/packages/com.circleci.v2/CircleCI.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.0.0#/Config.pkl"
/// Whether this is a release build or not.
isRelease: Boolean = false
@@ -28,16 +28,16 @@ fixed gradleArgs = new Listing {
}
}.join(" ")
steps: Listing<CircleCI.Step>
steps: Listing<Config.Step>
job: CircleCI.Job = new {
job: Config.Job = new {
environment {
["LANG"] = "en_US.UTF-8"
}
steps {
"checkout"
...module.steps
new CircleCI.RunStep {
new Config.RunStep {
// find all test results and write them to the home dir
name = "Gather test results"
command = """
@@ -46,7 +46,7 @@ job: CircleCI.Job = new {
"""
`when` = "always"
}
new CircleCI.StoreTestResults {
new Config.StoreTestResults {
path = "~/test-results"
}
}

View File

@@ -15,14 +15,14 @@
//===----------------------------------------------------------------------===//
extends "GradleJob.pkl"
import ".../pkl-pantry/packages/com.circleci.v2/CircleCI.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.0.0#/Config.pkl"
name: String = command
command: String
steps {
new CircleCI.RunStep {
new Config.RunStep {
name = module.name
command = """
./gradlew \(module.gradleArgs) \(module.command)