Last active
March 3, 2018 19:58
-
-
Save ralphpina/0b2a47034c1425415fd77b6b62c32c00 to your computer and use it in GitHub Desktop.
CircleCi 2 config file for Welnys
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
# Copied from their sample project | |
# https://github.com/CircleCI-Public/circleci-demo-go/blob/master/.circleci/config.yml | |
version: 2 | |
jobs: | |
build: | |
docker: | |
# CircleCI Go images available at: https://hub.docker.com/r/circleci/golang/ | |
- image: circleci/golang:1.8 | |
# CircleCI MySQL images available at: https://hub.docker.com/r/circleci/mysql/ | |
- image: circleci/mysql:5.7 | |
# env vars below from https://discuss.circleci.com/t/cannot-connect-to-mysql-using-default-credentials/13314/5 | |
environment: | |
- MYSQL_ALLOW_EMPTY_PASSWORD=true | |
- MYSQL_ROOT_HOST=% | |
- MYSQL_USER=ubuntu | |
- MYSQL_PASSWORD=ubuntu | |
working_directory: /go/src/github.com/welnys/api | |
environment: | |
TEST_RESULTS: /tmp/test-results | |
steps: | |
- run: | |
name: Install mysql-client | |
command: sudo apt install mysql-client | |
- checkout | |
- run: | |
name: Make dir for test results | |
command: mkdir -p $TEST_RESULTS | |
- restore_cache: | |
keys: | |
- v1-pkg-cache | |
# Get Go packages | |
- run: | |
name: Get Go packages | |
command: | | |
go get github.com/jstemmer/go-junit-report \ | |
&& go get -u google.golang.org/appengine \ | |
&& go get -u github.com/golang/dep/cmd/dep \ | |
&& dep ensure \ | |
&& go get ./... | |
# Google Cloud SDK. We need it to setup the environment with the commands below | |
# https://discuss.circleci.com/t/gcloud-permissions-error/2631/25 | |
- run: | |
name: Downloading Google Cloud SDK | |
command: | | |
curl -L -o google-cloud-sdk.zip https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.zip \ | |
&& unzip google-cloud-sdk.zip \ | |
&& rm google-cloud-sdk.zip \ | |
&& google-cloud-sdk/install.sh \ | |
--usage-reporting=false \ | |
--bash-completion=true \ | |
--path-update=true \ | |
--quiet | |
# Install Google Cloud SDK | |
- run: | |
name: Installing Google Cloud SDK | |
command: | | |
echo $GCLOUD_SERVICE_KEY | base64 --decode --ignore-garbage > ${HOME}/gcloud-service-key.json \ | |
&& sudo google-cloud-sdk/bin/gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json \ | |
&& sudo google-cloud-sdk/bin/gcloud config set project welnys-api \ | |
&& sudo google-cloud-sdk/bin/gcloud --quiet components install app-engine-python \ | |
&& sudo google-cloud-sdk/bin/gcloud --quiet components install app-engine-go | |
- run: | |
name: Waiting for MySQL to be ready | |
command: | | |
for i in `seq 1 10`; | |
do | |
nc -z localhost 3306 && echo Success && exit 0 | |
echo -n . | |
sleep 1 | |
done | |
echo Failed waiting for MySQL && exit 1 | |
- run: | |
name: Installing test database | |
command: mysql -h 127.0.0.1 -u ubuntu --password=ubuntu circle_test < welnys_test_db.sql | |
- run: | |
name: Run admin unit tests | |
command: | | |
cd admin && go test -v -cover | |
environment: | |
APPENGINE_DEV_APPSERVER: /go/src/github.com/welnys/api/google-cloud-sdk/bin/dev_appserver.py | |
- run: | |
name: Run auth unit tests | |
command: cd auth && go test -v -cover | |
environment: | |
APPENGINE_DEV_APPSERVER: /go/src/github.com/welnys/api/google-cloud-sdk/bin/dev_appserver.py | |
- run: | |
name: Run db unit tests | |
command: cd db && go test -v -cover | |
environment: | |
APPENGINE_DEV_APPSERVER: /go/src/github.com/welnys/api/google-cloud-sdk/bin/dev_appserver.py | |
- run: | |
name: Run main unit tests | |
command: cd main && go test -v -cover | |
environment: | |
APPENGINE_DEV_APPSERVER: /go/src/github.com/welnys/api/google-cloud-sdk/bin/dev_appserver.py | |
- run: | |
name: Run models unit tests | |
command: cd models && go test -v -cover | |
environment: | |
APPENGINE_DEV_APPSERVER: /go/src/github.com/welnys/api/google-cloud-sdk/bin/dev_appserver.py | |
- run: | |
name: Run payments unit tests | |
command: cd payments && go test -v -cover | |
environment: | |
APPENGINE_DEV_APPSERVER: /go/src/github.com/welnys/api/google-cloud-sdk/bin/dev_appserver.py | |
- run: | |
name: Run providers unit tests | |
command: cd providers && go test -v -cover | |
environment: | |
APPENGINE_DEV_APPSERVER: /go/src/github.com/welnys/api/google-cloud-sdk/bin/dev_appserver.py | |
- run: | |
name: Run scheduler unit tests | |
command: cd scheduler && go test -v -cover | |
environment: | |
APPENGINE_DEV_APPSERVER: /go/src/github.com/welnys/api/google-cloud-sdk/bin/dev_appserver.py | |
- run: | |
name: Run user unit tests | |
command: cd user && go test -v -cover | |
environment: | |
APPENGINE_DEV_APPSERVER: /go/src/github.com/welnys/api/google-cloud-sdk/bin/dev_appserver.py | |
- save_cache: | |
key: v1-pkg-cache | |
paths: | |
- "/go/pkg" | |
- store_artifacts: | |
path: /tmp/test-results | |
destination: raw-test-output | |
- store_test_results: | |
path: /tmp/test-results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment