Skip to content

Commit

Permalink
ci: fix licensecheck, move to lint (#4173)
Browse files Browse the repository at this point in the history
Update the find directories for the licensecheck step; as this is (almost)
the same pattern as already used in the go_lint-steps, move this
licensecheck there, it makes just as much sense there anyway.
  • Loading branch information
matzf authored May 29, 2022
1 parent de6d299 commit 7357f03
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,30 @@ steps:
- label: "check generated"
if: build.message !~ /\[doc\]/
command:
- ./tools/licensechecker.py $(find go acceptance -type f -iname '*.go')
- echo "--- go_deps.bzl"
- mkdir -p /tmp/test-artifacts
- cp go.mod go.sum go_deps.bzl /tmp/test-artifacts/
- make go_deps.bzl -B
- $(bazel info output_base 2>/dev/null)/external/go_sdk/bin/go mod tidy
- diff -u /tmp/test-artifacts/go.mod go.mod
- diff -u /tmp/test-artifacts/go.sum go.sum
- diff -u /tmp/test-artifacts/go_deps.bzl go_deps.bzl
- echo "--- protobuf"
- cp -R pkg/proto/ /tmp/test-artifacts
- make protobuf
- diff -ur /tmp/test-artifacts/proto/ pkg/proto/
- echo "--- licenses"
- mkdir -p /tmp/test-artifacts/licenses
- ./tools/licenses.sh /tmp/test-artifacts/licenses
- diff -rNu3 /tmp/test-artifacts/licenses ./licenses/data
- echo "--- gomocks"
- ./tools/gomocks.py diff
- echo "--- antlr"
- rm -rf /tmp/test-artifacts/antlr
- cp -R antlr/ /tmp/test-artifacts/antlr
- make antlr
- diff -ur /tmp/test-artifacts/antlr/ antlr/
- echo "--- testdata"
- ./tools/update_testdata.sh
timeout_in_minutes: 20
key: check_generated
Expand Down
8 changes: 5 additions & 3 deletions tools/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ run_silently() {
go_lint() {
lint_header "go"
local TMPDIR=$(mktemp -d /tmp/scion-lint.XXXXXXX)
local LOCAL_DIRS="$(find ./* -maxdepth 0 -type d )"
# Find go files to lint, excluding generated code. For linelen and misspell.
find $LOCAL_DIRS -type f -iname '*.go' \
find -type f -iname '*.go' \
-a '!' -ipath '*.pb.go' \
-a '!' -ipath '*.gen.go' \
-a '!' -ipath './antlr/*' \
Expand All @@ -42,14 +41,17 @@ go_lint() {
# See: https://github.com/bazelbuild/rules_go/issues/511
# Instead we'll just run the commands from Go SDK directly.
GOSDK=$(bazel info output_base 2>/dev/null)/external/go_sdk/bin
out=$($GOSDK/gofmt -d -s $( cat $TMPDIR/gofiles.list) );
out=$(xargs -a $TMPDIR/gofiles.list $GOSDK/gofmt -d -s);
if [ -n "$out" ]; then in_red "$out"; ret=1; fi
lint_step "linelen (lll)"
out=$($TMPDIR/lll -w 4 -l 100 --files -e '`comment:"|`ini:"|https?:|`sql:"|gorm:"|`json:"|`yaml:|nolint:lll' < $TMPDIR/gofiles.list)
if [ -n "$out" ]; then in_red "$out"; ret=1; fi
lint_step "misspell"
out=$(xargs -a $TMPDIR/gofiles.list $TMPDIR/misspell -error)
if [ -n "$out" ]; then in_red "$out"; ret=1; fi
lint_step "licensechecker"
out=$(xargs -a $TMPDIR/gofiles.list tools/licensechecker.py)
if [ -n "$out" ]; then in_red "$out"; ret=1; fi
lint_step "bazel"
run_silently make gazelle GAZELLE_MODE=diff || ret=1
bazel test --config lint || ret=1
Expand Down

0 comments on commit 7357f03

Please sign in to comment.