generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
82 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,28 @@ concurrency: | |
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
bazel-test: | ||
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v5 | ||
with: | ||
folders: '[".", "example"]' | ||
# Only test with Bazel 6. And we don't try for Windows support yet. | ||
exclude: '[{"bazelversion": "5.4.0"}, {"os": "windows-latest"}]' | ||
|
||
integration-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup bats | ||
uses: mig4/setup-bats@v1 | ||
with: | ||
bats-version: "1.8.2" | ||
- name: Setup bats helpers | ||
uses: brokenpip3/[email protected] | ||
with: | ||
support-path: /usr/lib/bats/bats-support | ||
support-version: "0.3.0" | ||
assert-path: /usr/lib/bats/bats-assert | ||
assert-version: "2.1.0" | ||
- name: Integration test | ||
working-directory: example | ||
run: bats ./test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Don't depend on a JAVA_HOME pointing at a system JDK | ||
# see https://github.com/bazelbuild/rules_jvm_external/issues/445 | ||
build --repo_env=JAVA_HOME=../bazel_tools/jdk | ||
|
||
startup --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
bats_load_library "bats-support" | ||
bats_load_library "bats-assert" | ||
|
||
function assert_lints() { | ||
# Shellcheck | ||
echo <<"EOF" | assert_output --partial | ||
In src/hello.sh line 3: | ||
[ -z $THING ] && echo "hello world" | ||
^----^ SC2086 (info): Double quote to prevent globbing and word splitting. | ||
EOF | ||
|
||
# Ruff | ||
echo <<"EOF" | assert_output --partial | ||
src/unused_import.py:13:8: F401 [*] `os` imported but unused | ||
Found 1 error. | ||
[*] 1 fixable with the `--fix` option. | ||
EOF | ||
|
||
# Flake8 | ||
assert_output --partial "src/unused_import.py:13:1: F401 'os' imported but unused" | ||
|
||
# PMD | ||
assert_output --partial 'src/Foo.java:9: FinalizeOverloaded: Finalize methods should not be overloaded' | ||
|
||
# ESLint | ||
assert_output --partial 'src/file.ts:2:7: Type string trivially inferred from a string literal, remove type annotation [error from @typescript-eslint/no-inferrable-types]' | ||
|
||
# Buf | ||
assert_output --partial 'src/file.proto:1:1:Import "src/unused.proto" is unused.' | ||
} | ||
|
||
@test "should produce reports" { | ||
run $BATS_TEST_DIRNAME/../lint.sh //src:all | ||
assert_success | ||
assert_lints | ||
} | ||
|
||
@test "should fail when --fail-on-violation is passed" { | ||
run $BATS_TEST_DIRNAME/../lint.sh --fail-on-violation //src:all | ||
assert_failure | ||
assert_lints | ||
} |