Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add github actions for lint & test #4

Merged
merged 9 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -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

18 changes: 18 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
run:
go: '1.22'
linters:
enable:
- govet
- typecheck
- unused
- gofmt
- whitespace
- gosimple
- exportloopref
- nilerr
- goimports
- staticcheck
- ineffassign
- errcheck
disable:
- depguard
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion djot_parser/djot_ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ type QuoteDirection int

const (
OpenQuote QuoteDirection = +1
CloseQuote = -1
CloseQuote QuoteDirection = -1
)

func detectQuoteDirection(document []byte, position int) QuoteDirection {
Expand Down
1 change: 0 additions & 1 deletion djot_tokenizer/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion tokenizer/line_tokenizer_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package tokenizer

import (
"github.com/stretchr/testify/require"
"testing"

"github.com/stretchr/testify/require"
)

func TestLineTokenizer(t *testing.T) {
Expand Down
Loading