This is a go sample repo. This was adapted from hydra.
This sample app will implement the following
- Basic web server handling /v1/details and /v1/status request
- This will communicate with Synq API
- DB Connection with flyway setup
- Tests with mocking
- CircleCI setup (with coveralls setup)
- Uses govendor to vendor/ management
This workspace works! You can check out the test by running
circleci build
If you want to run it locally, you need to setup the test database
createuser -U <postgres admin> -h localhost -P -d circleci
createdb -U circleci -h localhost gosample_test
cd sql/environments/test && flyway migrate
When you copy the workspace the first thing you should do is setup circleci
and coveralls
. This is fairly straightforward.
- Go to CircleCI Dashboard
Add Project
Setup Project
the workspace you are working onStarting Building
(assuming you select 2.0)- Go to
Settings
and then Status Badges and copy the badge to your README.md- If its a private workspace, you need to setup an
API Token
in API Permissions
- If its a private workspace, you need to setup an
- Go to Add Repos to add your repo
- Find your repo (you may need to hit the
Synq Repos
button on the upper right) - Click it "On"
- Go to Details and copy the
repo token
- Go to CircleCI's ENV settings and create the ENV VAR
COVERALLS_TOKEN
using the copied repo token. - Copy the Coveralls Badge and paste it into your README.md
- Once yuou have some tests, go to the coveralls Settings page and change the Coverage Threshold to minimum
75%
and Decrease threshold to5%
- Go to GitHub repo settings and branches
- Make
master
a protected branch - Check
Project Branch
,Require status checks to pass before merging
and make sureci/circleci
is required. Save your changes- Note, coveralls won't show until you've ran a successful build with it so you can come back to make that required as well
- Go to
.circleci/config.yml
and- replace
gosample_test
with the database you want - replace
gosample
with the name of your workspace
- replace
- Go to
sql/environments/test/flywayconf
- replace
gosample_test
with database you want
- replace
- Change the
sql/migrations/V000__Init.sql
with the table you want - And of course, change the code as needed, but this workspace starts at 100% code coverage so try to maintain high coverage!
- Golang (duh!)
- Postgres
- Govendor
go get -u github.com/kardianos/govendor
- CircleCi cli
- Coveralls