Skip to content

Commit eb3917f

Browse files
authored
Initial commit
0 parents  commit eb3917f

File tree

13 files changed

+295
-0
lines changed

13 files changed

+295
-0
lines changed

.github/workflows/main.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build + Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
14+
- run: zip -r Hugo.zip Hugo -x "*.DS_Store"
15+
16+
- name: Upload style to release
17+
uses: svenstaro/upload-release-action@v2
18+
if: startsWith(github.ref, 'refs/tags/')
19+
with:
20+
repo_token: ${{ secrets.GITHUB_TOKEN }}
21+
file: Hugo.zip
22+
23+
test:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Go
32+
uses: actions/setup-go@v5
33+
34+
- name: Install Deps
35+
run: |
36+
wget https://github.com/errata-ai/vale/releases/download/v${VALE_VERSION}/vale_${VALE_VERSION}_Linux_64-bit.tar.gz
37+
mkdir bin && tar -xvzf vale_${VALE_VERSION}_Linux_64-bit.tar.gz -C bin
38+
echo "./bin" >> $GITHUB_PATH
39+
env:
40+
VALE_VERSION: 3.3.0
41+
42+
- name: Features
43+
run: |
44+
zip -r Hugo.zip Hugo -x "*.DS_Store"
45+
cd testdata && ../bin/vale sync && cd -
46+
go test -v ./...

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Hugo.zip
2+
/testdata/styles
3+
4+
# Binaries for programs and plugins
5+
*.exe
6+
*.exe~
7+
*.dll
8+
*.so
9+
*.dylib
10+
11+
# Test binary, built with `go test -c`
12+
*.test
13+
14+
# Output of the go coverage tool, specifically when used with LiteIDE
15+
*.out
16+
17+
# Dependency directories (remove the comment below to include it)
18+
# vendor/

Hugo/.vale.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[*.md]
2+
# Exclude `{{< ... >}}`, `{{% ... %}}`, [Who]({{< ... >}})
3+
TokenIgnores = ({{[%<] .* [%>]}}.*?{{[%<] ?/.* [%>]}}), \
4+
(\[.+\]\({{< .+ >}}\)), \
5+
[^\S\r\n]({{[%<] \w+ .+ [%>]}})\s, \
6+
[^\S\r\n]({{[%<](?:/\*) .* (?:\*/)[%>]}})\s
7+
8+
# Exclude `{{< myshortcode `This is some <b>HTML</b>, ... >}}`
9+
BlockIgnores = (?sm)^({{[%<] \w+ [^{]*?\s[%>]}})\n$, \
10+
(?s) *({{< highlight [^>]* ?>}}.*?{{< ?/ ?highlight >}})

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 errata.ai
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.PHONY: test zip sync
2+
3+
all: test
4+
5+
zip:
6+
zip -r Hugo.zip Hugo -x "*.DS_Store"
7+
8+
sync:
9+
cd testdata && vale sync && cd -
10+
11+
test: zip sync
12+
go test -v ./...

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Hugo
2+
3+
A Vale configuration for Hugo-generated static sites.
4+
5+
## Testing
6+
7+
```
8+
$ make test
9+
```

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/errata-ai/Hugo
2+
3+
go 1.17
4+
5+
require github.com/google/go-cmdtest v0.4.0
6+
7+
require (
8+
github.com/google/go-cmp v0.3.1 // indirect
9+
github.com/google/renameio v0.1.0 // indirect
10+
)

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
github.com/google/go-cmdtest v0.4.0 h1:ToXh6W5spLp3npJV92tk6d5hIpUPYEzHLkD+rncbyhI=
2+
github.com/google/go-cmdtest v0.4.0/go.mod h1:apVn/GCasLZUVpAJ6oWAuyP7Ne7CEsQbTnc0plM3m+o=
3+
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
4+
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
5+
github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=
6+
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package main
2+
3+
import "os"
4+
5+
func cdf() int {
6+
os.Chdir(os.Args[1])
7+
return 0
8+
}

main_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"fmt"
6+
"os"
7+
"os/exec"
8+
"path/filepath"
9+
"runtime"
10+
"testing"
11+
12+
"github.com/google/go-cmdtest"
13+
)
14+
15+
var update = flag.Bool("update", false, "replace test file contents with output")
16+
17+
func Test(t *testing.T) {
18+
ts, err := cmdtest.Read("testdata")
19+
if err != nil {
20+
t.Fatal(err)
21+
}
22+
23+
ts.Setup = func(_ string) error {
24+
_, testFileName, _, ok := runtime.Caller(0)
25+
if !ok {
26+
return fmt.Errorf("failed get real working directory from caller")
27+
}
28+
29+
projectRootDir := filepath.Join(filepath.Dir(testFileName), "testdata")
30+
if err := os.Setenv("ROOTDIR", projectRootDir); err != nil {
31+
return fmt.Errorf("failed change 'ROOTDIR' to caller working directory: %v", err)
32+
}
33+
34+
return nil
35+
}
36+
37+
path, err := exec.LookPath("vale")
38+
if err != nil {
39+
path = "./bin/vale"
40+
}
41+
42+
ts.Commands["vale"] = cmdtest.Program(path)
43+
ts.Commands["cdf"] = cmdtest.InProcessProgram("cdf", cdf)
44+
45+
ts.Run(t, *update)
46+
}

0 commit comments

Comments
 (0)