From a0245523496af7e5cc7493ef4d1d199f0d5220f3 Mon Sep 17 00:00:00 2001 From: Jesse Tatasciore Date: Wed, 28 Aug 2024 11:28:33 -0700 Subject: [PATCH] test: suggestions --- .aspect/cli/config.yaml | 1 + .aspect/workflows/config.yaml | 2 + .circleci/config.yml | 44 ++++++++ bar.json | 106 ++++++++++++++++++ foo.json | 34 ++++++ lib/tests/copy_to_bin/test.sh | 2 +- lib/tests/run_binary_expansions/expansions.sh | 2 +- tools/lint/linters.bzl | 6 + 8 files changed, 195 insertions(+), 2 deletions(-) create mode 100755 bar.json diff --git a/.aspect/cli/config.yaml b/.aspect/cli/config.yaml index e6bbe2e25..81324c8d7 100644 --- a/.aspect/cli/config.yaml +++ b/.aspect/cli/config.yaml @@ -7,3 +7,4 @@ configure: lint: aspects: - //tools/lint:linters.bzl%vale + - //tools/lint:linters.bzl%shellcheck diff --git a/.aspect/workflows/config.yaml b/.aspect/workflows/config.yaml index 2dfa09f3b..8706d45a7 100644 --- a/.aspect/workflows/config.yaml +++ b/.aspect/workflows/config.yaml @@ -99,6 +99,8 @@ workspaces: - delivery: without: true tasks: + - checkout: + update_strategy: rebase - test: hooks: - type: before_task diff --git a/.circleci/config.yml b/.circleci/config.yml index ebd7af12d..84c2100b6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -199,6 +199,10 @@ jobs: command: /etc/aspect/workflows/bin/agent_health_check name: Agent health check no_output_timeout: 180m + - run: + command: rosetta run checkout + name: Checkout health + no_output_timeout: 180m - run: command: rosetta run buildifier --workspace << parameters.workspace >> name: Buildifier @@ -239,6 +243,10 @@ jobs: command: /etc/aspect/workflows/bin/agent_health_check name: Agent health check no_output_timeout: 180m + - run: + command: rosetta run checkout + name: Checkout health + no_output_timeout: 180m - run: command: rosetta run test --workspace << parameters.workspace >> name: Test @@ -299,6 +307,10 @@ jobs: command: /etc/aspect/workflows/bin/agent_health_check name: Agent health check no_output_timeout: 180m + - run: + command: rosetta run checkout + name: Checkout health + no_output_timeout: 180m - run: command: rosetta run test --workspace << parameters.workspace >> name: Test @@ -359,6 +371,10 @@ jobs: command: /etc/aspect/workflows/bin/agent_health_check name: Agent health check no_output_timeout: 180m + - run: + command: rosetta run checkout + name: Checkout health + no_output_timeout: 180m - run: command: rosetta run test --workspace << parameters.workspace >> name: Test @@ -419,6 +435,10 @@ jobs: command: /etc/aspect/workflows/bin/agent_health_check name: Agent health check no_output_timeout: 180m + - run: + command: rosetta run checkout + name: Checkout health + no_output_timeout: 180m - run: command: rosetta run test --workspace << parameters.workspace >> name: Test @@ -479,6 +499,10 @@ jobs: command: /etc/aspect/workflows/bin/agent_health_check name: Agent health check no_output_timeout: 180m + - run: + command: rosetta run checkout + name: Checkout health + no_output_timeout: 180m - run: command: rosetta run test --workspace << parameters.workspace >> name: Test @@ -539,6 +563,10 @@ jobs: command: /etc/aspect/workflows/bin/agent_health_check name: Agent health check no_output_timeout: 180m + - run: + command: rosetta run checkout + name: Checkout health + no_output_timeout: 180m - run: command: rosetta run format --workspace << parameters.workspace >> name: Format @@ -579,6 +607,10 @@ jobs: command: /etc/aspect/workflows/bin/agent_health_check name: Agent health check no_output_timeout: 180m + - run: + command: rosetta run checkout + name: Checkout health + no_output_timeout: 180m - run: command: rosetta run gazelle --workspace << parameters.workspace >> name: Gazelle @@ -619,6 +651,10 @@ jobs: command: /etc/aspect/workflows/bin/agent_health_check name: Agent health check no_output_timeout: 180m + - run: + command: rosetta run checkout + name: Checkout health + no_output_timeout: 180m - run: command: rosetta run lint --workspace << parameters.workspace >> name: Lint @@ -697,6 +733,10 @@ jobs: command: /etc/aspect/workflows/bin/agent_health_check name: Agent health check no_output_timeout: 180m + - run: + command: rosetta run checkout + name: Checkout health + no_output_timeout: 180m - run: command: rosetta run configure --workspace << parameters.workspace >> name: Configure @@ -737,6 +777,10 @@ jobs: command: /etc/aspect/workflows/bin/agent_health_check name: Agent health check no_output_timeout: 180m + - run: + command: rosetta run checkout + name: Checkout health + no_output_timeout: 180m - run: command: rosetta run test --workspace << parameters.workspace >> name: Test diff --git a/bar.json b/bar.json new file mode 100755 index 000000000..5bfd8d2ff --- /dev/null +++ b/bar.json @@ -0,0 +1,106 @@ +{ + "diagnostics": [ + { + "severity": 4, + "help": " declare \"$key\"=\"$value\"", + "title": " provided a suggestion", + "source_content": { + "name": "lib/tests/stamping/stamper.sh" + }, + "spans": [ + { + "offset": 9 + } + ], + "baggage": { + "label": "//lib/tests/stamping:stamper" + }, + "type": 1 + }, + { + "message": "Vale.Spelling:Did you really mean 'esdwdsqafdfg'?", + "severity": 3, + "title": "Vale found an issue", + "source_content": { + "name": "foo.md" + }, + "spans": [ + { + "offset": 4 + } + ], + "baggage": { + "label": "//:foo" + }, + "type": 1 + }, + { + "message": "Vale.Spelling:Did you really mean 'wqftqerwt'?", + "severity": 3, + "title": "Vale found an issue", + "source_content": { + "name": "foo.md" + }, + "spans": [ + { + "offset": 5 + } + ], + "baggage": { + "label": "//:foo" + }, + "type": 1 + }, + { + "message": "Vale.Spelling:Did you really mean 'gertgerw'?", + "severity": 3, + "title": "Vale found an issue", + "source_content": { + "name": "foo.md" + }, + "spans": [ + { + "offset": 8 + } + ], + "baggage": { + "label": "//:foo" + }, + "type": 1 + }, + { + "message": "Google.FirstPerson:Avoid first-person pronouns such as 'I '.", + "severity": 3, + "title": "Vale found an issue", + "source_content": { + "name": "foo.md" + }, + "spans": [ + { + "offset": 11 + } + ], + "baggage": { + "label": "//:foo" + }, + "type": 1 + }, + { + "message": "Vale.Avoid:Avoid using 'bar'.", + "severity": 3, + "title": "Vale found an issue", + "source_content": { + "name": "foo.md" + }, + "spans": [ + { + "offset": 13 + } + ], + "baggage": { + "label": "//:foo" + }, + "type": 1 + } + ] +} \ No newline at end of file diff --git a/foo.json b/foo.json index bd13f4449..eda04e92d 100755 --- a/foo.json +++ b/foo.json @@ -1,5 +1,39 @@ { "diagnostics": [ + { + "severity": 4, + "help": " declare \"$key\"=\"$value\"", + "title": " provided a suggestion", + "source_content": { + "name": "lib/tests/stamping/stamper.sh" + }, + "spans": [ + { + "offset": 9 + } + ], + "baggage": { + "label": "//lib/tests/stamping:stamper" + }, + "type": 1 + }, + { + "severity": 4, + "help": "rm -f \"$outfile\" || true", + "title": " provided a suggestion", + "source_content": { + "name": "lib/tests/run_binary_expansions/expansions.sh" + }, + "spans": [ + { + "offset": 6 + } + ], + "baggage": { + "label": "//lib/tests/run_binary_expansions:expansions_sh" + }, + "type": 1 + }, { "message": "Vale.Spelling:Did you really mean 'esdwdsqafdfg'?", "severity": 3, diff --git a/lib/tests/copy_to_bin/test.sh b/lib/tests/copy_to_bin/test.sh index a02c14777..72467d4a8 100755 --- a/lib/tests/copy_to_bin/test.sh +++ b/lib/tests/copy_to_bin/test.sh @@ -4,7 +4,7 @@ set -o errexit -o nounset expected_file="$1" source_file="$2" -bin_file="$3" +bin_file=$3 if [[ "$expected_file" != "$source_file" ]]; then echo "ERROR: expected source_file to be $expected_file, but got $source_file" exit 1 diff --git a/lib/tests/run_binary_expansions/expansions.sh b/lib/tests/run_binary_expansions/expansions.sh index e0bea99a1..05cb2d1fa 100755 --- a/lib/tests/run_binary_expansions/expansions.sh +++ b/lib/tests/run_binary_expansions/expansions.sh @@ -3,7 +3,7 @@ set -o errexit -o nounset -o pipefail mkdir -p $(dirname "$1") outfile=$1 -rm -f "$outfile" || true +rm -f $outfile || true for each in $@; do sanitized=${each/darwin/PLATFORM} sanitized=${sanitized/k8/PLATFORM} diff --git a/tools/lint/linters.bzl b/tools/lint/linters.bzl index 03554e189..d8c0da811 100644 --- a/tools/lint/linters.bzl +++ b/tools/lint/linters.bzl @@ -1,6 +1,12 @@ "Create linter aspects, see https://github.com/aspect-build/rules_lint/blob/main/docs/linting.md#installation" load("@aspect_rules_lint//lint:vale.bzl", "lint_vale_aspect") +load("@aspect_rules_lint//lint:shellcheck.bzl", "lint_shellcheck_aspect") + +shellcheck = lint_shellcheck_aspect( + binary = "@multitool//tools/shellcheck", + config = "@@//:.shellcheckrc", +) vale = lint_vale_aspect( binary = "@@//tools/lint:vale_bin",