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. // limitations under the License.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// File gets rendered to .circleci/config.yml via git hook. // 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/BuildNativeJob.pkl"
import "jobs/GradleCheckJob.pkl" import "jobs/GradleCheckJob.pkl"

View File

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

View File

@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
extends "GradleJob.pkl" 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 local self = this
@@ -28,8 +28,8 @@ job {
} }
steps { steps {
new CircleCI.AttachWorkspaceStep { at = "." } new Config.AttachWorkspaceStep { at = "." }
new CircleCI.RunStep { new Config.RunStep {
command = "./gradlew \(self.gradleArgs) \(module.command)" command = "./gradlew \(self.gradleArgs) \(module.command)"
} }
} }

View File

@@ -15,12 +15,12 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
extends "GradleJob.pkl" 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" javaVersion: "11.0"|"17.0"
steps { steps {
new CircleCI.RunStep { new Config.RunStep {
name = "gradle check" name = "gradle check"
command = "./gradlew \(module.gradleArgs) check" command = "./gradlew \(module.gradleArgs) check"
} }

View File

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

View File

@@ -15,14 +15,14 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
extends "GradleJob.pkl" 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 name: String = command
command: String command: String
steps { steps {
new CircleCI.RunStep { new Config.RunStep {
name = module.name name = module.name
command = """ command = """
./gradlew \(module.gradleArgs) \(module.command) ./gradlew \(module.gradleArgs) \(module.command)