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

Integration test #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
45 changes: 45 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build & Test

on:
pull_request: # Apply to all pull requests
push:
branches:
- main # Apply to all pushes to `main`
workflow_dispatch:
inputs:
tags:
description: 'Optional Tag'
required: false

jobs:
container-job:
runs-on: ubuntu-latest
# Docker Hub image that `container-job` executes in
container: golang:1.17

# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
image: postgres:14-alpine
env:
POSTGRES_DB: footest
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v3

# - name: golangci-lint
# uses: golangci/golangci-lint-action@v3

- name: Test
run: make migrate-up-test test
51 changes: 51 additions & 0 deletions .github/workflows/protos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish protobufs

on:
pull_request: # Apply to all pull requests

jobs:
validate-protos:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Check to see if there were any protobuf changes
- name: Check for protobuf changes
uses: technote-space/get-diff-action@v6
id: git-diff
with:
PATTERNS: |
idl/**/*.proto

# Install the `buf` CLI
- uses: bufbuild/buf-setup-action@v1
# Only execute if there were any protobuf changes
if: steps.git-diff.outputs.diff

# Lint your Protobuf sources
- name: Lint Protobufs
uses: bufbuild/buf-lint-action@v1
# Only execute if there were any protobuf changes
if: steps.git-diff.outputs.diff
with:
input: .

# Run breaking change detection for PRs
- name: Breaking Change Detection
uses: bufbuild/buf-breaking-action@v1
if: ${{ steps.git-diff.outputs.diff && github.event_name == 'pull_request' }}
with:
input: .
against: 'https://github.com/kevinmichaelchen/api-go-template.git#branch=main'

# Run breaking change detection for `main` branch
- name: Breaking Change Detection
uses: bufbuild/buf-breaking-action@v1
if: ${{ steps.git-diff.outputs.diff && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
input: .
against: 'https://github.com/kevinmichaelchen/api-go-template.git#branch=main,ref=HEAD~1'
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,18 @@ migrate-down:
migrate/migrate \
-path=/migrations/ \
-database postgres://postgres:postgres@localhost:5432/foo\?sslmode=disable \
down -all
down -all

.PHONY: test
test:
go test ./... --tags=integration

.PHONY: migrate-up-test
migrate-up-test:
docker run -v $(shell pwd)/schema:/migrations \
--rm \
--network host \
migrate/migrate \
-path=/migrations/ \
-database postgres://postgres:postgres@localhost:5432/footest\?sslmode=disable \
up
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.9"

services:
db:
image: postgis/postgis
image: postgres:14-alpine
environment:
- POSTGRES_DB=foo
- POSTGRES_USER=postgres
Expand Down
18 changes: 15 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/XSAM/otelsql v0.14.1
github.com/bufbuild/connect-go v0.1.0
github.com/friendsofgo/errors v0.9.2
github.com/golang-migrate/migrate/v4 v4.15.2
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/kat-co/vala v0.0.0-20170210184112-42e1d8b61f12
github.com/lib/pq v1.10.5
Expand All @@ -14,6 +15,7 @@ require (
github.com/sethvargo/go-envconfig v0.6.0
github.com/spf13/cobra v1.4.0
github.com/spf13/viper v1.9.0
github.com/stretchr/testify v1.7.1
github.com/volatiletech/null/v8 v8.1.2
github.com/volatiletech/randomize v0.0.1
github.com/volatiletech/sqlboiler/v4 v4.11.0
Expand All @@ -29,24 +31,31 @@ require (
go.uber.org/fx v1.17.1
go.uber.org/zap v1.21.0
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4
google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e
google.golang.org/grpc v1.46.0
google.golang.org/protobuf v1.28.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gofrs/uuid v3.2.0+incompatible // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-github/v39 v39.2.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
Expand All @@ -60,10 +69,13 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/dig v1.14.1 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/ini.v1 v1.63.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
Loading