From 2c40116c2c037e4c7b961a5a6c0c5aa6d842cffd Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 15 Oct 2024 21:55:15 +0100 Subject: [PATCH 1/6] fix(local): correct failure message --- toolchain/local/select/repository.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolchain/local/select/repository.bzl b/toolchain/local/select/repository.bzl index fc6ef25..c84f4a3 100644 --- a/toolchain/local/select/repository.bzl +++ b/toolchain/local/select/repository.bzl @@ -43,7 +43,7 @@ def implementation(rctx): path = rctx.path(workspace) if not path.exists: - fail("Missing `{}` for `{}`: {}".format(label, select, path)) + fail("Missing `{}` for `{}`: {}".format(canon, rctx.name, path)) rctx.delete(".") rctx.symlink(path.dirname, ".") -- GitLab From 0fbf9c6fd718736a6dc9c590b6657c5c0e693e7f Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 15 Oct 2024 22:01:59 +0100 Subject: [PATCH 2/6] fix: switch to `REPO.bazel` from `WORKSPACE` --- toolchain/export/symlink/repository.bzl | 2 +- toolchain/local/select/repository.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/toolchain/export/symlink/repository.bzl b/toolchain/export/symlink/repository.bzl index 3f5f669..672e4ea 100644 --- a/toolchain/export/symlink/repository.bzl +++ b/toolchain/export/symlink/repository.bzl @@ -11,7 +11,7 @@ ATTRS = { def implementation(rctx): label = rctx.attr.target - workspace = label.relative(":WORKSPACE") + workspace = label.relative(":REPO.bazel") path = rctx.path(workspace) if not path.exists: fail("Failed to find `{}`, can only symlink repository labels.".format(path, label)) diff --git a/toolchain/local/select/repository.bzl b/toolchain/local/select/repository.bzl index c84f4a3..4597e5c 100644 --- a/toolchain/local/select/repository.bzl +++ b/toolchain/local/select/repository.bzl @@ -39,7 +39,7 @@ def canonical(rctx, label): def implementation(rctx): label = resolve(rctx.attr.map, no_match_error = rctx.attr.no_match_error) canon = canonical(rctx, label) - workspace = Label("{}//:WORKSPACE".format(canon)) + workspace = Label("{}//:REPO.bazel".format(canon)) path = rctx.path(workspace) if not path.exists: -- GitLab From 63ad1ecf0048fb140feef02bad9c6b79d89cf6e7 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 15 Oct 2024 22:04:09 +0100 Subject: [PATCH 3/6] ci: test multiple Bazel versions --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 402c56b..0472da6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,6 +35,9 @@ test: CONFIG: - local - remote + USE_BAZEL_VERSION: + - 7.x + - last_rc script: - (cd "${ROOT}"; bazelisk build --config="${CONFIG}" //...) - (cd "${ROOT}"; bazelisk test --config="${CONFIG}" //...) -- GitLab From e41df679f3daaa344d2c00da3f5dae241f124a4f Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 15 Oct 2024 22:07:12 +0100 Subject: [PATCH 4/6] ci: disable lockfile validation --- .bazelrc.ci | 2 +- e2e/.bazelrc.ci | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bazelrc.ci b/.bazelrc.ci index 038267c..b1766b9 100644 --- a/.bazelrc.ci +++ b/.bazelrc.ci @@ -26,7 +26,7 @@ test --test_output=errors test --test_verbose_timeout_warnings # Validate that the lockfile is correct -common --lockfile_mode=error +common --lockfile_mode=off # These locations are cached on the CI build:local --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk diff --git a/e2e/.bazelrc.ci b/e2e/.bazelrc.ci index 038267c..b1766b9 100644 --- a/e2e/.bazelrc.ci +++ b/e2e/.bazelrc.ci @@ -26,7 +26,7 @@ test --test_output=errors test --test_verbose_timeout_warnings # Validate that the lockfile is correct -common --lockfile_mode=error +common --lockfile_mode=off # These locations are cached on the CI build:local --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk -- GitLab From 7cb0c4b595dbc625adaeb19322dd77816f24ba01 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 15 Oct 2024 22:25:23 +0100 Subject: [PATCH 5/6] ci: optimise test jobs --- .bazelrc.ci | 2 +- .gitlab-ci.yml | 43 ++++++++++++++++++++++++++++++------------- e2e/.bazelrc.ci | 2 +- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/.bazelrc.ci b/.bazelrc.ci index b1766b9..8f8d31a 100644 --- a/.bazelrc.ci +++ b/.bazelrc.ci @@ -26,7 +26,7 @@ test --test_output=errors test --test_verbose_timeout_warnings # Validate that the lockfile is correct -common --lockfile_mode=off +common --lockfile_mode=${CI_LOCKFILE_MODE} # These locations are cached on the CI build:local --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0472da6..e6ddc74 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,39 +14,56 @@ include: CI_COMMIT_REF_NAME CI_COMMIT_SHA CI_SERVER_HOST + CI_LOCKFILE_MODE default: tags: - arm64 -test: +.test: extends: .bazelisk cache: - !reference [.bazelisk, cache] - key: "bazel-cache-${CI_PROJECT_ID}" paths: - - ".cache/bazel/disk" - - ".cache/bazel/repo" + - ".cache/bazel/disk" + - ".cache/bazel/repo" + variables: + CI_LOCKFILE_MODE: error + CONFIG: local + script: + - (cd "${ROOT}"; bazelisk test --config="${CONFIG}" //...) + +config: + extends: .test parallel: matrix: - ROOT: - - . - - e2e + - . + - e2e CONFIG: - - local - - remote + - local + - remote + +version: + extends: .test + variables: + CI_LOCKFILE_MODE: "off" + parallel: + matrix: + - ROOT: + - . + - e2e USE_BAZEL_VERSION: - - 7.x - - last_rc - script: - - (cd "${ROOT}"; bazelisk build --config="${CONFIG}" //...) - - (cd "${ROOT}"; bazelisk test --config="${CONFIG}" //...) + - 7.x + - last_rc # TODO: switch this out for `rules_semantic_release` semantic-release: stage: .post needs: - - test + - config + - version image: node:lts cache: key: diff --git a/e2e/.bazelrc.ci b/e2e/.bazelrc.ci index b1766b9..8f8d31a 100644 --- a/e2e/.bazelrc.ci +++ b/e2e/.bazelrc.ci @@ -26,7 +26,7 @@ test --test_output=errors test --test_verbose_timeout_warnings # Validate that the lockfile is correct -common --lockfile_mode=off +common --lockfile_mode=${CI_LOCKFILE_MODE} # These locations are cached on the CI build:local --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk -- GitLab From 04e103870044ec2ad7d371d81027d6c202582ddb Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 15 Oct 2024 22:28:04 +0100 Subject: [PATCH 6/6] ci: extend `.test` for `semantic-release` Ensures that we have the correct setup for Bazel commands in `semantic-release`. --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e6ddc74..b2aa015 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -60,6 +60,7 @@ version: # TODO: switch this out for `rules_semantic_release` semantic-release: + extends: .test stage: .post needs: - config -- GitLab