Skip to content
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
35 changes: 35 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# Code coverage report
#
# Reports tests code coverage to coveralls.
# Uses COVERALLS_TOKEN env var from GitHub repo secrets.
#
# see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
#

name: Submit code coverage
on:
push:
branches:
- master
env:
GO111MODULE: on
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '^1.14.4'
- uses: actions/checkout@v2
- run: go version
- name: install
run: |
go get golang.org/x/tools/cmd/cover
- name: Test
run: cat tools/cover.txt | xargs go test -v -covermode=count -coverprofile=coverage.out
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
25 changes: 25 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Pull request check workflow
#
# Runs linter and tests on source branch to check code quality.
#
# see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
#

name: Check Pull Request
on: [pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v1
with:
version: v1.27
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '^1.14.4'
- run: go version
- run: go test ./...
File renamed without changes.
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
run:
tests: false
skip-dirs:
- pkg/worker
- cmd/webworker
3 changes: 1 addition & 2 deletions cmd/playground/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func main() {

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

wg.Add(1)
Expand Down
2 changes: 2 additions & 0 deletions cmd/webworker/webworker.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build js

package main

import (
Expand Down
4 changes: 2 additions & 2 deletions pkg/analyzer/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func TestPackage_SymbolByChar(t *testing.T) {
pkg := Package{
Synopsis: "test doc",
PackageSummary: PackageSummary{
Functions: newSymbolIndex(allFuncs),
Values: newSymbolIndex(allSyms),
Functions: NewSymbolIndex(allFuncs),
Values: NewSymbolIndex(allSyms),
},
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/analyzer/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// should be in sync with "testdata/src" !!!
var examplePackageSummary = PackageSummary{
Functions: newSymbolIndex([]*CompletionItem{
Functions: NewSymbolIndex([]*CompletionItem{
{
Label: "SomeFunc",
Kind: Function,
Expand Down Expand Up @@ -71,7 +71,7 @@ var examplePackageSummary = PackageSummary{
Documentation: NewMarkdownString("FuncUnnamedParams is function with unnamed params\n\n"),
},
}),
Values: newSymbolIndex([]*CompletionItem{
Values: NewSymbolIndex([]*CompletionItem{
{
Label: "SomeConst",
Kind: Constant,
Expand Down
3 changes: 2 additions & 1 deletion pkg/analyzer/sym_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ func emptySymbolIndex() SymbolIndex {
}
}

func newSymbolIndex(items []*CompletionItem) SymbolIndex {
// NewSymbolIndex creates a new symbol index from completion items
func NewSymbolIndex(items []*CompletionItem) SymbolIndex {
idx := SymbolIndex{
Symbols: items,
nameMap: make(map[string]*CompletionItem, len(items)),
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/sym_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestSymbolIndex(t *testing.T) {
{Label: "baz"},
}

index := newSymbolIndex(syms)
index := NewSymbolIndex(syms)
require.Equal(t, syms, index.Symbols)
require.Equal(t, len(syms), index.Len())

Expand Down
2 changes: 1 addition & 1 deletion pkg/compiler/storage/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (s LocalStorage) getOutputLocation(id ArtifactID) string {
// HasItem implements storage interface
func (s LocalStorage) HasItem(id ArtifactID) (bool, error) {
s.useLock.Lock()
s.useLock.Unlock()
defer s.useLock.Unlock()
fPath := s.getOutputLocation(id)
_, err := os.Stat(fPath)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions pkg/langserver/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ func WriteJSON(w http.ResponseWriter, i interface{}) {

w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(data)
return
_, _ = w.Write(data)
}

func shouldFormatCode(r *http.Request) (bool, error) {
Expand Down
1 change: 0 additions & 1 deletion pkg/testutil/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ func ContainsError(t *testing.T, err error, msg string) {
if emsg := err.Error(); !strings.Contains(emsg, msg) {
t.Fatalf("error %q should include %q", emsg, msg)
}
return
}
2 changes: 2 additions & 0 deletions pkg/worker/args.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build js

package worker

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/worker/callback.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build js

package worker

import "syscall/js"
Expand Down
2 changes: 2 additions & 0 deletions pkg/worker/worker.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build js

// Package worker contains Go web-worker WASM module bridge methods
package worker

Expand Down