Skip to content
Open
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/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test on ubuntu, macosx and windows
on:
push:
branches:
- master
tags:
- v[0-9]+.[0-9]+.[0-9]+
pull_request:
branches:
- master

jobs:
test:
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, windows-latest]
env:
PSQL_USER: user
PSQL_PWD: password
PSQL_DB: ghsync

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
uses: actions/checkout@v1

- name: Spin up docker compose
run: docker-compose up -d
if: matrix.os == 'ubuntu-latest'

- name: Test
run: |
make test-coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 24 additions & 5 deletions github/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,26 @@ func checkToken(t *testing.T) {
}
}

func isOSXOnTravis() bool {
func checkTokenOnGHA(t *testing.T) {
// I cannot read orgs since the scope of the temp token in GHA does not have the rights
if os.Getenv("GITHUB_TOKEN") != "" && os.Getenv("GITHUB_ACTION") != "" {
t.Skip("GITHUB_TOKEN does not have the rights to read orgs")
}
}

func isOSXOnCICD() bool {
// docker service is not supported on osx in Travis: https://docs.travis-ci.com/user/docker/
// nor GHA
// but maybe in a local osx dev env so we will skip only in travis
if runtime.GOOS == "darwin" && os.Getenv("TRAVIS") == "true" {
if runtime.GOOS == "darwin" && (os.Getenv("TRAVIS") == "true" || os.Getenv("GITHUB_ACTION") != "") {
return true
}
return false
}

func isWindowsOnCICD() bool {
// Linux Contains on Windows capabilities are not support in GHA nor Travis
if runtime.GOOS == "windows" && (os.Getenv("TRAVIS") == "true" || os.Getenv("GITHUB_ACTION") != "") {
return true
}
return false
Expand All @@ -113,6 +129,7 @@ func getDB(t *testing.T) (db *sql.DB) {
if err = database.Migrate(DBURL); err != nil {
require.Nil(t, err, "Cannot migrate the DB")
}
time.Sleep(10 * time.Second)
return db
}

Expand Down Expand Up @@ -172,7 +189,7 @@ type DownloaderTestSuite struct {
}

func (suite *DownloaderTestSuite) SetupSuite() {
if !isOSXOnTravis() {
if !(isOSXOnCICD() || isWindowsOnCICD()) {
suite.db = getDB(suite.T())
suite.NotNil(suite.db)
}
Expand Down Expand Up @@ -251,6 +268,7 @@ func testRepo(t *testing.T, oracle testutils.RepositoryTestOracle, d *Downloader
func (suite *DownloaderTestSuite) TestOnlineOrganizationDownload() {
t := suite.T()
checkToken(t)
checkTokenOnGHA(t)
testOracles, err := loadTests(onlineOrgTests)
suite.NoError(err, "Failed to read the testcases")
suite.Greater(len(testOracles.OrganizationTestOracles), 0, "Must contain at least one test")
Expand Down Expand Up @@ -368,6 +386,7 @@ func testOrgWithDB(t *testing.T, oracle testutils.OrganizationTestOracle, d *Dow
func (suite *DownloaderTestSuite) TestOnlineOrganizationDownloadWithDB() {
t := suite.T()
checkToken(t)
checkTokenOnGHA(t)
testOracles, err := loadTests(onlineOrgTests)
suite.NoError(err, "Failed to read the online tests")
suite.Greater(len(testOracles.OrganizationTestOracles), 0, "Must contain at least one test")
Expand Down Expand Up @@ -531,8 +550,8 @@ func (suite *DownloaderTestSuite) TestOfflineRepositoryDownloadWithDB() {
}

func (suite *DownloaderTestSuite) BeforeTest(suiteName, testName string) {
if strings.HasSuffix(testName, "WithDB") && isOSXOnTravis() {
suite.T().Skip("Don't test OSX with docker psql")
if strings.HasSuffix(testName, "WithDB") && (isOSXOnCICD() || isWindowsOnCICD()) {
suite.T().Skip("Don't test OSX/Windows with docker psql on CICD")
}
}

Expand Down