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 11, 2023
1 parent 1f7933f commit 46612db
Showing 1 changed file with 31 additions and 79 deletions.
110 changes: 31 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: arm64
- 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
- uses: ikalnytskyi/action-setup-postgres@v4
with:
go-version: ${{ env.GO_VERSION }}
database: gct_dev_ci
id: postgres

- name: Cache go modules
uses: actions/cache@v3
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

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,32 @@ 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: 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: go test -race -coverprofile coverage.txt -covermode atomic ./...
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

0 comments on commit 46612db

Please sign in to comment.