diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 110691cbc..63795452f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -229,8 +229,8 @@ All tests are automated. The ['Checks' document](./docs/checks.md) is a large document to explain all checks by actionlint. -This document is maintained with [`update-checks-doc`](./scripts/update-checks-doc) script. This script automatically updates +This document is maintained with [`check-checks`](./scripts/check-checks) script. This script automatically updates the code blocks after `Output:` and the `Playground` links. This script should be run after modifying the document. -Please see [the readme of the script](./scripts/update-checks-doc/README.md) for the usage and knowing the details of the +Please see [the readme of the script](./scripts/check-checks/README.md) for the usage and knowing the details of the document format that this script assumes. diff --git a/Makefile b/Makefile index 5a5911d9b..9e0d8a9d3 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ t test: .testtimestamp .staticchecktimestamp: $(TESTS) $(SRCS) $(TOOL) staticcheck ./... GOOS=js GOARCH=wasm staticcheck ./playground - go run ./scripts/update-checks-doc -check -quiet ./docs/checks.md + go run ./scripts/check-checks -quiet ./docs/checks.md touch .staticchecktimestamp l lint: .staticchecktimestamp diff --git a/scripts/update-checks-doc/.gitignore b/scripts/check-checks/.gitignore similarity index 100% rename from scripts/update-checks-doc/.gitignore rename to scripts/check-checks/.gitignore diff --git a/scripts/update-checks-doc/README.md b/scripts/check-checks/README.md similarity index 90% rename from scripts/update-checks-doc/README.md rename to scripts/check-checks/README.md index a0e26993a..7bae49b94 100644 --- a/scripts/update-checks-doc/README.md +++ b/scripts/check-checks/README.md @@ -1,5 +1,5 @@ -update-checks-doc -================= +check-checks +============ This is a script to maintain [the 'Checks' document](../../docs/checks.md). @@ -21,19 +21,19 @@ For making the implementation simple, this script does not support Windows. ## Usage ``` -go run ./scripts/update-checks-doc [-check] FILE +go run ./scripts/check-checks [FLAGS] FILE ``` -Update the document. This command directly modifies the file. +Check the document is up-to-date. ```sh -go run ./scripts/update-checks-doc ./docs/checks.md +go run ./scripts/check-checks ./docs/checks.md ``` -Check the document is up-to-date. +Update the document. This command directly modifies the file. ```sh -go run ./scripts/update-checks-doc -check ./docs/checks.md +go run ./scripts/check-checks -fix ./docs/checks.md ``` The check is run on the [CI workflow](../../.github/workflows/ci.yaml). diff --git a/scripts/update-checks-doc/main.go b/scripts/check-checks/main.go similarity index 97% rename from scripts/update-checks-doc/main.go rename to scripts/check-checks/main.go index dadf6d21e..818032f1a 100644 --- a/scripts/update-checks-doc/main.go +++ b/scripts/check-checks/main.go @@ -316,14 +316,14 @@ func Update(in []byte) ([]byte, error) { var stderr io.Writer = os.Stderr func Main(args []string) error { - var check bool + var fix bool var quiet bool flags := flag.NewFlagSet(args[0], flag.ContinueOnError) - flags.BoolVar(&check, "check", false, "check the document is up-to-date") + flags.BoolVar(&fix, "fix", false, "fix the outdated document automatically") flags.BoolVar(&quiet, "quiet", false, "disable trace logs") flags.SetOutput(stderr) flags.Usage = func() { - fmt.Fprintln(stderr, "Usage: update-checks-doc [FLAGS] FILE\n\nFlags:") + fmt.Fprintln(stderr, "Usage: check-checks [FLAGS] FILE\n\nFlags:") flags.PrintDefaults() } @@ -358,8 +358,8 @@ func Main(args []string) error { return nil } - if check { - return fmt.Errorf("checks document has some update. run `go run ./scripts/update-checks-doc %s` and commit the changes. the diff:\n\n%s", path, cmp.Diff(in, out)) + if !fix { + return fmt.Errorf("checks document has some update. run `go run ./scripts/check-checks -fix %s` and commit the changes on Linux or macOS. the diff:\n\n%s", path, cmp.Diff(in, out)) } log.Printf("Overwrite the file with the updated content (%d bytes) at %q", len(out), path) diff --git a/scripts/update-checks-doc/main_test.go b/scripts/check-checks/main_test.go similarity index 82% rename from scripts/update-checks-doc/main_test.go rename to scripts/check-checks/main_test.go index f34691145..576b2584a 100644 --- a/scripts/update-checks-doc/main_test.go +++ b/scripts/check-checks/main_test.go @@ -41,7 +41,7 @@ func testErr(t *testing.T, err error, want ...string) { func TestMainGenerateOK(t *testing.T) { if runtime.GOOS == "windows" { - t.Skip("update-checks-doc doesn't support Windows") + t.Skip("check-checks doesn't support Windows") } root := t.TempDir() @@ -52,7 +52,7 @@ func TestMainGenerateOK(t *testing.T) { in.Close() tmp.Close() - if err := Main([]string{"exe", path}); err != nil { + if err := Main([]string{"exe", "-fix", path}); err != nil { t.Fatal(err) } @@ -65,20 +65,20 @@ func TestMainGenerateOK(t *testing.T) { func TestMainCheckOK(t *testing.T) { if runtime.GOOS == "windows" { - t.Skip("update-checks-doc doesn't support Windows") + t.Skip("check-checks doesn't support Windows") } path := filepath.FromSlash("testdata/ok/minimal.out") - if err := Main([]string{"exe", "-check", path}); err != nil { + if err := Main([]string{"exe", path}); err != nil { t.Fatal(err) } } func TestMainCheckQuietOK(t *testing.T) { if runtime.GOOS == "windows" { - t.Skip("update-checks-doc doesn't support Windows") + t.Skip("check-checks doesn't support Windows") } path := filepath.FromSlash("testdata/ok/minimal.out") - if err := Main([]string{"exe", "-check", "-quiet", path}); err != nil { + if err := Main([]string{"exe", "-quiet", path}); err != nil { t.Fatal(err) } } @@ -91,14 +91,14 @@ func TestMainPrintHelp(t *testing.T) { func TestMainCheckError(t *testing.T) { if runtime.GOOS == "windows" { - t.Skip("update-checks-doc doesn't support Windows") + t.Skip("check-checks doesn't support Windows") } path := filepath.FromSlash("testdata/ok/minimal.in") - testErr(t, Main([]string{"exe", "-check", path}), "checks document has some update") + testErr(t, Main([]string{"exe", path}), "checks document has some update") } func TestMainFileNotFound(t *testing.T) { - testErr(t, Main([]string{"exe", "-check", "this-file-does-not-exist.md"}), "could not read the document file") + testErr(t, Main([]string{"exe", "this-file-does-not-exist.md"}), "could not read the document file") } func TestMainTooManyArgs(t *testing.T) { @@ -109,16 +109,6 @@ func TestMainInvalidCheckFlag(t *testing.T) { testErr(t, Main([]string{"exe", "-c", "foo.md"}), "flag provided but not defined") } -func TestMainNoUpdate(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("update-checks-doc doesn't support Windows") - } - path := filepath.FromSlash("testdata/ok/minimal.out") - if err := Main([]string{"exe", path}); err != nil { - t.Fatal(err) - } -} - func TestMainUpdateError(t *testing.T) { path := filepath.FromSlash("testdata/err/no_playground_link.md") if err := Main([]string{"exe", path}); err == nil { @@ -128,7 +118,7 @@ func TestMainUpdateError(t *testing.T) { func TestUpdateOK(t *testing.T) { if runtime.GOOS == "windows" { - t.Skip("update-checks-doc doesn't support Windows") + t.Skip("check-checks doesn't support Windows") } dir := filepath.FromSlash("testdata/ok") diff --git a/scripts/update-checks-doc/testdata/err/duplicate_id.md b/scripts/check-checks/testdata/err/duplicate_id.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/duplicate_id.md rename to scripts/check-checks/testdata/err/duplicate_id.md diff --git a/scripts/update-checks-doc/testdata/err/duplicate_title.md b/scripts/check-checks/testdata/err/duplicate_title.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/duplicate_title.md rename to scripts/check-checks/testdata/err/duplicate_title.md diff --git a/scripts/update-checks-doc/testdata/err/empty.md b/scripts/check-checks/testdata/err/empty.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/empty.md rename to scripts/check-checks/testdata/err/empty.md diff --git a/scripts/update-checks-doc/testdata/err/empty_anchor_id.md b/scripts/check-checks/testdata/err/empty_anchor_id.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/empty_anchor_id.md rename to scripts/check-checks/testdata/err/empty_anchor_id.md diff --git a/scripts/update-checks-doc/testdata/err/empty_input.md b/scripts/check-checks/testdata/err/empty_input.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/empty_input.md rename to scripts/check-checks/testdata/err/empty_input.md diff --git a/scripts/update-checks-doc/testdata/err/empty_input_with_skip_output.md b/scripts/check-checks/testdata/err/empty_input_with_skip_output.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/empty_input_with_skip_output.md rename to scripts/check-checks/testdata/err/empty_input_with_skip_output.md diff --git a/scripts/update-checks-doc/testdata/err/empty_input_with_skip_output_and_playground.md b/scripts/check-checks/testdata/err/empty_input_with_skip_output_and_playground.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/empty_input_with_skip_output_and_playground.md rename to scripts/check-checks/testdata/err/empty_input_with_skip_output_and_playground.md diff --git a/scripts/update-checks-doc/testdata/err/empty_input_with_skip_playground.md b/scripts/check-checks/testdata/err/empty_input_with_skip_playground.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/empty_input_with_skip_playground.md rename to scripts/check-checks/testdata/err/empty_input_with_skip_playground.md diff --git a/scripts/update-checks-doc/testdata/err/missing_output_and_playground_link.md b/scripts/check-checks/testdata/err/missing_output_and_playground_link.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/missing_output_and_playground_link.md rename to scripts/check-checks/testdata/err/missing_output_and_playground_link.md diff --git a/scripts/update-checks-doc/testdata/err/missing_output_block.md b/scripts/check-checks/testdata/err/missing_output_block.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/missing_output_block.md rename to scripts/check-checks/testdata/err/missing_output_block.md diff --git a/scripts/update-checks-doc/testdata/err/missing_output_header.md b/scripts/check-checks/testdata/err/missing_output_header.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/missing_output_header.md rename to scripts/check-checks/testdata/err/missing_output_header.md diff --git a/scripts/update-checks-doc/testdata/err/missing_playground_link.md b/scripts/check-checks/testdata/err/missing_playground_link.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/missing_playground_link.md rename to scripts/check-checks/testdata/err/missing_playground_link.md diff --git a/scripts/update-checks-doc/testdata/err/no_error.md b/scripts/check-checks/testdata/err/no_error.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/no_error.md rename to scripts/check-checks/testdata/err/no_error.md diff --git a/scripts/update-checks-doc/testdata/err/no_example.md b/scripts/check-checks/testdata/err/no_example.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/no_example.md rename to scripts/check-checks/testdata/err/no_example.md diff --git a/scripts/update-checks-doc/testdata/err/no_input.md b/scripts/check-checks/testdata/err/no_input.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/no_input.md rename to scripts/check-checks/testdata/err/no_input.md diff --git a/scripts/update-checks-doc/testdata/err/no_input_with_skip_output.md b/scripts/check-checks/testdata/err/no_input_with_skip_output.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/no_input_with_skip_output.md rename to scripts/check-checks/testdata/err/no_input_with_skip_output.md diff --git a/scripts/update-checks-doc/testdata/err/no_input_with_skip_output_and_playground.md b/scripts/check-checks/testdata/err/no_input_with_skip_output_and_playground.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/no_input_with_skip_output_and_playground.md rename to scripts/check-checks/testdata/err/no_input_with_skip_output_and_playground.md diff --git a/scripts/update-checks-doc/testdata/err/no_input_with_skip_playground.md b/scripts/check-checks/testdata/err/no_input_with_skip_playground.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/no_input_with_skip_playground.md rename to scripts/check-checks/testdata/err/no_input_with_skip_playground.md diff --git a/scripts/update-checks-doc/testdata/err/no_output.md b/scripts/check-checks/testdata/err/no_output.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/no_output.md rename to scripts/check-checks/testdata/err/no_output.md diff --git a/scripts/update-checks-doc/testdata/err/no_playground_link.md b/scripts/check-checks/testdata/err/no_playground_link.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/no_playground_link.md rename to scripts/check-checks/testdata/err/no_playground_link.md diff --git a/scripts/update-checks-doc/testdata/err/too_long_input_line.md b/scripts/check-checks/testdata/err/too_long_input_line.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/too_long_input_line.md rename to scripts/check-checks/testdata/err/too_long_input_line.md diff --git a/scripts/update-checks-doc/testdata/err/unclosed_example_input.md b/scripts/check-checks/testdata/err/unclosed_example_input.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/unclosed_example_input.md rename to scripts/check-checks/testdata/err/unclosed_example_input.md diff --git a/scripts/update-checks-doc/testdata/err/unclosed_output.md b/scripts/check-checks/testdata/err/unclosed_output.md similarity index 100% rename from scripts/update-checks-doc/testdata/err/unclosed_output.md rename to scripts/check-checks/testdata/err/unclosed_output.md diff --git a/scripts/update-checks-doc/testdata/ok/minimal.in b/scripts/check-checks/testdata/ok/minimal.in similarity index 100% rename from scripts/update-checks-doc/testdata/ok/minimal.in rename to scripts/check-checks/testdata/ok/minimal.in diff --git a/scripts/update-checks-doc/testdata/ok/minimal.out b/scripts/check-checks/testdata/ok/minimal.out similarity index 100% rename from scripts/update-checks-doc/testdata/ok/minimal.out rename to scripts/check-checks/testdata/ok/minimal.out diff --git a/scripts/update-checks-doc/testdata/ok/multi_examples.in b/scripts/check-checks/testdata/ok/multi_examples.in similarity index 100% rename from scripts/update-checks-doc/testdata/ok/multi_examples.in rename to scripts/check-checks/testdata/ok/multi_examples.in diff --git a/scripts/update-checks-doc/testdata/ok/multi_examples.out b/scripts/check-checks/testdata/ok/multi_examples.out similarity index 100% rename from scripts/update-checks-doc/testdata/ok/multi_examples.out rename to scripts/check-checks/testdata/ok/multi_examples.out diff --git a/scripts/update-checks-doc/testdata/ok/multi_sections.in b/scripts/check-checks/testdata/ok/multi_sections.in similarity index 100% rename from scripts/update-checks-doc/testdata/ok/multi_sections.in rename to scripts/check-checks/testdata/ok/multi_sections.in diff --git a/scripts/update-checks-doc/testdata/ok/multi_sections.out b/scripts/check-checks/testdata/ok/multi_sections.out similarity index 100% rename from scripts/update-checks-doc/testdata/ok/multi_sections.out rename to scripts/check-checks/testdata/ok/multi_sections.out diff --git a/scripts/update-checks-doc/testdata/ok/replace_absolute_path.in b/scripts/check-checks/testdata/ok/replace_absolute_path.in similarity index 100% rename from scripts/update-checks-doc/testdata/ok/replace_absolute_path.in rename to scripts/check-checks/testdata/ok/replace_absolute_path.in diff --git a/scripts/update-checks-doc/testdata/ok/replace_absolute_path.out b/scripts/check-checks/testdata/ok/replace_absolute_path.out similarity index 100% rename from scripts/update-checks-doc/testdata/ok/replace_absolute_path.out rename to scripts/check-checks/testdata/ok/replace_absolute_path.out diff --git a/scripts/update-checks-doc/testdata/ok/skip_output.in b/scripts/check-checks/testdata/ok/skip_output.in similarity index 100% rename from scripts/update-checks-doc/testdata/ok/skip_output.in rename to scripts/check-checks/testdata/ok/skip_output.in diff --git a/scripts/update-checks-doc/testdata/ok/skip_output.out b/scripts/check-checks/testdata/ok/skip_output.out similarity index 100% rename from scripts/update-checks-doc/testdata/ok/skip_output.out rename to scripts/check-checks/testdata/ok/skip_output.out diff --git a/scripts/update-checks-doc/testdata/ok/skip_output_and_playground.in b/scripts/check-checks/testdata/ok/skip_output_and_playground.in similarity index 100% rename from scripts/update-checks-doc/testdata/ok/skip_output_and_playground.in rename to scripts/check-checks/testdata/ok/skip_output_and_playground.in diff --git a/scripts/update-checks-doc/testdata/ok/skip_output_and_playground.out b/scripts/check-checks/testdata/ok/skip_output_and_playground.out similarity index 100% rename from scripts/update-checks-doc/testdata/ok/skip_output_and_playground.out rename to scripts/check-checks/testdata/ok/skip_output_and_playground.out diff --git a/scripts/update-checks-doc/testdata/ok/skip_playground.in b/scripts/check-checks/testdata/ok/skip_playground.in similarity index 100% rename from scripts/update-checks-doc/testdata/ok/skip_playground.in rename to scripts/check-checks/testdata/ok/skip_playground.in diff --git a/scripts/update-checks-doc/testdata/ok/skip_playground.out b/scripts/check-checks/testdata/ok/skip_playground.out similarity index 100% rename from scripts/update-checks-doc/testdata/ok/skip_playground.out rename to scripts/check-checks/testdata/ok/skip_playground.out diff --git a/scripts/update-checks-doc/testdata/ok/strip_comment_playground_link.in b/scripts/check-checks/testdata/ok/strip_comment_playground_link.in similarity index 100% rename from scripts/update-checks-doc/testdata/ok/strip_comment_playground_link.in rename to scripts/check-checks/testdata/ok/strip_comment_playground_link.in diff --git a/scripts/update-checks-doc/testdata/ok/strip_comment_playground_link.out b/scripts/check-checks/testdata/ok/strip_comment_playground_link.out similarity index 100% rename from scripts/update-checks-doc/testdata/ok/strip_comment_playground_link.out rename to scripts/check-checks/testdata/ok/strip_comment_playground_link.out diff --git a/scripts/update-checks-doc/testdata/ok/unknown_anchors.in b/scripts/check-checks/testdata/ok/unknown_anchors.in similarity index 100% rename from scripts/update-checks-doc/testdata/ok/unknown_anchors.in rename to scripts/check-checks/testdata/ok/unknown_anchors.in diff --git a/scripts/update-checks-doc/testdata/ok/unknown_anchors.out b/scripts/check-checks/testdata/ok/unknown_anchors.out similarity index 100% rename from scripts/update-checks-doc/testdata/ok/unknown_anchors.out rename to scripts/check-checks/testdata/ok/unknown_anchors.out diff --git a/scripts/update-checks-doc/testdata/ok/unknown_code_blocks.in b/scripts/check-checks/testdata/ok/unknown_code_blocks.in similarity index 100% rename from scripts/update-checks-doc/testdata/ok/unknown_code_blocks.in rename to scripts/check-checks/testdata/ok/unknown_code_blocks.in diff --git a/scripts/update-checks-doc/testdata/ok/unknown_code_blocks.out b/scripts/check-checks/testdata/ok/unknown_code_blocks.out similarity index 100% rename from scripts/update-checks-doc/testdata/ok/unknown_code_blocks.out rename to scripts/check-checks/testdata/ok/unknown_code_blocks.out