mirror of
https://github.com/amitbet/vncproxy.git
synced 2025-04-27 10:50:47 +00:00
add circleCI config
This commit is contained in:
parent
82e1549c4f
commit
fa416220ea
73
.circleci/config.yml
Normal file
73
.circleci/config.yml
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user