diff --git a/.bazelignore b/.bazelignore index d020514c4eabce6a9458560577805d6cd6554f97..826a06aa4ed44398cb1eb77aeea5043127d32543 100644 --- a/.bazelignore +++ b/.bazelignore @@ -1,2 +1,3 @@ rules_download rules_toolchain +.cache diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f9ffccce60fcab9cbc48bdfa03db7d431fe3928d..a3c376557a81a35f36a300657dc77088f3966928 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,9 +14,6 @@ bootstrap: image: node:lts variables: NPM_CACHE: "${CI_PROJECT_DIR}/.cache/npm" - cache: - key: "bazelisk-node-0" - paths: !reference [.bazelisk, cache, paths] before_script: - | cat <<"EOF" | tee /usr/local/bin/bazelisk diff --git a/README.md b/README.md index 46c947e0b896ddbb73fbb18e16731f245889af3f..1dd4462f32605ca47decef3c5e0e856e2124170f 100644 --- a/README.md +++ b/README.md @@ -83,8 +83,20 @@ custom: extends: .bazelisk script: - !reference [.bazelisk-fragment, rc] - - bazelisk build //... - - bazelisk run //... + - | + bazelisk \ + --output_user_root=$BAZEL_OUTPUT_USER_ROOT \ + build \ + --disk_cache=$BAZEL_DISK_CACHE \ + --repository_cache=$BAZEL_REPOSITORY_CACHE \ + //... + - | + bazelisk \ + --output_user_root=$BAZEL_OUTPUT_USER_ROOT \ + run \ + --disk_cache=$BAZEL_DISK_CACHE \ + --repository_cache=$BAZEL_REPOSITORY_CACHE \ + //... ``` [gitlab-ci-reference]: https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html#reference-tags diff --git a/template.yml b/template.yml index 9c44a057f4b8558c1605b7a728b07ab5e235279b..a0e5a36be19235d353ad8cd702e1c81e59d13da5 100644 --- a/template.yml +++ b/template.yml @@ -18,8 +18,22 @@ spec: default: //... root: default: . - key: - default: "bazelisk-1" + bazelisk_home: + default: "$CI_PROJECT_DIR/.cache/bazelisk" + bazelisk_home_key: + default: "bazelisk-home" + output_user_root: + default: "$CI_PROJECT_DIR/.cache/bazel-output-user-root" + output_user_root_key: + default: "bazel-output-user-root" + disk_cache: + default: "$CI_PROJECT_DIR/.cache/bazel-disk-cache" + disk_cache_key: + default: "bazel-disk-cache" + repository_cache: + default: "$CI_PROJECT_DIR/.cache/bazel-repository-cache" + repository_cache_key: + default: "bazel-repository-cache" --- .bazelisk-fragment: rc: @@ -34,7 +48,12 @@ spec: execute: - cd "${ROOT}" - > - "$[[inputs.bazelisk]]" "$[[inputs.command]]" "$[[inputs.target]]" + "$[[inputs.bazelisk]]" \ + "--output_user_root=$[[inputs.output_user_root]]" \ + "$[[inputs.command]]" \ + "--disk_cache=$[[inputs.disk_cache]]" \ + "--repository_cache=$[[inputs.repository_cache]]" \ + "$[[inputs.target]]" - cd - testlogs: # https://gitlab.com/gitlab-org/gitlab/-/issues/19746 - | @@ -57,12 +76,27 @@ spec: image: "$[[inputs.image]]:$[[inputs.tag]]" variables: ROOT: "$[[inputs.root]]" - BAZELISK_HOME: "${CI_PROJECT_DIR}/.cache/bazelisk" + BAZELISK_HOME: "$[[inputs.bazelisk_home]]" + BAZEL_OUTPUT_USER_ROOT: "$[[inputs.output_user_root]]" + BAZEL_DISK_CACHE: "$[[inputs.disk_cache]]" + BAZEL_REPOSITORY_CACHE: "$[[inputs.repository_cache]]" cache: - key: "$[[inputs.key]]" - paths: - - ".cache" - when: always + - key: "$[[inputs.bazelisk_home_key]]" + paths: + - "$[[inputs.bazelisk_home]]" + when: always + - key: "$[[inputs.output_user_root_key]]" + paths: + - "$[[inputs.output_user_root]]" + when: always + - key: "$[[inputs.repository_cache_key]]" + paths: + - "$[[inputs.repository_cache]]" + when: always + - key: "$[[inputs.disk_cache_key]]" + paths: + - "$[[inputs.disk_cache]]" + when: always script: - !reference [.bazelisk-fragment, rc] - !reference [.bazelisk-fragment, execute]