Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: add github actions workflow #3644

Merged
merged 12 commits into from
Jun 2, 2021
65 changes: 65 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Go

on:
push:
pull_request:

jobs:

build:

strategy:
matrix:
os: [ubuntu-latest]
go: [1.16.4, 1.15.11]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to prevent duplication of go/pg versions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried removing the dupe with env vars, but failed to get it to work. Also, it was a little wonky because env vars have to be strings and these are arrays. I think it's not worth solving right now. According to the GitHub community forums they don't support yml anchors and aliases yet. If that gets added that'll probably be the ideal way to solve this.

pg: [9.6.5, 10]

services:
postgres:
image: postgres:${{ matrix.pg }}
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- run: ./gomod.sh
- run: ./gofmt.sh
- run: ./gogenerate.sh
- run: ./govet.sh
- run: ./staticcheck.sh
- run: go build ./...
- run: go test -race -cover ./...
env:
PGHOST: localhost
PGPORT: 5432
PGUSER: postgres
PGPASSWORD: postgres
PGDATABASE: postgres
REDIS_HOST: localhost
REDIS_PORT: 6379