Add lint to CI and pre-commit
This commit is contained in:
parent
c9633c095d
commit
7425bc25d9
53
.github/workflows/go.yml
vendored
Normal file
53
.github/workflows/go.yml
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
name: Go
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
go-version: [1.18]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Go ${{ matrix.go-version }}
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go-version }}
|
||||||
|
|
||||||
|
- name: Install goimports
|
||||||
|
run: |
|
||||||
|
go install golang.org/x/tools/cmd/goimports@latest
|
||||||
|
export PATH="$HOME/go/bin:$PATH"
|
||||||
|
|
||||||
|
- name: Install pre-commit
|
||||||
|
run: pip install pre-commit
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
run: pre-commit run -a
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
go-version: [1.17, 1.18]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Go ${{ matrix.go-version }}
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go-version }}
|
||||||
|
|
||||||
|
- name: Install libolm
|
||||||
|
run: sudo apt-get install libolm-dev libolm3
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: go build -v ./...
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: go test -v ./...
|
14
.pre-commit-config.yaml
Normal file
14
.pre-commit-config.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.1.0
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
exclude_types: [markdown]
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: check-yaml
|
||||||
|
- id: check-added-large-files
|
||||||
|
|
||||||
|
- repo: https://github.com/tekwizely/pre-commit-golang
|
||||||
|
rev: v1.0.0-beta.5
|
||||||
|
hooks:
|
||||||
|
- id: go-imports-repo
|
@ -840,7 +840,7 @@ func (c *Container) MarkRead(roomID id.RoomID, eventID id.EventID) {
|
|||||||
defer debug.Recover()
|
defer debug.Recover()
|
||||||
err := c.client.MarkRead(roomID, eventID)
|
err := c.client.MarkRead(roomID, eventID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
debug.Print("Failed to mark %s in %s as read: %v", eventID, roomID, err)
|
debug.Printf("Failed to mark %s in %s as read: %v", eventID, roomID, err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func autocompleteFile(cmd *CommandAutocomplete) (completions []string, newText s
|
|||||||
func autocompleteToggle(cmd *CommandAutocomplete) (completions []string, newText string) {
|
func autocompleteToggle(cmd *CommandAutocomplete) (completions []string, newText string) {
|
||||||
completions = make([]string, 0, len(toggleMsg))
|
completions = make([]string, 0, len(toggleMsg))
|
||||||
for k := range toggleMsg {
|
for k := range toggleMsg {
|
||||||
if (strings.HasPrefix(k, cmd.RawArgs)) {
|
if strings.HasPrefix(k, cmd.RawArgs) {
|
||||||
completions = append(completions, k)
|
completions = append(completions, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user