mirror of
https://github.com/facundoolano/jorge.git
synced 2024-11-16 07:47:40 +01:00
run linter in github actions (#20)
* run linter in github actions * try fixing go mod * no install go * again * maybe this? * separate install * no v * fix lint errors
This commit is contained in:
parent
3064beb3a1
commit
adb17ad9d2
9 changed files with 32 additions and 24 deletions
9
.github/workflows/test.yml
vendored
9
.github/workflows/test.yml
vendored
|
@ -26,3 +26,12 @@ jobs:
|
|||
|
||||
- name: Test
|
||||
run: go test -v ./...
|
||||
|
||||
- name: Vet
|
||||
run: go vet -v ./...
|
||||
|
||||
- name: install staticcheck
|
||||
run: go install "honnef.co/go/tools/cmd/staticcheck@latest"
|
||||
|
||||
- name: staticcheck
|
||||
run: staticcheck ./...
|
||||
|
|
|
@ -59,6 +59,9 @@ func (cmd *Init) Run(ctx *kong.Context) error {
|
|||
|
||||
initfilesRoot := "initfiles"
|
||||
return fs.WalkDir(initfiles, initfilesRoot, func(path string, entry fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if path == initfilesRoot {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -135,18 +135,17 @@ func setupWatcher(config *config.Config) (*fsnotify.Watcher, *EventBroker, error
|
|||
|
||||
// Add the layouts and all source directories to the given watcher
|
||||
func addAll(watcher *fsnotify.Watcher, config *config.Config) error {
|
||||
err := watcher.Add(config.LayoutsDir)
|
||||
err = watcher.Add(config.DataDir)
|
||||
err = watcher.Add(config.IncludesDir)
|
||||
watcher.Add(config.LayoutsDir)
|
||||
watcher.Add(config.DataDir)
|
||||
watcher.Add(config.IncludesDir)
|
||||
// fsnotify watches all files within a dir, but non recursively
|
||||
// this walks through the src dir and adds watches for each found directory
|
||||
filepath.WalkDir(config.SrcDir, func(path string, entry fs.DirEntry, err error) error {
|
||||
return filepath.WalkDir(config.SrcDir, func(path string, entry fs.DirEntry, err error) error {
|
||||
if entry.IsDir() {
|
||||
watcher.Add(path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func rebuildSite(config *config.Config, watcher *fsnotify.Watcher, broker *EventBroker) {
|
||||
|
|
6
go.mod
6
go.mod
|
@ -1,6 +1,6 @@
|
|||
module github.com/facundoolano/jorge
|
||||
|
||||
go 1.22.0
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
github.com/alecthomas/chroma/v2 v2.5.0
|
||||
|
@ -12,8 +12,8 @@ require (
|
|||
github.com/tdewolff/minify/v2 v2.20.16
|
||||
github.com/yuin/goldmark v1.7.0
|
||||
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
|
||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b
|
||||
golang.org/x/text v0.3.3
|
||||
golang.org/x/net v0.14.0
|
||||
golang.org/x/text v0.12.0
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||
)
|
||||
|
|
11
go.sum
11
go.sum
|
@ -44,15 +44,12 @@ github.com/yuin/goldmark v1.7.0 h1:EfOIvIMZIzHdB/R/zVrikYLPPwJlfMcNczJFMs1m6sA=
|
|||
github.com/yuin/goldmark v1.7.0/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc h1:+IAOyRda+RLrxa1WC7umKOZRsGq4QrFFMYApOeHzQwQ=
|
||||
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc/go.mod h1:ovIvrum6DQJA4QsJSovrkC4saKHQVs7TvcaeO8AIl5I=
|
||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw=
|
||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
||||
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
||||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
|
|
2
main.go
2
main.go
|
@ -8,7 +8,7 @@ import (
|
|||
var cli struct {
|
||||
Init commands.Init `cmd:"" help:"Initialize a new website project." aliases:"i"`
|
||||
Build commands.Build `cmd:"" help:"Build a website project." aliases:"b"`
|
||||
Post commands.Post `cmd:"" help:"Initialize a new post template file." help:"title of the new post." aliases:"p"`
|
||||
Post commands.Post `cmd:"" help:"Initialize a new post template file." aliases:"p"`
|
||||
Serve commands.Serve `cmd:"" help:"Run a local server for the website." aliases:"s"`
|
||||
Version kong.VersionFlag `short:"v"`
|
||||
}
|
||||
|
|
|
@ -58,7 +58,6 @@ var smartifyTransforms = []struct {
|
|||
}
|
||||
|
||||
var smartifyReplacer *strings.Replacer
|
||||
var smartifyReplaceSpans = map[string]string{}
|
||||
|
||||
func init() {
|
||||
smartifyReplacer = strings.NewReplacer(
|
||||
|
|
|
@ -20,10 +20,11 @@ const string = "joe's garage";
|
|||
</html>`
|
||||
|
||||
output, err := Smartify(".html", strings.NewReader(input))
|
||||
assertEqual(t, err, nil)
|
||||
buf := new(strings.Builder)
|
||||
_, err = io.Copy(buf, output)
|
||||
|
||||
assertEqual(t, err, nil)
|
||||
|
||||
assertEqual(t, buf.String(), `<html><head>
|
||||
<script type="text/javascript">
|
||||
const url = 'http://localhost:4001/_events/';
|
||||
|
|
|
@ -69,7 +69,7 @@ title: about
|
|||
|
||||
// add a static file (no front matter)
|
||||
content = `go away!`
|
||||
file = newFile(config.SrcDir, "robots.txt", content)
|
||||
newFile(config.SrcDir, "robots.txt", content)
|
||||
|
||||
site, err := Load(*config)
|
||||
|
||||
|
@ -155,7 +155,7 @@ date: 2023-01-01
|
|||
file = newFile(config.SrcDir, "about.html", content)
|
||||
defer os.Remove(file.Name())
|
||||
|
||||
site, err := Load(*config)
|
||||
site, _ := Load(*config)
|
||||
output, err := site.render(site.templates[file.Name()])
|
||||
assertEqual(t, err, nil)
|
||||
assertEqual(t, string(output), `<ul>
|
||||
|
@ -208,7 +208,7 @@ tags: [software]
|
|||
file = newFile(config.SrcDir, "about.html", content)
|
||||
defer os.Remove(file.Name())
|
||||
|
||||
site, err := Load(*config)
|
||||
site, _ := Load(*config)
|
||||
output, err := site.render(site.templates[file.Name()])
|
||||
assertEqual(t, err, nil)
|
||||
assertEqual(t, string(output), `<h1>software</h1>
|
||||
|
@ -259,7 +259,7 @@ title: "2. an oldie!"
|
|||
file = newFile(config.SrcDir, "index.html", content)
|
||||
defer os.Remove(file.Name())
|
||||
|
||||
site, err := Load(*config)
|
||||
site, _ := Load(*config)
|
||||
output, err := site.render(site.templates[file.Name()])
|
||||
assertEqual(t, err, nil)
|
||||
assertEqual(t, string(output), `<ul>
|
||||
|
@ -314,7 +314,7 @@ tags: [software]
|
|||
file = newFile(config.SrcDir, "about.html", content)
|
||||
defer os.Remove(file.Name())
|
||||
|
||||
site, err := Load(*config)
|
||||
site, _ := Load(*config)
|
||||
output, err := site.render(site.templates[file.Name()])
|
||||
assertEqual(t, err, nil)
|
||||
assertEqual(t, strings.TrimSpace(string(output)), `goodbye! - an overridden excerpt
|
||||
|
@ -347,7 +347,7 @@ func TestRenderDataFile(t *testing.T) {
|
|||
file = newFile(config.SrcDir, "projects.html", content)
|
||||
defer os.Remove(file.Name())
|
||||
|
||||
site, err := Load(*config)
|
||||
site, _ := Load(*config)
|
||||
output, err := site.render(site.templates[file.Name()])
|
||||
assertEqual(t, err, nil)
|
||||
assertEqual(t, string(output), `<ul>
|
||||
|
|
Loading…
Reference in a new issue