Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .buildifier.lint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"type": "default",
"mode": "check",
"lint": "warn",
"uncheckedWarningsList": [
"function-docstring",
"function-docstring-args",
"function-docstring-header",
"function-docstring-return",
"module-docstring",
"skylark-docstring",
"unsorted-dict-items"
],
"warningsList": [
"attr-applicable_licenses",
"attr-cfg",
"attr-license",
"attr-licenses",
"attr-non-empty",
"attr-output-default",
"attr-single-file",
"build-args-kwargs",
"bzl-visibility",
"confusing-name",
"constant-glob",
"ctx-actions",
"ctx-args",
"deprecated-function",
"depset-items",
"depset-iteration",
"depset-union",
"dict-concatenation",
"dict-method-named-arg",
"duplicated-name",
"filetype",
"git-repository",
"http-archive",
"integer-division",
"keyword-positional-params",
"list-append",
"load",
"name-conventions",
"native-android",
"native-build",
"native-cc-binary",
"native-cc-common",
"native-cc-debug-package-info",
"native-cc-fdo-prefetch-hints",
"native-cc-fdo-profile",
"native-cc-import",
"native-cc-info",
"native-cc-library",
"native-cc-memprof-profile",
"native-cc-objc-import",
"native-cc-objc-library",
"native-cc-propeller-optimize",
"native-cc-proto",
"native-cc-shared-library",
"native-cc-shared-library-hint-info",
"native-cc-shared-library-info",
"native-cc-test",
"native-cc-toolchain",
"native-cc-toolchain-suite",
"native-java-binary",
"native-java-common",
"native-java-import",
"native-java-info",
"native-java-library",
"native-java-lite-proto",
"native-java-package-config",
"native-java-plugin",
"native-java-plugin-info",
"native-java-proto",
"native-java-runtime",
"native-java-test",
"native-java-toolchain",
"native-package",
"native-proto",
"native-proto-common",
"native-proto-info",
"native-proto-lang-toolchain",
"native-proto-lang-toolchain-info",
"native-py",
"native-sh-binary",
"native-sh-library",
"native-sh-test",
"no-effect",
"output-group",
"overly-nested-depset",
"package-name",
"package-on-top",
"positional-args",
"print",
"provider-params",
"redefined-variable",
"repository-name",
"return-value",
"rule-impl-return",
"skylark-comment",
"string-iteration",
"uninitialized",
"unnamed-macro",
"unreachable",
"unused-variable"
]
}
4 changes: 4 additions & 0 deletions .github/workflows/per-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ jobs:
uses: ./.github/actions/kurtosis-install
- name: Kurtosis Lint
run: kurtosis lint ${{ github.workspace }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Buildifier Lint
run: make lint

assertoor:
runs-on: ubuntu-latest
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile.buildifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM alpine:latest

# Install required dependencies
RUN apk add --no-cache curl

# Install buildifier
RUN ARCH=$(uname -m) \
&& if [ "$ARCH" = "x86_64" ]; then BUILDIFIER_ARCH="amd64"; elif [ "$ARCH" = "aarch64" ]; then BUILDIFIER_ARCH="arm64"; else BUILDIFIER_ARCH="amd64"; fi \
&& curl -fsSL -o /usr/local/bin/buildifier "https://github.com/bazelbuild/buildtools/releases/download/v8.2.1/buildifier-linux-${BUILDIFIER_ARCH}" \
&& chmod +x /usr/local/bin/buildifier

# Set working directory for linting
WORKDIR /workspace

# Entry point to run buildifier
ENTRYPOINT ["/usr/local/bin/buildifier"]
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Dockerfile-based linter for Starlark files
DOCKERFILE_LINT := Dockerfile.buildifier
LINT_IMAGE := ethereum-package-buildifier

.PHONY: lint lint-build fmt fmt-check

# Build the lint Docker image
lint-build:
docker build -f $(DOCKERFILE_LINT) -t $(LINT_IMAGE) .

# Run buildifier on .star files (all files if no FILES specified, or specific FILES/patterns)
lint: lint-build
@if [ "$(FILES)" ]; then \
echo "Running buildifier on specified files: $(FILES)"; \
exit_code=0; \
for pattern in $(FILES); do \
for file in $$pattern; do \
if [ -f "$$file" ]; then \
printf "\033[1;34mLinting file: \033[1;33m%s\033[0m\n" "$$file"; \
docker run --rm -u $(shell id -u):$(shell id -g) -v $(PWD):/workspace $(LINT_IMAGE) --config=.buildifier.lint.json "$$file" || exit_code=1; \
fi; \
done; \
done; \
exit $$exit_code; \
else \
echo "Running buildifier on all .star files..."; \
exit_code=0; \
for file in $$(find . -name "*.star" -type f); do \
printf "\033[1;34mLinting file: \033[1;33m%s\033[0m\n" "$$file"; \
docker run --rm -u $(shell id -u):$(shell id -g) -v $(PWD):/workspace $(LINT_IMAGE) --config=.buildifier.lint.json "$$file" || exit_code=1; \
done; \
exit $$exit_code; \
fi
@echo "Linting complete."

# Format .star files using buildifier (all files if no FILES specified, or specific FILES/patterns)
fmt: lint-build
@if [ "$(FILES)" ]; then \
echo "Formatting specified files: $(FILES)"; \
for pattern in $(FILES); do \
for file in $$pattern; do \
if [ -f "$$file" ]; then \
printf "\033[1;32mFormatting file: \033[1;33m%s\033[0m\n" "$$file"; \
cat "$$file" | docker run --rm -i -u $(shell id -u):$(shell id -g) -v $(PWD):/workspace $(LINT_IMAGE) --type=bzl > "$$file.tmp" && mv "$$file.tmp" "$$file"; \
fi; \
done; \
done; \
else \
echo "Formatting all .star files..."; \
find . -name "*.star" -type f | while read file; do \
printf "\033[1;32mFormatting file: \033[1;33m%s\033[0m\n" "$$file"; \
cat "$$file" | docker run --rm -i -u $(shell id -u):$(shell id -g) -v $(PWD):/workspace $(LINT_IMAGE) --type=bzl > "$$file.tmp" && mv "$$file.tmp" "$$file"; \
done; \
fi
@echo "Formatting complete."
Loading