diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..90598ab --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,44 @@ +name: "tests" + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + lint: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: { version: latest } + + test: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: Print system information + run: cat /proc/{meminfo,cpuinfo} + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: Install dependencies + run: go get . + - name: Build + run: go build -v ./... + - name: Test with the Go CLI + run: TEST_FORMAT=github-actions make test + diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..3c85559 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,18 @@ +run: + go: '1.22' +linters: + enable: + - govet + - typecheck + - unused + - gofmt + - whitespace + - gosimple + - exportloopref + - nilerr + - goimports + - staticcheck + - ineffassign + - errcheck + disable: + - depguard diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2fb8678 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +.PHONY: test lint + +TEST_FORMAT ?= standard-quiet +LINT_FORMAT ?= colored-line-number + +all: test lint + +test: + go install gotest.tools/gotestsum@latest + gotestsum --format $(TEST_FORMAT) -- -tags=test ./... +lint: + golangci-lint run --out-format $(LINT_FORMAT) --verbose diff --git a/djot_parser/djot_ast.go b/djot_parser/djot_ast.go index e5a1563..3bb71f7 100644 --- a/djot_parser/djot_ast.go +++ b/djot_parser/djot_ast.go @@ -262,7 +262,7 @@ type QuoteDirection int const ( OpenQuote QuoteDirection = +1 - CloseQuote = -1 + CloseQuote QuoteDirection = -1 ) func detectQuoteDirection(document []byte, position int) QuoteDirection { diff --git a/djot_tokenizer/attributes.go b/djot_tokenizer/attributes.go index 8bbc17e..fce8d3b 100644 --- a/djot_tokenizer/attributes.go +++ b/djot_tokenizer/attributes.go @@ -24,7 +24,6 @@ func MatchQuotedString(r tokenizer.TextReader, s tokenizer.ReaderState) ([]byte, tokenizer.Assertf(ok, "MaskRepeat must match because minCount is zero") value = append(value, r[start:next]...) - start = next if endString, ok := r.Token(next, "\""); ok { return value, endString, true } else if escape, ok := r.Token(next, "\\"); ok { diff --git a/tokenizer/line_tokenizer_test.go b/tokenizer/line_tokenizer_test.go index 30f9f1b..53be67c 100644 --- a/tokenizer/line_tokenizer_test.go +++ b/tokenizer/line_tokenizer_test.go @@ -1,8 +1,9 @@ package tokenizer import ( - "github.com/stretchr/testify/require" "testing" + + "github.com/stretchr/testify/require" ) func TestLineTokenizer(t *testing.T) {