CI: Add macOS and Windows support #429
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: [push, pull_request] | |
name: CI | |
env: | |
GO_VERSION: 1.21.x | |
jobs: | |
backend-psql: | |
name: GoCryptoTrader back-end with PSQL | |
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 }} | |
- uses: ikalnytskyi/action-setup-postgres@v4 | |
with: | |
database: gct_dev_ci | |
id: postgres | |
- name: Clear PGSERVICEFILE | |
run: | | |
echo "PGSERVICEFILE=" >> $GITHUB_ENV | |
shell: bash | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
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: | | |
${{ env.GOMODCACHE }} | |
${{ env.GOCACHE }} | |
key: ${{ runner.os }}-go-${{ matrix.goarch }}-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ runner.os }}-go-${{ matrix.goarch }}- | |
- name: Test | |
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 | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
frontend: | |
name: GoCryptoTrader front-end | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cancel previous workflow runs | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '10.8.x' | |
- name: Cache Node.js modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.OS }}-node- | |
${{ runner.OS }}- | |
- name: Build | |
run: | | |
cd web/ | |
npm install | |
npm run lint | |
npm run build |