From a6ee52ee895d02db5de6d06abb18492cd8a917a0 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Wed, 4 Dec 2024 15:52:27 +0000 Subject: [PATCH 1/2] docs: add descriptions for `bazelisk` inputs --- templates/bazelisk.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/templates/bazelisk.yml b/templates/bazelisk.yml index aee6904..1f5024a 100644 --- a/templates/bazelisk.yml +++ b/templates/bazelisk.yml @@ -2,28 +2,39 @@ spec: inputs: image: default: registry.gitlab.arm.com/ci/component/bazelisk + description: "Open container image (OCI) to use." tag: default: latest + description: "Open container image (OCI) tag for the image." stage: default: test + description: "`.bazelisk` job stage." src: default: .bazelrc.ci + description: "Bazel run commands to perform variable replacement on." dst: default: .bazelrc.user + description: "Destination file for the Bazel run commands variable replacement." bazelisk: default: bazelisk + description: "The `bazelisk` CLI location." command: default: test + description: "The `bazelisk` CLI command." target: default: //... + description: "The `bazelisk` CLI target." root: default: . + description: "The root directory of the Bazel module." key: default: "bazelisk-1" + description: "The GitLab CI cache key." variables: default: | CI_PROJECT_DIR CI_PROJECT_ID + description: "Variables to perform environment variable replacement in the Bazel run commands." --- .bazelisk-fragment: rc: -- GitLab From 7cdac80b86e9594889135060505d616357af7ba4 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Wed, 4 Dec 2024 15:52:39 +0000 Subject: [PATCH 2/2] feat: add `ruleset` template --- templates/ruleset/.job.yml | 54 ++++++++++++++++++++++++++ templates/ruleset/config.yml | 25 ++++++++++++ templates/ruleset/semantic-release.yml | 39 +++++++++++++++++++ templates/ruleset/template.yml | 27 +++++++++++++ templates/ruleset/version.yml | 32 +++++++++++++++ 5 files changed, 177 insertions(+) create mode 100644 templates/ruleset/.job.yml create mode 100644 templates/ruleset/config.yml create mode 100644 templates/ruleset/semantic-release.yml create mode 100644 templates/ruleset/template.yml create mode 100644 templates/ruleset/version.yml diff --git a/templates/ruleset/.job.yml b/templates/ruleset/.job.yml new file mode 100644 index 0000000..eea7931 --- /dev/null +++ b/templates/ruleset/.job.yml @@ -0,0 +1,54 @@ +spec: + inputs: + image: + default: registry.gitlab.arm.com/ci/component/bazelisk + description: "Open container image (OCI) to use." + tag: + default: latest + description: "Open container image (OCI) tag for the image." + config: + default: local + description: "The default `--config` to use for the `.job` template." + regex: ^\w+$ + lockfile: + default: error + description: "The value for `CI_LOCKFILE_MODE` environment variable." + options: + - off + - refresh + - update + - error +--- +include: + - local: "/templates/bazelisk.yml" + inputs: + image: "$[[inputs.image]]" + tag: "$[[inputs.tag]]" + variables: | + CI_PROJECT_DIR + CI_PROJECT_ID + CI_REMOTE_EXECUTOR + CI_REMOTE_CACHE + CI_REMOTE_HEADER + CI_REMOTE_JOBS + CI_BES_RESULTS_URL + CI_BES_BACKEND + CI_PROJECT_URL + CI_COMMIT_REF_NAME + CI_COMMIT_SHA + CI_SERVER_HOST + CI_LOCKFILE_MODE + +.job: + extends: .bazelisk + cache: + - !reference [.bazelisk, cache] + - key: "bazel-cache-${CI_PROJECT_ID}" + paths: + - ".cache/bazel/disk" + - ".cache/bazel/repo" + variables: + CI_LOCKFILE_MODE: "$[[inputs.lockfile]]" + CONFIG: "$[[inputs.config]]" + script: + - cd "${ROOT}"; bazelisk test --config="${CONFIG}" //... diff --git a/templates/ruleset/config.yml b/templates/ruleset/config.yml new file mode 100644 index 0000000..14ad5ba --- /dev/null +++ b/templates/ruleset/config.yml @@ -0,0 +1,25 @@ +spec: + inputs: + image: + default: registry.gitlab.arm.com/ci/component/bazelisk + description: "Open container image (OCI) to use." + tag: + default: latest + description: "Open container image (OCI) tag for the image." +--- +include: + - local: "/templates/ruleset/.job.yml" + inputs: + image: "$[[inputs.image]]" + tag: "$[[inputs.tag]]" + +config: + extends: .job + parallel: + matrix: + - ROOT: + - . + - e2e + CONFIG: + - local + - remote diff --git a/templates/ruleset/semantic-release.yml b/templates/ruleset/semantic-release.yml new file mode 100644 index 0000000..0f01eae --- /dev/null +++ b/templates/ruleset/semantic-release.yml @@ -0,0 +1,39 @@ +spec: + inputs: + image: + default: registry.gitlab.arm.com/ci/component/bazelisk + description: "Open container image (OCI) to use." + tag: + default: latest + description: "Open container image (OCI) tag for the image." +--- +include: + - local: "/templates/ruleset/.job.yml" + inputs: + image: "$[[inputs.image]]" + tag: "$[[inputs.tag]]" + +# TODO: switch this out for `rules_semantic_release` +semantic-release: + extends: .job + stage: .post + image: node:lts + cache: + - key: + prefix: "node" + files: + - package-lock.json + paths: + - node_modules + - .cache/npm + - !reference [.job, cache] + before_script: + - npm config --location project set cache "${CI_PROJECT_DIR}/.cache/npm" + - npm ci --prefer-offline + script: + - !reference [.bazelisk-fragment, rc] + - npx semantic-release + rules: + - if: $CI_COMMIT_TAG + when: never + - if: $CI_COMMIT_REF_PROTECTED == "true" diff --git a/templates/ruleset/template.yml b/templates/ruleset/template.yml new file mode 100644 index 0000000..46f05b1 --- /dev/null +++ b/templates/ruleset/template.yml @@ -0,0 +1,27 @@ +spec: + inputs: + image: + default: registry.gitlab.arm.com/ci/component/bazelisk + description: "Open container image (OCI) to use." + tag: + default: latest + description: "Open container image (OCI) tag for the image." + minimum: + default: 7.4.0 + description: "The minimum Bazel version tested." + regex: ^\d+\.\d+\.\d+$ +--- +include: + - local: "/templates/ruleset/version.yml" + inputs: + image: "$[[inputs.image]]" + tag: "$[[inputs.tag]]" + minimum: "$[[inputs.minimum]]" + - local: "/templates/ruleset/config.yml" + inputs: + image: "$[[inputs.image]]" + tag: "$[[inputs.tag]]" + - local: "/templates/ruleset/semantic-release.yml" + inputs: + image: "$[[inputs.image]]" + tag: "$[[inputs.tag]]" diff --git a/templates/ruleset/version.yml b/templates/ruleset/version.yml new file mode 100644 index 0000000..02bced1 --- /dev/null +++ b/templates/ruleset/version.yml @@ -0,0 +1,32 @@ +spec: + inputs: + image: + default: registry.gitlab.arm.com/ci/component/bazelisk + description: "Open container image (OCI) to use." + tag: + default: latest + description: "Open container image (OCI) tag for the image." + minimum: + default: 7.4.0 + description: "The minimum Bazel version tested." + regex: ^\d+\.\d+\.\d+$ +--- +include: + - local: "/templates/ruleset/.job.yml" + inputs: + image: "$[[inputs.image]]" + tag: "$[[inputs.tag]]" + +version: + extends: .job + variables: + CI_LOCKFILE_MODE: "off" + parallel: + matrix: + - ROOT: + - . + - e2e + USE_BAZEL_VERSION: + - "$[[inputs.minimum]]" + - 7.x + - last_rc -- GitLab