Skip to content

Commit 7691a9a

Browse files
committed
Revert "add support for Windows to update-checks-doc script"
This reverts commit 6807526. because some outputs cannot be updated on Windows. For example the file path separator is different on Windows. It is not useful to partially support Windows by this tool.
1 parent 6807526 commit 7691a9a

File tree

9 files changed

+26
-140
lines changed

9 files changed

+26
-140
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
/scripts/generate-webhook-events/testdata/** -text
44
/scripts/generate-availability/testdata/** -text
55
/scripts/generate-actionlint-matcher/test/** -text
6-
/scripts/update-checks-doc/testdata/** -text

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ jobs:
104104
echo "$diffs" >&2
105105
exit 1
106106
fi
107+
- name: Check `docs/checks.md` is up-to-date
108+
run: go run ./scripts/update-checks-doc -check ./docs/checks.md
107109
- name: Install staticcheck
108110
run: |
109111
go install honnef.co/go/tools/cmd/staticcheck@latest

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ all: build test lint
2323

2424
t test: .testtimestamp
2525

26-
.staticchecktimestamp: $(TESTS) $(SRCS) $(TOOL) docs/checks.md
26+
.staticchecktimestamp: $(TESTS) $(SRCS) $(TOOL)
2727
staticcheck ./...
2828
GOOS=js GOARCH=wasm staticcheck ./playground
29-
go run ./scripts/update-checks-doc -check -quiet docs/checks.md
3029
touch .staticchecktimestamp
3130

3231
l lint: .staticchecktimestamp

docs/checks.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2182,7 +2182,6 @@ jobs:
21822182
```
21832183

21842184
Output:
2185-
<!-- Skip update output on Windows -->
21862185

21872186
```
21882187
test.yaml:6:5: when a reusable workflow is called with "uses", "runs-on" is not available. only following keys are allowed: "name", "uses", "with", "secrets", "needs", "if", and "permissions" in job "job1" [syntax-check]

scripts/update-checks-doc/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ This script does:
99
- update the links to the [playground](https://rhysd.github.io/actionlint/) for the example inputs
1010
- check the document is up-to-date
1111

12+
For making the implementation simple, this script does not support Windows.
13+
1214
## Prerequisites
1315

1416
- Go
17+
- Linux or macOS
1518
- `shellcheck` command
1619
- `pyflakes` command
1720

scripts/update-checks-doc/main.go

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"io"
1212
"log"
1313
"os"
14-
"runtime"
1514
"strings"
1615

1716
"github.com/google/go-cmp/cmp"
@@ -184,7 +183,6 @@ func (u *Updater) Update() {
184183
isInputHeader := l == "Example input:"
185184
isOutputHeader := l == "Output:"
186185
isSkipOutput := l == "<!-- Skip update output -->"
187-
isSkipOutputWin := l == "<!-- Skip update output on Windows -->"
188186
isSkipPlaygroundLink := l == "<!-- Skip playground link -->"
189187
isPlaygroundLink := strings.HasPrefix(l, "[Playground](") && strings.HasSuffix(l, ")")
190188

@@ -196,7 +194,7 @@ func (u *Updater) Update() {
196194
u.expect(stateHeading, stateEnd)
197195
case isOutputHeader:
198196
u.expect(stateAfterInput)
199-
case isSkipOutput, isSkipOutputWin:
197+
case isSkipOutput:
200198
u.expect(stateOutputHeader)
201199
case isSkipPlaygroundLink, isPlaygroundLink:
202200
u.expect(stateAfterOutput)
@@ -276,12 +274,8 @@ func (u *Updater) Update() {
276274
u.state(stateOutputHeader, "Found example output header")
277275
}
278276
case stateOutputHeader:
279-
if isSkipOutput || isSkipOutputWin && runtime.GOOS == "windows" {
280-
reason := "Skip updating output due to the comment"
281-
if isSkipOutputWin {
282-
reason += " only on Windows"
283-
}
284-
u.state(stateAfterOutput, reason)
277+
if isSkipOutput {
278+
u.state(stateAfterOutput, "Skip updating output due to the comment")
285279
} else if l == "```" {
286280
u.state(stateOutputBlock, "Start code block for output")
287281
}
@@ -323,10 +317,8 @@ var stderr io.Writer = os.Stderr
323317

324318
func Main(args []string) error {
325319
var check bool
326-
var quiet bool
327320
flags := flag.NewFlagSet(args[0], flag.ContinueOnError)
328321
flags.BoolVar(&check, "check", false, "check the document is up-to-date")
329-
flags.BoolVar(&quiet, "quiet", false, "disable trace log")
330322
flags.SetOutput(stderr)
331323
flags.Usage = func() {
332324
fmt.Fprintln(stderr, "Usage: update-checks-doc [FLAGS] FILE\n\nFlags:")
@@ -343,20 +335,12 @@ func Main(args []string) error {
343335
}
344336
path := flags.Arg(0)
345337

346-
if quiet {
347-
log.SetOutput(io.Discard)
348-
}
349-
350338
in, err := os.ReadFile(path)
351339
if err != nil {
352340
return fmt.Errorf("could not read the document file: %w", err)
353341
}
354342
log.Printf("Read %d bytes from %q", len(in), path)
355343

356-
if runtime.GOOS == "windows" {
357-
in = bytes.ReplaceAll(in, []byte{'\r', '\n'}, []byte{'\n'})
358-
}
359-
360344
out, err := Update(in)
361345
if err != nil {
362346
return err

scripts/update-checks-doc/main_test.go

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ func testErr(t *testing.T, err error, want ...string) {
4040
}
4141

4242
func TestMainGenerateOK(t *testing.T) {
43+
if runtime.GOOS == "windows" {
44+
t.Skip("update-checks-doc doesn't support Windows")
45+
}
4346
root := t.TempDir()
4447

4548
in := must(os.Open(filepath.FromSlash("testdata/ok/minimal.in")))
@@ -61,15 +64,11 @@ func TestMainGenerateOK(t *testing.T) {
6164
}
6265

6366
func TestMainCheckOK(t *testing.T) {
64-
path := filepath.FromSlash("testdata/ok/minimal.out")
65-
if err := Main([]string{"exe", "-check", path}); err != nil {
66-
t.Fatal(err)
67+
if runtime.GOOS == "windows" {
68+
t.Skip("update-checks-doc doesn't support Windows")
6769
}
68-
}
69-
70-
func TestMainCheckQuietOK(t *testing.T) {
7170
path := filepath.FromSlash("testdata/ok/minimal.out")
72-
if err := Main([]string{"exe", "-check", "-quiet", path}); err != nil {
71+
if err := Main([]string{"exe", "-check", path}); err != nil {
7372
t.Fatal(err)
7473
}
7574
}
@@ -81,6 +80,9 @@ func TestMainPrintHelp(t *testing.T) {
8180
}
8281

8382
func TestMainCheckError(t *testing.T) {
83+
if runtime.GOOS == "windows" {
84+
t.Skip("update-checks-doc doesn't support Windows")
85+
}
8486
path := filepath.FromSlash("testdata/ok/minimal.in")
8587
testErr(t, Main([]string{"exe", "-check", path}), "checks document has some update")
8688
}
@@ -98,6 +100,9 @@ func TestMainInvalidCheckFlag(t *testing.T) {
98100
}
99101

100102
func TestMainNoUpdate(t *testing.T) {
103+
if runtime.GOOS == "windows" {
104+
t.Skip("update-checks-doc doesn't support Windows")
105+
}
101106
path := filepath.FromSlash("testdata/ok/minimal.out")
102107
if err := Main([]string{"exe", path}); err != nil {
103108
t.Fatal(err)
@@ -112,6 +117,10 @@ func TestMainUpdateError(t *testing.T) {
112117
}
113118

114119
func TestUpdateOK(t *testing.T) {
120+
if runtime.GOOS == "windows" {
121+
t.Skip("update-checks-doc doesn't support Windows")
122+
}
123+
115124
dir := filepath.FromSlash("testdata/ok")
116125

117126
tests := []string{}
@@ -120,18 +129,7 @@ func TestUpdateOK(t *testing.T) {
120129
if !strings.HasSuffix(n, ".in") {
121130
continue
122131
}
123-
124-
id := strings.TrimSuffix(n, filepath.Ext(n))
125-
// This test case does not work on Windows
126-
if runtime.GOOS == "windows" && id == "replace_absolute_path" {
127-
continue
128-
}
129-
// This test case only works on Windows
130-
if runtime.GOOS != "windows" && id == "skip_output_on_windows" {
131-
continue
132-
}
133-
134-
tests = append(tests, id)
132+
tests = append(tests, strings.TrimSuffix(n, filepath.Ext(n)))
135133
}
136134

137135
for _, tc := range tests {

scripts/update-checks-doc/testdata/ok/skip_output_on_windows.in

Lines changed: 0 additions & 49 deletions
This file was deleted.

scripts/update-checks-doc/testdata/ok/skip_output_on_windows.out

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)