Skip to content

Commit 35ba253

Browse files
authored
Initial implementation (#2)
2 parents b345d24 + 8c575a7 commit 35ba253

File tree

121 files changed

+5340
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+5340
-15
lines changed

.bazelignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
examples/
2+
3+
# Do not include other files and directories in tests/integration_test, which
4+
# need to live in this workspace.
5+
tests/integration_tests/example_workspaces/simple/bazel-bin
6+
tests/integration_tests/example_workspaces/simple/bazel-out
7+
tests/integration_tests/example_workspaces/simple/bazel-simple
8+
tests/integration_tests/example_workspaces/simple/bazel-testlogs
9+
tests/integration_tests/example_workspaces/pkl_cache/bazel-pkl_cache

.bazelrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
common --enable_bzlmod
2+
3+
build --incompatible_default_to_explicit_init_py
4+
5+
build --java_language_version=11
6+
build --java_runtime_version=11
7+
8+
test --test_output=all
9+
10+
# To update these lines, execute
11+
# `bazel run @rules_bazel_integration_test//tools:update_deleted_packages`
12+
build --deleted_packages=examples/pkl_project,examples/pkl_project/pkl,examples/simple,tests/integration_tests/example_workspaces/pkl_cache,tests/integration_tests/example_workspaces/simple
13+
query --deleted_packages=examples/pkl_project,examples/pkl_project/pkl,examples/simple,tests/integration_tests/example_workspaces/pkl_cache,tests/integration_tests/example_workspaces/simple

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.0.2

.circleci/config.pkl

Lines changed: 88 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,105 @@
1-
amends "../../pkl/.circleci/CircleCI.pkl"
1+
//===----------------------------------------------------------------------===//
2+
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// https://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//===----------------------------------------------------------------------===//
16+
// File gets rendered to .circleci/config.yml via git hook.
17+
amends "package://pkg.pkl-lang.org/pkl-project-commons/[email protected]#/PklCI.pkl"
218

3-
version = 2.1
19+
prb {
20+
jobs {
21+
"test"
22+
}
23+
}
24+
25+
main {
26+
jobs {
27+
"test"
28+
}
29+
}
430

531
jobs {
632
["test"] {
733
docker {
8-
new {
9-
image = "cimg/base"
34+
new { image = "gcr.io/bazel-public/bazel:7.1.1" }
35+
}
36+
steps {
37+
"checkout"
38+
new RunStep {
39+
name = "Buildifier lint"
40+
command = "bazel run buildifier"
1041
}
42+
new RunStep {
43+
name = "Bazel tests"
44+
command = "bazel test --curses=no --color=yes --show_timestamps //..."
45+
}
46+
}
47+
}
48+
["github-release"] {
49+
docker {
50+
new { image = "maniator/gh:v2.40.1" }
1151
}
1252
steps {
53+
local archiveName = "rules_pkl-$VERSION.tar.gz"
54+
new AttachWorkspaceStep { at = "." }
55+
new RunStep {
56+
name = "Setup environment"
57+
// There SHOULD be a better way to extract the bazel module version from the bazel metadata.
58+
command = """
59+
echo "export VERSION=$(bazel mod path rules_pkl | awk -F'@' '/rules_pkl/{ print substr($2, 1, length($2)-1) }')" >> $BASH_ENV
60+
"""
61+
}
62+
new RunStep {
63+
name = "Build archive"
64+
command = "tar -cavf \(archiveName) --anchored --exclude-from .tar-exclude-from-file.conf *"
65+
}
1366
new RunStep {
14-
command = "echo hello"
67+
name = "Publish release on GitHub"
68+
command = #"""
69+
gh release create "${CIRCLE_TAG}" \
70+
--title "${CIRCLE_TAG}" \
71+
--target "${CIRCLE_SHA1}" \
72+
--verify-tag \
73+
--repo "${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
74+
\#(archiveName)
75+
"""#
1576
}
1677
}
1778
}
1879
}
1980

20-
workflows {
21-
["main"] {
22-
`when` {
23-
equal {
24-
#"main"#
25-
module.pipelineValues.`pipeline.git.branch`
81+
circleCi {
82+
workflows {
83+
["release-branch"] {
84+
jobs = new Listing<Mapping<String, WorkflowJob>> {
85+
new {
86+
["hold"] {
87+
type = "approval"
88+
}
89+
}
90+
new {
91+
["pr-approval/authenticate"] {
92+
context = "pkl-pr-approval"
93+
}
94+
}
95+
for (job in super.jobs) {
96+
(if (job is Mapping) job else new Mapping<String, WorkflowJob> { [job] {} }) {
97+
local thisMapping = this
98+
[thisMapping.keys.first] {
99+
requires { "hold" }
100+
}
101+
}
102+
}
26103
}
27104
}
28105
}

.circleci/config.yml

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,64 @@
11
# Generated from CircleCI.pkl. DO NOT EDIT.
2-
version: 2.1
2+
version: '2.1'
3+
orbs:
4+
pr-approval: apple/[email protected]
35
jobs:
46
test:
57
steps:
8+
- checkout
69
- run:
7-
command: echo hello
10+
command: bazel run buildifier
11+
name: Buildifier lint
12+
- run:
13+
command: bazel test --curses=no --color=yes --show_timestamps //...
14+
name: Bazel tests
815
docker:
9-
- image: cimg/base
16+
- image: gcr.io/bazel-public/bazel:7.1.1
17+
github-release:
18+
steps:
19+
- attach_workspace:
20+
at: '.'
21+
- run:
22+
command: echo "export VERSION=$(bazel mod path rules_pkl | awk -F'@' '/rules_pkl/{ print substr($2, 1, length($2)-1) }')" >> $BASH_ENV
23+
name: Setup environment
24+
- run:
25+
command: tar -cavf rules_pkl-$VERSION.tar.gz --anchored --exclude-from .tar-exclude-from-file.conf *
26+
name: Build archive
27+
- run:
28+
command: |-
29+
gh release create "${CIRCLE_TAG}" \
30+
--title "${CIRCLE_TAG}" \
31+
--target "${CIRCLE_SHA1}" \
32+
--verify-tag \
33+
--repo "${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
34+
rules_pkl-$VERSION.tar.gz
35+
name: Publish release on GitHub
36+
docker:
37+
- image: maniator/gh:v2.40.1
1038
workflows:
39+
prb:
40+
jobs:
41+
- hold:
42+
type: approval
43+
- pr-approval/authenticate:
44+
context: pkl-pr-approval
45+
- test:
46+
requires:
47+
- hold
48+
when:
49+
matches:
50+
value: << pipeline.git.branch >>
51+
pattern: ^pull/\d+(/head)?$
1152
main:
12-
jobs: []
53+
jobs:
54+
- test
1355
when:
1456
equal:
1557
- main
1658
- << pipeline.git.branch >>
59+
release-branch:
60+
jobs:
61+
- hold:
62+
type: approval
63+
- pr-approval/authenticate:
64+
context: pkl-pr-approval

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The normal release process for a ruleset is to run `git archive` to generate the tarball or zip file.
2+
# We strip out anything that isn't strictly necessary at runtime by users.
3+
/.bazel* export-ignore
4+
/.git* export-ignore
5+
/.pre-commit-config.yaml export-ignore
6+
/docs export-ignore
7+
/examples export-ignore
8+
/renovate.json export-ignore

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
*~
2+
3+
# macOS
4+
.DS_STORE
5+
6+
# IntelliJ
7+
.idea/
8+
.ijwb
9+
*.iml
10+
!.idea/codestyles/
11+
!.idea/inspectionProfiles/
12+
!.idea/runConfigurations/
13+
!.idea/scopes/
14+
!.idea/vcs.xml
15+
16+
# Bazel
17+
bazel-*
18+
/examples/*/bazel-*
19+
/tests/*/bazel-*
20+
MODULE.bazel.lock

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v3.2.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
exclude: '(tests/pkl_eval/expected/filtered_animals.pcf|docs/rules_pkl_docs.md)'
10+
- id: check-yaml
11+
- id: check-added-large-files
12+
13+
- repo: https://github.com/keith/pre-commit-buildifier
14+
rev: 6.4.0
15+
hooks:
16+
- id: buildifier
17+
- id: buildifier-lint

.tar-exclude-from-file.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.circleci
2+
examples
3+
bazel-bin
4+
bazel-out
5+
bazel-rules_pkl
6+
bazel-testlogs

BUILD.bazel

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
15+
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
16+
17+
gazelle_binary(
18+
name = "gazelle_bin",
19+
languages = ["@bazel_skylib_gazelle_plugin//bzl"],
20+
)
21+
22+
gazelle(
23+
name = "gazelle",
24+
gazelle = "gazelle_bin",
25+
)
26+
27+
filegroup(
28+
name = "workspace_files",
29+
srcs = [
30+
"BUILD.bazel",
31+
"MODULE.bazel",
32+
"WORKSPACE",
33+
"//pkl:all_files",
34+
"//pkl/private:all_files",
35+
"//pkl/private/org/pkl_lang/bazel/symlinks:all_files",
36+
],
37+
visibility = ["//tests/integration_tests:__subpackages__"],
38+
)
39+
40+
buildifier(
41+
name = "buildifier",
42+
lint_mode = "warn",
43+
mode = "check",
44+
)

0 commit comments

Comments
 (0)