diff --git a/packages/com.gitlab.ci.schema/Cache.pkl b/packages/com.gitlab.ci.schema/Cache.pkl index b9cf6e2..b584d46 100644 --- a/packages/com.gitlab.ci.schema/Cache.pkl +++ b/packages/com.gitlab.ci.schema/Cache.pkl @@ -6,11 +6,14 @@ module com.gitlab.ci.schema.Cache import "gitlab.pkl" +/// CacheKey defines a cache key +typealias CacheKey = String(matches(Regex(#"^(?!.*\/)^(.*[^.]+.*)$"#)))|gitlab.KeySpec + /// Use the `cache:key` keyword to give each cache a unique identifying key. /// All jobs that use the same cache key use the same cache, including in different pipelines. /// Must be used with `cache:path`, or nothing is cached. /// [Learn More](https://docs.gitlab.com/ee/ci/yaml/#cachekey). -key: String(matches(Regex(#"^(?!.*\/)^(.*[^.]+.*)$"#)))|gitlab.KeySpec +key: CacheKey? /// Use the `cache:paths` keyword to choose which files or directories to cache. /// [Learn More](https://docs.gitlab.com/ee/ci/yaml/#cachepaths) diff --git a/packages/com.gitlab.ci.schema/PklProject b/packages/com.gitlab.ci.schema/PklProject index ffcb98c..52706a8 100644 --- a/packages/com.gitlab.ci.schema/PklProject +++ b/packages/com.gitlab.ci.schema/PklProject @@ -1,7 +1,7 @@ amends ".../basePklProject.pkl" package { - version = "0.1.0" + version = "0.1.1" description = """ Package that provides the schema for GitlabCI """ diff --git a/packages/com.gitlab.ci.schema/examples/pipeline/basic.pkl b/packages/com.gitlab.ci.schema/examples/pipeline/basic.pkl index 5fabb28..8f70f85 100644 --- a/packages/com.gitlab.ci.schema/examples/pipeline/basic.pkl +++ b/packages/com.gitlab.ci.schema/examples/pipeline/basic.pkl @@ -28,6 +28,15 @@ local class GolangJob extends AbstractJob { image = gitlab.dockerHubImage("golang", "1.12") } +cache { + key = "gradle-build" + policy = "pull-push" + paths { + "build" + } +} + + /// Jobs jobs { diff --git a/packages/com.gitlab.ci.schema/tests/pipeline.pkl-expected.pcf b/packages/com.gitlab.ci.schema/tests/pipeline.pkl-expected.pcf index b6614ba..b23e577 100644 --- a/packages/com.gitlab.ci.schema/tests/pipeline.pkl-expected.pcf +++ b/packages/com.gitlab.ci.schema/tests/pipeline.pkl-expected.pcf @@ -6,6 +6,12 @@ examples { - name: docker.io/library/postgres:14-bookworm pull_policy: if-not-present - docker.io/library/docker:dind-rootless + cache: + key: gradle-build + paths: + - build + policy: pull-push + when: on_success stages: - build - test