Skip to content

Commit

Permalink
fix: fix cache key error
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Tomasi <dominik.tomasi@gmail.com>
  • Loading branch information
dtomasi committed Apr 30, 2024
1 parent d2bc6b4 commit b5d0597
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/com.gitlab.ci.schema/Cache.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/com.gitlab.ci.schema/PklProject
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
amends ".../basePklProject.pkl"

package {
version = "0.1.0"
version = "0.1.1"
description = """
Package that provides the schema for GitlabCI
"""
Expand Down
9 changes: 9 additions & 0 deletions packages/com.gitlab.ci.schema/examples/pipeline/basic.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
6 changes: 6 additions & 0 deletions packages/com.gitlab.ci.schema/tests/pipeline.pkl-expected.pcf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b5d0597

Please sign in to comment.