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/push_pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Go
on: [push, pull_request]
jobs:

build:
name: Test on go ${{ matrix.go_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
go_version: [1.13]
os: [ubuntu-latest, macOS-latest]

steps:
- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go_version }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Test
run: |
make test-coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload coverage
run: |
os=os_$(echo ${{ matrix.os }} | tr '[:punct:]' '_')
go=go_$(echo ${{ matrix.go_version }} | tr '[:punct:]' '_')
bash <(curl -s https://codecov.io/bash) -f coverage.txt -cF $os,$go
env:
CODECOV_TOKEN: be731f61-6ca9-42b0-8f1a-59f4a0b28c0d
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: go

go: 1.12.x
go: 1.13.x
go_import_path: github.com/src-d/gitcollector

matrix:
Expand All @@ -10,8 +10,7 @@ services:
- docker

script:
- GO111MODULE=on
- make ci-script
- make test

jobs:
include:
Expand All @@ -30,7 +29,7 @@ jobs:
skip_cleanup: true
on:
tags: true

after_deploy:
- make docker-push-latest-release

Expand Down
30 changes: 23 additions & 7 deletions discovery/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ func TestGitHub(t *testing.T) {
timeToStop = 5 * time.Second
)

token, _ := getToken()
token, err := getToken()
if err != nil {
t.Skip(err.Error())
}

queue := make(chan *github.Repository, 50)
advertiseRepos := func(
_ context.Context,
Expand Down Expand Up @@ -74,7 +78,7 @@ func TestGitHub(t *testing.T) {
}
}()

err := discovery.Start()
err = discovery.Start()
req.True(ErrDiscoveryStopped.Is(err))

close(queue)
Expand Down Expand Up @@ -151,7 +155,11 @@ func TestExcludeRepos(t *testing.T) {
timeToStop = 5 * time.Second
)

token, _ := getToken()
token, err := getToken()
if err != nil {
t.Skip(err.Error())
}

queue := make(chan *github.Repository, 50)
advertiseRepos := func(
_ context.Context,
Expand Down Expand Up @@ -200,7 +208,7 @@ func TestExcludeRepos(t *testing.T) {
}
}()

err := discovery.Start()
err = discovery.Start()
req.True(ErrDiscoveryStopped.Is(err))

close(queue)
Expand Down Expand Up @@ -246,6 +254,11 @@ func TestProxyMockUps(t *testing.T) {
func testProxyMockUp(t *testing.T, code int, errContains string) {
const org = "bblfsh"

token, err := getToken()
if err != nil {
t.Skip(err.Error())
}

healthyTransport := http.DefaultTransport
defer func() { http.DefaultTransport = healthyTransport }()

Expand All @@ -263,7 +276,6 @@ func testProxyMockUp(t *testing.T, code int, errContains string) {

require.NoError(t, testutils.SetTransportProxy())

token, _ := getToken()
queue := make(chan *github.Repository, 50)
advertiseRepos := func(
_ context.Context,
Expand Down Expand Up @@ -322,7 +334,11 @@ func TestAdvertiseErrors(t *testing.T) {
func testAdvertise(t *testing.T, ac advertiseCase) {
const org = "bblfsh"

token, _ := getToken()
token, err := getToken()
if err != nil {
t.Skip(err.Error())
}

queue := make(chan *github.Repository, 50)
advertiseRepos := func(
ctx context.Context,
Expand Down Expand Up @@ -356,7 +372,7 @@ func testAdvertise(t *testing.T, ac advertiseCase) {
},
)

err := discovery.Start()
err = discovery.Start()
require.Error(t, err)
require.Contains(t, err.Error(), ac.errContains)
}
Expand Down
6 changes: 5 additions & 1 deletion downloader/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,11 @@ func testPeriodicallyBrokenGithubAPI(t *testing.T, h *testhelper.Helper) {
blackListRepoIDs := make(map[borges.RepositoryID]struct{})
for err := range errs {
if err != nil {
require.Contains(t, err.Error(), "Internal Server Error")
if strings.Contains(err.Error(), "EOF") {
require.Contains(t, err.Error(), "EOF")
} else {
require.Contains(t, err.Error(), "Internal Server Error")
}
log.Infof("error: %q", err.Error())
blackListRepoIDs[getRepoIDFromErrorText(err.Error())] = struct{}{}
failedCounter++
Expand Down
13 changes: 12 additions & 1 deletion integration/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package integration

import (
"database/sql"
"os"
"runtime"
"strings"
"testing"

_ "github.com/lib/pq"
Expand Down Expand Up @@ -41,6 +43,10 @@ func TestPostgres(t *testing.T) {
t.Skip("cannot run these tests on osx")
}

if os.Getenv("GITHUB_TOKEN") == "" {
t.Skip("github token not defined")
}

h, err := NewHelper(orgs)
require.NoError(t, err)
defer h.Close()
Expand Down Expand Up @@ -72,7 +78,12 @@ func testBrokenPostgresEndpoint(t *testing.T, h *helper) {

err := h.Exec()
require.Error(t, err)
require.Contains(t, err.Error(), "no such host")

if strings.Contains(err.Error(), "lookup broken") {
require.Contains(t, err.Error(), "lookup broken")
} else {
require.Contains(t, err.Error(), "no such host")
}
}

func testPostgresCreateSchemaFail(t *testing.T, h *helper) {
Expand Down