Skip to content

Commit 4e87948

Browse files
authored
Merge pull request #46 from x1unix/feat/gh-action-lint
Add PR check and coverage submit workflows
2 parents d5ebf5d + 0176407 commit 4e87948

File tree

16 files changed

+83
-12
lines changed

16 files changed

+83
-12
lines changed

.github/workflows/coverage.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Code coverage report
3+
#
4+
# Reports tests code coverage to coveralls.
5+
# Uses COVERALLS_TOKEN env var from GitHub repo secrets.
6+
#
7+
# see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
8+
#
9+
10+
name: Submit code coverage
11+
on:
12+
push:
13+
branches:
14+
- master
15+
env:
16+
GO111MODULE: on
17+
jobs:
18+
coverage:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Setup Go
22+
uses: actions/setup-go@v2
23+
with:
24+
go-version: '^1.14.4'
25+
- uses: actions/checkout@v2
26+
- run: go version
27+
- name: install
28+
run: |
29+
go get golang.org/x/tools/cmd/cover
30+
- name: Test
31+
run: cat tools/cover.txt | xargs go test -v -covermode=count -coverprofile=coverage.out
32+
- name: Send coverage
33+
uses: shogo82148/actions-goveralls@v1
34+
with:
35+
path-to-profile: coverage.out

.github/workflows/pull_request.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# Pull request check workflow
3+
#
4+
# Runs linter and tests on source branch to check code quality.
5+
#
6+
# see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
7+
#
8+
9+
name: Check Pull Request
10+
on: [pull_request]
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: golangci-lint
17+
uses: golangci/golangci-lint-action@v1
18+
with:
19+
version: v1.27
20+
- name: Setup Go
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: '^1.14.4'
24+
- run: go version
25+
- run: go test ./...
File renamed without changes.

.golangci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
run:
2+
tests: false
3+
skip-dirs:
4+
- pkg/worker
5+
- cmd/webworker

cmd/playground/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func main() {
5252

5353
flag.Parse()
5454
l := getLogger(args.debug)
55-
defer l.Sync()
55+
defer l.Sync() //nolint:errcheck
5656
if err := start(goRoot, args); err != nil {
5757
l.Sugar().Fatal(err)
5858
}
@@ -143,7 +143,6 @@ func startHttpServer(ctx context.Context, wg *sync.WaitGroup, server *http.Serve
143143
if err := server.Shutdown(shutdownCtx); err != nil {
144144
logger.Errorf("Could not gracefully shutdown the server: %v\n", err)
145145
}
146-
return
147146
}()
148147

149148
wg.Add(1)

cmd/webworker/webworker.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build js
2+
13
package main
24

35
import (

pkg/analyzer/package_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ func TestPackage_SymbolByChar(t *testing.T) {
2929
pkg := Package{
3030
Synopsis: "test doc",
3131
PackageSummary: PackageSummary{
32-
Functions: newSymbolIndex(allFuncs),
33-
Values: newSymbolIndex(allSyms),
32+
Functions: NewSymbolIndex(allFuncs),
33+
Values: NewSymbolIndex(allSyms),
3434
},
3535
}
3636

pkg/analyzer/scanner_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
// should be in sync with "testdata/src" !!!
1212
var examplePackageSummary = PackageSummary{
13-
Functions: newSymbolIndex([]*CompletionItem{
13+
Functions: NewSymbolIndex([]*CompletionItem{
1414
{
1515
Label: "SomeFunc",
1616
Kind: Function,
@@ -71,7 +71,7 @@ var examplePackageSummary = PackageSummary{
7171
Documentation: NewMarkdownString("FuncUnnamedParams is function with unnamed params\n\n"),
7272
},
7373
}),
74-
Values: newSymbolIndex([]*CompletionItem{
74+
Values: NewSymbolIndex([]*CompletionItem{
7575
{
7676
Label: "SomeConst",
7777
Kind: Constant,

pkg/analyzer/sym_index.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ func emptySymbolIndex() SymbolIndex {
2020
}
2121
}
2222

23-
func newSymbolIndex(items []*CompletionItem) SymbolIndex {
23+
// NewSymbolIndex creates a new symbol index from completion items
24+
func NewSymbolIndex(items []*CompletionItem) SymbolIndex {
2425
idx := SymbolIndex{
2526
Symbols: items,
2627
nameMap: make(map[string]*CompletionItem, len(items)),

pkg/analyzer/sym_index_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestSymbolIndex(t *testing.T) {
1313
{Label: "baz"},
1414
}
1515

16-
index := newSymbolIndex(syms)
16+
index := NewSymbolIndex(syms)
1717
require.Equal(t, syms, index.Symbols)
1818
require.Equal(t, len(syms), index.Len())
1919

0 commit comments

Comments
 (0)