Skip to content

Commit 141b363

Browse files
committed
test error from empty id attribute in update-checks-doc script
1 parent d32b16e commit 141b363

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

scripts/update-checks-doc/README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ This script does:
88
- update the outputs of the example inputs; the code blocks after `Output:` header
99
- update the links to the [playground](https://rhysd.github.io/actionlint/) for the example inputs
1010

11-
For making the implementation simple, this script does not support Windows. Please run this script
12-
on Linux or macOS.
11+
For making the implementation simple, this script does not support Windows.
12+
13+
## Prerequisites
14+
15+
- Go
16+
- Linux or macOS
17+
- `shellcheck` command
18+
- `pyflakes` command
1319

1420
## Usage
1521

22+
```
23+
go run ./scripts/update-checks-doc [-check] FILE
24+
```
25+
1626
Update the document. This command directly modifies the file.
1727

1828
```sh

scripts/update-checks-doc/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ func Update(in []byte) ([]byte, error) {
113113
}
114114
if strings.HasPrefix(l, `<a id="`) && strings.HasSuffix(l, `"></a>`) {
115115
anchor = strings.TrimSuffix(strings.TrimPrefix(l, `<a id="`), `"></a>`)
116+
if len(anchor) == 0 {
117+
return nil, fmt.Errorf("id for <a> tag is empty at line %d", lnum)
118+
}
116119
}
117120
if l == "Example input:" {
118121
log.Printf("Found example input header for %q at line %d", section, lnum)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<a id=""></a>
2+
## Hello
3+
4+
Example input:
5+
6+
```yaml
7+
on: push
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- run: echo ${{ unknown }}
13+
```
14+
15+
Output:
16+
17+
```
18+
This section will be generated
19+
```
20+
21+
[Playground](https://rhysd.github.io/actionlint/#THIS_URL_WILL_BE_UPDATED)
22+
23+
The `id` attribute of the `<a>` is an empty string.

0 commit comments

Comments
 (0)