Skip to content

Commit

Permalink
Use packages for CircleCI definition (apple#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
bioball authored Feb 8, 2024
1 parent 8e6ddfb commit 9dc7eb2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 9 additions & 10 deletions .circleci/jobs/BuildNativeJob.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]#/Config.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/[email protected]#/URI.pkl"

/// The OS to run on
os: "macOS"|"linux"
Expand All @@ -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")
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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/"
Expand Down
6 changes: 3 additions & 3 deletions .circleci/jobs/DeployJob.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)"
}
}
4 changes: 2 additions & 2 deletions .circleci/jobs/GradleCheckJob.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
10 changes: 5 additions & 5 deletions .circleci/jobs/GradleJob.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = """
Expand All @@ -46,7 +46,7 @@ job: CircleCI.Job = new {
"""
`when` = "always"
}
new CircleCI.StoreTestResults {
new Config.StoreTestResults {
path = "~/test-results"
}
}
Expand Down
4 changes: 2 additions & 2 deletions .circleci/jobs/SimpleGradleJob.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9dc7eb2

Please sign in to comment.