diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..67e661c --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,73 @@ +version: 2 # use CircleCI 2.0 +jobs: # basic units of work in a run + build: # runs not using Workflows must have a `build` job as entry point + docker: # run the steps with Docker + # CircleCI Go images available at: https://hub.docker.com/r/circleci/golang/ + - image: circleci/golang:1.12 + # CircleCI PostgreSQL images available at: https://hub.docker.com/r/circleci/postgres/ + - image: circleci/postgres:9.6-alpine + environment: # environment variables for primary container + POSTGRES_USER: circleci-demo-go + POSTGRES_DB: circle_test + + parallelism: 2 + + environment: # environment variables for the build itself + TEST_RESULTS: /tmp/test-results # path to where test results will be saved + + steps: # steps that comprise the `build` job + - checkout # check out source code to working directory + - run: mkdir -p $TEST_RESULTS # create the test results directory + + - restore_cache: # restores saved cache if no changes are detected since last run + keys: + - go-mod-v4-{{ checksum "go.sum" }} + + # Wait for Postgres to be ready before proceeding + - run: + name: Waiting for Postgres to be ready + command: dockerize -wait tcp://localhost:5432 -timeout 1m + + - run: + name: Run unit tests + environment: # environment variables for the database url and path to migration files + CONTACTS_DB_URL: "postgres://circleci-demo-go@localhost:5432/circle_test?sslmode=disable" + CONTACTS_DB_MIGRATIONS: /home/circleci/project/db/migrations + + # store the results of our tests in the $TEST_RESULTS directory + command: | + PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname) + gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES + + # - run: make # pull and build dependencies for the project + + # - save_cache: + # key: go-mod-v4-{{ checksum "go.sum" }} + # paths: + # - "/go/pkg/mod" + + # - run: + # name: Start service + # environment: + # CONTACTS_DB_URL: "postgres://circleci-demo-go@localhost:5432/circle_test?sslmode=disable" + # CONTACTS_DB_MIGRATIONS: /home/circleci/project/db/migrations + # command: ./workdir/contacts + # background: true # keep service running and proceed to next step + + # - run: + # name: Validate service is working + # command: | + # sleep 5 + # curl --retry 10 --retry-delay 1 -X POST --header "Content-Type: application/json" -d '{"email":"test@example.com","name":"Test User"}' http://localhost:8080/contacts + + # - store_artifacts: # upload test summary for display in Artifacts + # path: /tmp/test-results + # destination: raw-test-output + + # - store_test_results: # upload test results for display in Test Summary + # path: /tmp/test-results +workflows: + version: 2 + build-workflow: + jobs: + - build diff --git a/.gitignore b/.gitignore index cdf7bbf..bbeeda7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,16 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out - +debug +ffmpeg # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 .glide/ +.idea/ +workspace.xml +*.avi +*.mp4 +*.mov +*.idx_ example/client/client example/server/server example/proxy/proxy