Skip to content

Commit

Permalink
update dependencies and workflows (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriehSchneier authored Aug 23, 2024
1 parent 865a92b commit a16d1ed
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/generate-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
runs-on: ${{ vars.RUNNER_UBUNTU && fromJSON(vars.RUNNER_UBUNTU) || 'ubuntu-latest' }}
steps:
- name: Check out code
uses: actions/checkout@master
uses: actions/checkout@v4
with:
fetch-depth: '0'

- name: Checkout github-tag-action
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ vars.GENERATE_TAG_REPO || 'anothrNick/github-tag-action' }}
ref: ${{ vars.GENERATE_TAG_REF || '1.62.0' }}
Expand Down
26 changes: 16 additions & 10 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,31 @@ jobs:
runs-on: ${{ vars.RUNNER_UBUNTU && fromJSON(vars.RUNNER_UBUNTU) || 'ubuntu-latest' }}
steps:
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.22
check-latest: true
cache: false

- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6

build:
name: Build
runs-on: ${{ vars.RUNNER_UBUNTU && fromJSON(vars.RUNNER_UBUNTU) || 'ubuntu-latest' }}
steps:
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.22
check-latest: true
cache: false

- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build
run: make build
Expand All @@ -45,12 +49,14 @@ jobs:
runs-on: ${{ vars.RUNNER_UBUNTU && fromJSON(vars.RUNNER_UBUNTU) || 'ubuntu-latest' }}
steps:
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.22
check-latest: true
cache: false

- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run tests
run: make test
Expand Down
6 changes: 3 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ linters-settings:
errcheck:
check-blank: true
govet:
check-shadowing: true
shadowing: true
revive:
min-confidence: 0
dupl:
Expand All @@ -25,7 +25,7 @@ linters:
disable-all: true
enable:
- bodyclose
- depguard
# - depguard
- dogsled
- dupl
- errcheck
Expand All @@ -50,7 +50,7 @@ linters:
- misspell
- nakedret
- prealloc
- exportloopref
- copyloopvar

- staticcheck
- stylecheck
Expand Down
8 changes: 4 additions & 4 deletions cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,13 @@ func loadTestGrammar() parser.Parsers {
return wbnf.MustCompile(string(text), makeResolver(inGrammarFile))
}

func testWbnfFile(filename, grammar string) error {
func testWbnfFile(filename, grammar string) {
g := wbnf.MustCompile(grammar, makeResolver(filename))
if printTree {
fmt.Println(ast.BuildTreeView("grammar", g.Node().(wbnf.GrammarNode).Node, true))
} else {
fmt.Println(g.Node().(ast.Node))
}

return nil
}

func test(c *cli.Context) error {
Expand Down Expand Up @@ -131,7 +129,9 @@ func test(c *cli.Context) error {
input = string(buf)
}
if inGrammarFile == "" {
return testWbnfFile(source, input)
testWbnfFile(source, input)

return nil
}
g := loadTestGrammar()

Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ module github.com/arr-ai/wbnf
go 1.18

require (
github.com/arr-ai/frozen v0.20.1
github.com/iancoleman/strcase v0.2.0
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.0
github.com/urfave/cli v1.22.10
github.com/arr-ai/frozen v0.20.3
github.com/iancoleman/strcase v0.3.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.9.0
github.com/urfave/cli v1.22.15
)

require (
github.com/arr-ai/hash v0.8.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/arr-ai/hash v1.1.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959 // indirect
golang.org/x/sys v0.13.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
41 changes: 21 additions & 20 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion parser/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s Scanner) Format(state fmt.State, c rune) {
if c == 'q' {
_, _ = fmt.Fprintf(state, "%q", s.slice())
} else {
_, _ = state.Write([]byte(s.slice()))
_, _ = state.Write([]byte(s.slice())) //nolint:errcheck
}
}

Expand Down
18 changes: 9 additions & 9 deletions wbnf/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,28 @@ func parseString(s string) string {
if err != nil {
panic(err)
}
sb.WriteByte(uint8(n))
sb.WriteByte(uint8(n)) // nolint:gosec // G115: integer overflow conversion int64 -> uint8
i++
case 'u':
n, err := strconv.ParseInt(s[i:i+4], 16, 16)
if err != nil {
panic(err)
}
sb.WriteByte(uint8(n))
sb.WriteByte(uint8(n)) // nolint:gosec // G115: integer overflow conversion int64 -> uint8
i += 2
case 'U':
n, err := strconv.ParseInt(s[i:i+8], 16, 32)
if err != nil {
panic(err)
}
sb.WriteByte(uint8(n))
sb.WriteByte(uint8(n)) // nolint:gosec // G115: integer overflow conversion int64 -> uint8
i += 4
case '0', '1', '2', '3', '4', '5', '6', '7':
n, err := strconv.ParseInt(s[i:i+3], 8, 8)
if err != nil {
panic(err)
}
sb.WriteByte(uint8(n))
sb.WriteByte(uint8(n)) // nolint:gosec // G115: integer overflow conversion int64 -> uint8
i++
case 'a':
sb.WriteByte('\a')
Expand Down Expand Up @@ -176,23 +176,23 @@ func (gb grammarBuilder) buildQuant(q QuantNode, term parser.Term) parser.Term {
return parser.Some(term)
}
case 1:
min := 0
max := 0
mn := 0
mx := 0
if x := q.OneMin().String(); x != "" {
val, err := strconv.Atoi(x)
if err != nil {
panic(err)
}
min = val
mn = val
}
if x := q.OneMax().String(); x != "" {
val, err := strconv.Atoi(x)
if err != nil {
panic(err)
}
max = val
mx = val
}
return parser.Quant{Term: term, Min: min, Max: max}
return parser.Quant{Term: term, Min: mn, Max: mx}
case 2:
assoc := parser.NewAssociativity(q.OneOp())
sep := gb.buildNamed(*q.OneNamed())
Expand Down

0 comments on commit a16d1ed

Please sign in to comment.