Skip to content

Vardoge/gosample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CircleCI Coverage Status

Go sample app to use for new repos

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

Setting up Cirlce CI

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 on
  • Starting 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

Setting up Coveralls

  • 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 to 5%

Setup your GitHub "protected" branch

  • Go to GitHub repo settings and branches
  • Make master a protected branch
  • Check Project Branch, Require status checks to pass before merging and make sure ci/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

Things to change before you start using it

  • Go to .circleci/config.yml and
    • replace gosample_test with the database you want
    • replace gosample with the name of your workspace
  • Go to sql/environments/test/flywayconf
    • replace gosample_test with database you want
  • 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!

Tools / Libraries Used

  • Golang (duh!)
  • Postgres
  • Govendor go get -u github.com/kardianos/govendor
  • CircleCi cli
  • Coveralls

About

Sample Go app, reference microservice

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published