Skip to content

Commit 4c46a93

Browse files
linter (#202)
1 parent c1e84e0 commit 4c46a93

3 files changed

Lines changed: 91 additions & 0 deletions

File tree

.github/workflows/lint.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 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+
name: Linting Checks
15+
16+
on:
17+
pull_request:
18+
types: [opened, reopened, synchronize]
19+
merge_group:
20+
types: [checks_requested]
21+
22+
jobs:
23+
lint:
24+
runs-on: ubuntu-latest
25+
continue-on-error: true
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4.2.2
29+
30+
- name: Setup Bazel
31+
uses: bazel-contrib/setup-bazel@0.15.0
32+
with:
33+
disk-cache: true
34+
repository-cache: true
35+
bazelisk-cache: true
36+
37+
- name: Run Linter Script
38+
run: bash scripts/run-linters.sh

MODULE.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,20 @@ bazel_dep(name = "score_dash_license_checker", version = "0.1.1")
9696

9797
# docs dependency
9898
bazel_dep(name = "score_process", version = "1.1.1-Beta")
99+
100+
# Add Linter
101+
bazel_dep(name = "rules_multitool", version = "1.2.0")
102+
bazel_dep(
103+
name = "score_linter",
104+
version = "0.1.0",
105+
)
106+
107+
multitool_root = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
108+
use_repo(multitool_root, "actionlint_hub", "multitool", "ruff_hub", "shellcheck_hub", "yamlfmt_hub")
109+
110+
register_toolchains(
111+
"@ruff_hub//toolchains:all",
112+
"@actionlint_hub//toolchains:all",
113+
"@shellcheck_hub//toolchains:all",
114+
"@yamlfmt_hub//toolchains:all",
115+
)

scripts/run-linters.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 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+
#!/usr/bin/env bash
14+
set -euo pipefail
15+
16+
bazel run //:ide_support
17+
18+
echo "Running Ruff linter..."
19+
bazel run @score_linter//:ruff check
20+
21+
echo "Running basedpyright..."
22+
.venv/bin/python3 -m basedpyright
23+
24+
echo "Running Actionlint..."
25+
bazel run @score_linter//:actionlint
26+
27+
echo "Running Shellcheck..."
28+
find . \
29+
-type d \( -name .git -o -name .venv -o -name bazel-out -o -name node_modules \) -prune -false \
30+
-o -type f -exec grep -Il '^#!.*sh' {} \; | \
31+
xargs bazel run @score_linter//:shellcheck --
32+
33+
echo "Running Yamlfmt..."
34+
bazel run @score_linter//:yamlfmt -- $(find . \
35+
-type d \( -name .git -o -name .venv -o -name bazel-out -o -name node_modules \) -prune -false \
36+
-o -type f \( -name "*.yaml" -o -name "*.yml" \) | tr '\n' '\0' | xargs -0)

0 commit comments

Comments
 (0)