Skip to content

Commit

Permalink
CI: Add macOS and Windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
thrasher- committed Dec 12, 2023
1 parent 1f7933f commit 7bbc0f3
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 258 deletions.
125 changes: 46 additions & 79 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,34 @@ env:
jobs:
backend-psql:
name: GoCryptoTrader back-end with PSQL
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_DB: gct_dev_ci
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
strategy:
matrix:
include:
- os: ubuntu-latest
goarch: amd64
- os: ubuntu-latest
goarch: 386
- os: macos-latest
goarch: amd64
- os: windows-latest
goarch: amd64
runs-on: ${{ matrix.os }}

steps:
- name: Cancel previous workflow runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Cache go modules
uses: actions/cache@v3
- uses: ikalnytskyi/action-setup-postgres@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-

- name: Test
run: go test -race -coverprofile coverage.txt -covermode atomic ./...
env:
PSQL_USER: postgres
PSQL_PASS: postgres
PSQL_HOST: localhost
PSQL_DBNAME: gct_dev_ci
PSQL_SKIPSQLCMD: true
PSQL_TESTDBNAME: gct_dev_ci
PSQL_SSLMODE: disable

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

backend-32bit:
name: GoCryptoTrader back-end 32-bit with PSQL
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_DB: gct_dev_ci
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
database: gct_dev_ci
id: postgres

steps:
- name: Cancel previous workflow runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Clear PGSERVICEFILE
run: |
echo "PGSERVICEFILE=" >> $GITHUB_ENV
shell: bash

- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -88,34 +42,47 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}

- name: Set up Go environment
run: |
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
shell: bash

- name: Additional steps for 386 architecture
if: matrix.goarch == '386'
run: |
echo "CGO_ENABLED=1" >> $GITHUB_ENV
sudo apt-get update
sudo apt-get install gcc-multilib g++-multilib
shell: bash

- name: Cache go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-386-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-386-

- name: Update apt-get
run: sudo apt-get update

- name: Install gcc-multilib
run: sudo apt-get install gcc-multilib
${{ env.GOMODCACHE }}
${{ env.GOCACHE }}
key: ${{ runner.os }}-go-${{ matrix.goarch }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ matrix.goarch }}-

- name: Test
run: go test -coverprofile coverage.txt -covermode atomic ./...
run: |
unset PGSERVICEFILE
if [ "${{ matrix.goarch }}" = "386" ]; then
go test -coverprofile coverage.txt -covermode atomic ./...
else
go test -race -coverprofile coverage.txt -covermode atomic ./...
fi
shell: bash
env:
GOARCH: ${{ matrix.goarch }}
PSQL_USER: postgres
PSQL_PASS: postgres
PSQL_HOST: localhost
PSQL_DBNAME: gct_dev_ci
PSQL_SKIPSQLCMD: true
PSQL_TESTDBNAME: gct_dev_ci
PSQL_SSLMODE: disable
GOARCH: 386
CGO_ENABLED: 1
CGO_CFLAGS: -fno-stack-protector

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
99 changes: 0 additions & 99 deletions .travis.yml

This file was deleted.

5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ LINTPKG = github.com/golangci/golangci-lint/cmd/[email protected]
LINTBIN = $(GOPATH)/bin/golangci-lint
GCTLISTENPORT=9050
GCTPROFILERLISTENPORT=8085
CRON = $(TRAVIS_EVENT_TYPE)
DRIVER ?= psql
RACE_FLAG := $(if $(NO_RACE_TEST),,-race)
CONFIG_FLAG = $(if $(CONFIG),-config $(CONFIG),)
Expand All @@ -24,11 +23,7 @@ linter:
check: linter test

test:
ifeq ($(CRON), cron)
go test $(RACE_FLAG) -tags=mock_test_off -coverprofile=coverage.txt -covermode=atomic ./...
else
go test $(RACE_FLAG) -coverprofile=coverage.txt -covermode=atomic ./...
endif

build:
go build $(LDFLAGS)
Expand Down
36 changes: 18 additions & 18 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
codecov:
require_ci_to_pass: true
comment:
behavior: default
layout: "reach,diff,flags,tree"
require_changes: false
coverage:
precision: 2
range: "70...100"
round: down
github_checks:
annotations: false
parsers:
gcov:
branch_detection:
conditional: true
loop: true
macro: false
method: false
require_ci_to_pass: true
comment:
behavior: default
layout: "reach,diff,flags,tree"
require_changes: false
coverage:
precision: 2
range: "70...100"
round: down
github_checks:
annotations: false
parsers:
gcov:
branch_detection:
conditional: true
loop: true
macro: false
method: false
39 changes: 0 additions & 39 deletions codelingo.yaml

This file was deleted.

19 changes: 1 addition & 18 deletions database/testhelpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,7 @@ var (

// GetConnectionDetails returns connection details for CI or test db instances
func GetConnectionDetails() *database.Config {
_, exists := os.LookupEnv("TRAVIS")
if exists {
return &database.Config{
Enabled: true,
Driver: "postgres",
ConnectionDetails: drivers.ConnectionDetails{
Host: "localhost",
Port: 5432,
Username: "postgres",
Password: "",
Database: "gct_dev_ci",
SSLMode: "",
},
}
}

_, exists = os.LookupEnv("APPVEYOR")
if exists {
if _, exists := os.LookupEnv("APPVEYOR"); exists {
return &database.Config{
Enabled: true,
Driver: "postgres",
Expand Down

0 comments on commit 7bbc0f3

Please sign in to comment.