Skip to content

Commit aa8222a

Browse files
AlexanderLaninCopilot
andauthored
feat: provide tools via bazel in addition to devcontainer (#116)
Readable docs: https://github.com/eclipse-score/devcontainer/blob/bazel/tools/README.md Usage example: eclipse-score/docs-as-code#511 --------- Co-authored-by: Copilot <copilot@github.com>
1 parent 1aa6194 commit aa8222a

31 files changed

Lines changed: 1761 additions & 217 deletions

.devcontainer/post_create_command.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@
1414
# *******************************************************************************
1515

1616
npm install -g @devcontainers/cli
17+
18+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
19+
REPOSITORY_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd -P)"
20+
21+
sudo "${REPOSITORY_ROOT}/tools/tool_installer.py" install shellcheck yamlfmt
22+
1723
pre-commit install
1824

1925
scripts/create_builder.sh
20-
21-
sudo apt-get update && sudo apt-get install -y shellcheck

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,12 @@
1515
# Exported image files shall never be committed.
1616
/export.img
1717
build/
18+
19+
# bazel files
20+
/bazel-*
21+
22+
# AI
23+
/.codex
24+
25+
# Python files
26+
*.pyc

.pre-commit-config.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@ repos:
2222
- id: check-executables-have-shebangs
2323
- id: check-added-large-files
2424
args: [--maxkb=50, --enforce-all] # increase or add git lfs if too strict
25-
- repo: https://github.com/google/yamlfmt
26-
rev: 21ca5323a9c87ee37a434e0ca908efc0a89daa07 # v0.21.0
25+
exclude: ^MODULE\.bazel\.lock$
26+
- repo: local
2727
hooks:
2828
- id: yamlfmt
29-
- repo: https://github.com/jumanjihouse/pre-commit-hooks
30-
rev: 38980559e3a605691d6579f96222c30778e5a69e # 3.0.0
31-
hooks:
29+
name: yamlfmt
30+
entry: tools/run_tool.sh yamlfmt
31+
language: system
32+
types: [yaml]
3233
- id: shellcheck
34+
name: shellcheck
35+
entry: tools/run_tool.sh shellcheck
36+
language: system
37+
types: [shell]
3338
- repo: https://github.com/eclipse-score/tooling
3439
rev: 31ff8eee214e4e97ef8f5cb46e443273515b63ec
3540
hooks:

.shellcheckrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ disable=SC2046
2424

2525
# optional checks, fixes might not be easy and better not break the code
2626
disable=SC2292,SC2154,SC2312
27+
28+
# SC1091: Not following sourced files that are not specified as input
29+
disable=SC1091

MODULE.bazel

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
module(name = "score_devcontainer")
15+
16+
bazel_dep(name = "rules_multitool", version = "1.11.1")
17+
18+
multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
19+
20+
multitool.hub(lockfile = "//tools:lockfiles/actionlint.lock.json")
21+
multitool.hub(lockfile = "//tools:lockfiles/ruff.lock.json")
22+
multitool.hub(lockfile = "//tools:lockfiles/shellcheck.lock.json")
23+
multitool.hub(lockfile = "//tools:lockfiles/yamlfmt.lock.json")
24+
multitool.hub(lockfile = "//tools:lockfiles/uv.lock.json")
25+
multitool.hub(lockfile = "//tools:lockfiles/buildifier.lock.json")
26+
multitool.hub(lockfile = "//tools:lockfiles/starpls.lock.json")
27+
multitool.hub(lockfile = "//tools:lockfiles/bazelisk.lock.json")
28+
29+
use_repo(multitool, "multitool")
30+
31+
register_toolchains("@multitool//toolchains:all")

MODULE.bazel.lock

Lines changed: 606 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

REUSE.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ SPDX-License-Identifier = "Apache-2.0"
2525

2626
[[annotations]]
2727
path = ["resources/reopen_in_container.png",
28-
"resources/devcontainer_success.png"
28+
"resources/devcontainer_success.png",
29+
"tools/lockfiles/*.lock.json",
30+
"MODULE.bazel.lock",
2931
]
3032
SPDX-FileCopyrightText = "Copyright (c) 2026 Contributors to the Eclipse Foundation"
3133
SPDX-License-Identifier = "Apache-2.0"

src/s-core-devcontainer/.devcontainer/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ FROM buildpack-deps:noble-curl
1616

1717
LABEL dev.containers.features="common"
1818

19+
COPY tools /usr/local/share/score-tools
20+
1921
RUN userdel -f -r ubuntu

src/s-core-devcontainer/.devcontainer/bazel-feature/devcontainer-feature.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
"id": "bazel",
44
"version": "1.0.0",
55
"description": "Bazel and supplimentary tools for working with Bazel-based projects.",
6-
"dependsOn": {
7-
"./s-core-local": {} // needed for extracting versions (versions.sh)
8-
},
96
"onCreateCommand": "/devcontainer/features/bazel/on_create_command.sh",
107
"postCreateCommand": {
118
// The repos in S-CORE may use different Bazel versions. This ensures that the required version is installed.

src/s-core-devcontainer/.devcontainer/bazel-feature/install.sh

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ rm -f "${COPY_TARGET}/devcontainer-features.env" "${COPY_TARGET}/devcontainer-fe
2929
DEBIAN_FRONTEND=noninteractive
3030

3131
# Read tool versions + metadata into environment variables
32-
. /devcontainer/features/s-core-local/versions.sh /devcontainer/features/bazel/versions.yaml
32+
. /usr/local/share/score-tools/versions.sh /devcontainer/features/bazel/versions.yaml
3333

3434
ARCHITECTURE=$(dpkg --print-architecture)
3535

@@ -39,20 +39,11 @@ apt-get update
3939
# Container build dependencies are not pinned, since they are removed anyway after container creation.
4040
apt-get install apt-transport-https -y
4141

42-
# Bazelisk, directly from GitHub
43-
# Using the existing devcontainer feature is not optimal:
44-
# - it does not check the SHA256 checksum of the downloaded file
45-
# - it cannot pre-install a specific version of Bazel, or prepare bash completion
46-
BAZELISK_VARIANT="amd64"
47-
SHA256SUM="${bazelisk_amd64_sha256}"
48-
if [ "${ARCHITECTURE}" = "arm64" ]; then
49-
BAZELISK_VARIANT="arm64"
50-
SHA256SUM="${bazelisk_arm64_sha256}"
51-
fi
52-
curl -L "https://github.com/bazelbuild/bazelisk/releases/download/v${bazelisk_version}/bazelisk-${BAZELISK_VARIANT}.deb" -o /tmp/bazelisk.deb
53-
echo "${SHA256SUM} /tmp/bazelisk.deb" | sha256sum -c - || exit 1
54-
apt-get install -y --no-install-recommends --fix-broken /tmp/bazelisk.deb
55-
rm /tmp/bazelisk.deb
42+
# Lockfile-managed Bazel tooling
43+
/usr/local/share/score-tools/tool_installer.py install bazelisk buildifier starpls
44+
45+
# Bazelisk + Bazel
46+
ln -sf /usr/local/bin/bazelisk /usr/local/bin/bazel
5647

5748
# Pre-install a fixed Bazel version, setup the bash command completion
5849
export USE_BAZEL_VERSION=${bazel_version}
@@ -67,29 +58,6 @@ sh -c "echo 'INSTALLED_BAZEL_VERSION=${bazel_version}' >> /devcontainer/features
6758
# This is required for corporate environments with custom CA certificates
6859
echo 'startup --host_jvm_args=-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts --host_jvm_args=-Djavax.net.ssl.trustStorePassword=changeit' >> /etc/bazel.bazelrc
6960

70-
# Buildifier, directly from GitHub (apparently no APT repository available)
71-
# The version is pinned to a specific release, and the SHA256 checksum is provided by the devcontainer-features.json file.
72-
BUILDIFIER_VARIANT="amd64"
73-
SHA256SUM="${buildifier_amd64_sha256}"
74-
if [ "${ARCHITECTURE}" = "arm64" ]; then
75-
BUILDIFIER_VARIANT="arm64"
76-
SHA256SUM="${buildifier_arm64_sha256}"
77-
fi
78-
curl -L "https://github.com/bazelbuild/buildtools/releases/download/v${buildifier_version}/buildifier-linux-${BUILDIFIER_VARIANT}" -o /usr/local/bin/buildifier
79-
echo "${SHA256SUM} /usr/local/bin/buildifier" | sha256sum -c - || exit 1
80-
chmod +x /usr/local/bin/buildifier
81-
82-
# Starlark Language Server, directly from GitHub (apparently no APT repository available)
83-
STARPLS_VARIANT="amd64"
84-
SHA256SUM="${starpls_amd64_sha256}"
85-
if [ "${ARCHITECTURE}" = "arm64" ]; then
86-
STARPLS_VARIANT="aarch64"
87-
SHA256SUM="${starpls_arm64_sha256}"
88-
fi
89-
curl -L "https://github.com/withered-magic/starpls/releases/download/v${starpls_version}/starpls-linux-${STARPLS_VARIANT}" -o /usr/local/bin/starpls
90-
echo "${SHA256SUM} /usr/local/bin/starpls" | sha256sum -c - || exit 1
91-
chmod +x /usr/local/bin/starpls
92-
9361
# Code completion for C++ code of Bazel projects
9462
# (see https://github.com/kiron1/bazel-compile-commands)
9563
source /etc/lsb-release

0 commit comments

Comments
 (0)