Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: validate the .pbtxt files in the build step #967

Merged
merged 5 commits into from
Feb 25, 2025
Merged
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
13 changes: 13 additions & 0 deletions .github/workflows/format-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ jobs:
- name: markdown-format
run: make lint/markdown

pbtxt:
needs: build-image
runs-on: ubuntu-latest
container:
image: ghcr.io/mlcommons/mobile_app_open-formatter:${{ github.run_number }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- name: configure Git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: pbtxt
run: make lint/pbtxt

yaml:
needs: build-image
runs-on: ubuntu-latest
Expand Down
16 changes: 16 additions & 0 deletions tools/formatter/format.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SHELL := /bin/bash

.PHONY: format
format: format/bazel format/clang format/dart format/ts format/line-endings format/markdown
Expand Down Expand Up @@ -108,6 +109,21 @@ lint/markdown:
grep --null-data "\.md$$" --exclude="*LICENSE.md" | \
xargs --null --no-run-if-empty markdownlint -c tools/formatter/configs/markdownlint.yml

.PHONY: lint/pbtxt
lint/pbtxt:
@{ \
echo "Linting: flutter/assets/tasks.pbtxt"; \
protoc --encode=mlperf.mobile.MLPerfConfig --proto_path=flutter/cpp/proto mlperf_task.proto < flutter/assets/tasks.pbtxt > /dev/null; \
}
@git ls-files -z | grep -zE '^mobile_back_[^/]*/.*\.pbtxt$$' | { \
err=0; \
while IFS= read -r -d '' file; do \
echo "Linting: $$file"; \
protoc --encode=mlperf.mobile.BackendSetting --proto_path=flutter/cpp/proto backend_setting.proto < "$$file" > /dev/null || err=1; \
done; \
exit $$err; \
}

output/docker_mlperf_formatter.stamp: tools/formatter/Dockerfile
docker build --progress=plain \
--build-arg UID=`id -u` --build-arg GID=`id -g` \
Expand Down
Loading