diff --git a/templates/bazelisk.yml b/templates/bazelisk.yml index aee690476c31c6536d954fa44e19fabb5dc02940..1f5024a78ece62e02a238ee3f5afdbe2c395c23c 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: diff --git a/templates/ruleset/.job.yml b/templates/ruleset/.job.yml new file mode 100644 index 0000000000000000000000000000000000000000..eea7931f162d7da44d5cc3b0bb5d57ec31e4930f --- /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 0000000000000000000000000000000000000000..14ad5ba3f22f60c3eb22e148b3d8e9d99f1f2985 --- /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 0000000000000000000000000000000000000000..0f01eae9cfeeced33614cafc8233cd2fc7fcde85 --- /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 0000000000000000000000000000000000000000..46f05b17120973bb7a766abba7d161e6bfa90c0f --- /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 0000000000000000000000000000000000000000..02bced14e0128ae068bd60829dc4989c6718ef47 --- /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