2018-07-10 13:01:02 +03:00
|
|
|
# anchor refs to be used elsewhere
|
|
|
|
refs:
|
|
|
|
wait_for_postgres: &wait_for_postgres
|
|
|
|
run:
|
|
|
|
name: waiting for postgres to be ready
|
|
|
|
command: |
|
|
|
|
for i in `seq 1 60`;
|
|
|
|
do
|
|
|
|
nc -z localhost 5432 && echo Success && exit 0
|
|
|
|
echo -n .
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo Failed waiting for Postgres && exit 1
|
2018-10-05 15:37:19 +03:00
|
|
|
wait_for_hge: &wait_for_hge
|
|
|
|
run:
|
|
|
|
name: waiting for graphql-engine to be ready
|
|
|
|
command: |
|
|
|
|
for i in `seq 1 60`;
|
|
|
|
do
|
|
|
|
nc -z localhost 8080 && echo Success && exit 0
|
|
|
|
echo -n .
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo Failed waiting for graphql-engine && exit 1
|
|
|
|
|
2018-07-10 13:01:02 +03:00
|
|
|
filter_only_vtags: &filter_only_vtags
|
|
|
|
filters:
|
|
|
|
tags:
|
|
|
|
only: /^v.*/
|
|
|
|
filter_only_release_branches: &filter_only_release_branches
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only: /^release-v.*/
|
|
|
|
filter_only_dev_branches: &filter_only_dev_branches
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only: /^dev.*/
|
2018-07-11 11:37:34 +03:00
|
|
|
filter_only_vtags_dev_release_branches: &filter_only_vtags_dev_release_branches
|
2018-07-10 14:52:13 +03:00
|
|
|
filters:
|
2018-07-11 11:37:34 +03:00
|
|
|
tags:
|
|
|
|
only: /^v.*/
|
2018-07-10 14:52:13 +03:00
|
|
|
branches:
|
|
|
|
only: /^(dev|release).*/
|
2018-07-10 13:01:02 +03:00
|
|
|
filter_ignore_branches: &filter_ignore_branches
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
ignore: /.*/
|
2018-07-26 08:47:21 +03:00
|
|
|
filter_ignore_dev_release_branches: &filter_ignore_dev_release_branches
|
2018-07-10 13:01:02 +03:00
|
|
|
filters:
|
|
|
|
branches:
|
2018-07-26 08:47:21 +03:00
|
|
|
ignore: /^(dev|release).*/
|
2018-07-11 15:02:29 +03:00
|
|
|
|
2018-07-26 08:47:21 +03:00
|
|
|
setup_remote_docker: &setup_remote_docker
|
|
|
|
setup_remote_docker:
|
|
|
|
version: 17.09.0-ce
|
|
|
|
docker_layer_caching: true
|
|
|
|
|
|
|
|
# ref pg environment for testing
|
|
|
|
test_pg_env: &test_pg_env
|
|
|
|
environment:
|
|
|
|
POSTGRES_USER: gql_test
|
|
|
|
POSTGRES_DB: gql_test
|
|
|
|
|
|
|
|
# ref test server job
|
|
|
|
test_server: &test_server
|
|
|
|
working_directory: ~/graphql-engine
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- attach_workspace:
|
|
|
|
at: /build
|
|
|
|
- *wait_for_postgres
|
|
|
|
- run:
|
|
|
|
name: test the server
|
|
|
|
working_directory: ./server
|
|
|
|
command: |
|
|
|
|
DATABASE_URL="postgres://gql_test:@localhost:5432/gql_test" make ci-test
|
2018-07-10 13:01:02 +03:00
|
|
|
|
2018-09-18 09:21:57 +03:00
|
|
|
# ref pytest server job
|
|
|
|
pytest_server: &pytest_server
|
|
|
|
working_directory: ~/graphql-engine
|
|
|
|
steps:
|
|
|
|
- checkout
|
2018-10-05 15:37:19 +03:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- server-app-cache-{{ .Branch }}-{{ .Revision }}
|
2018-09-18 09:21:57 +03:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- server-deps-cache-{{ checksum "server/graphql-engine.cabal" }}-{{ checksum "server/stack.yaml" }}
|
|
|
|
- attach_workspace:
|
|
|
|
at: /build
|
|
|
|
- *wait_for_postgres
|
|
|
|
- run:
|
2018-10-05 15:37:19 +03:00
|
|
|
name: run the server in background
|
|
|
|
working_directory: ./server
|
2018-09-18 09:21:57 +03:00
|
|
|
environment:
|
|
|
|
HASURA_GRAPHQL_DATABASE_URL: postgres://gql_test:@localhost:5432/gql_test
|
2018-09-24 14:50:11 +03:00
|
|
|
EVENT_WEBHOOK_HEADER: MyEnvValue
|
2018-10-05 15:37:19 +03:00
|
|
|
background: true
|
|
|
|
command: |
|
|
|
|
/build/_server_output/graphql-engine serve
|
2018-09-18 09:21:57 +03:00
|
|
|
- run:
|
|
|
|
name: create test output dir
|
|
|
|
command: |
|
|
|
|
mkdir -p /build/_server_test_output/$PG_VERSION
|
2018-10-05 15:37:19 +03:00
|
|
|
- *wait_for_hge
|
2018-09-18 09:21:57 +03:00
|
|
|
- run:
|
|
|
|
name: pytest the server
|
|
|
|
working_directory: ./server/tests-py
|
|
|
|
environment:
|
|
|
|
DATABASE_URL: postgres://gql_test:@localhost:5432/gql_test
|
|
|
|
HGE_URL: http://localhost:8080
|
|
|
|
command: |
|
|
|
|
pip3 install -r requirements.txt
|
|
|
|
pytest -vv --hge-url="$HGE_URL" --pg-url="$DATABASE_URL"
|
2018-10-05 15:37:19 +03:00
|
|
|
- run:
|
|
|
|
name: stop the server and generate coverage report
|
|
|
|
working_directory: ./server
|
|
|
|
command: |
|
|
|
|
kill -2 $(ps -e | grep graphql-engine | awk '{print $1}')
|
|
|
|
stack --system-ghc hpc report graphql-engine.tix --destdir /build/_server_test_output/$PG_VERSION
|
2018-09-18 09:21:57 +03:00
|
|
|
- store_artifacts:
|
|
|
|
path: /build/_server_test_output
|
|
|
|
destination: server_test
|
2018-07-10 13:01:02 +03:00
|
|
|
|
2018-06-29 16:09:21 +03:00
|
|
|
version: 2
|
|
|
|
jobs:
|
2018-07-18 08:30:52 +03:00
|
|
|
# check if this should be built or not, fails if
|
|
|
|
# changes only contains files in .ciignore
|
|
|
|
check_build_worthiness:
|
|
|
|
docker:
|
2018-08-30 18:54:12 +03:00
|
|
|
- image: hasura/graphql-engine-cli-builder:v0.3
|
2018-07-18 08:30:52 +03:00
|
|
|
working_directory: ~/graphql-engine
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- run:
|
|
|
|
name: check build worthiness
|
|
|
|
command: .circleci/ciignore.sh
|
2018-07-26 08:47:21 +03:00
|
|
|
|
|
|
|
# build the server binary, and package into docker image
|
|
|
|
build_server:
|
2018-06-29 16:09:21 +03:00
|
|
|
docker:
|
2018-08-30 18:54:12 +03:00
|
|
|
- image: hasura/graphql-engine-server-builder:v0.3
|
2018-07-03 20:10:13 +03:00
|
|
|
working_directory: ~/graphql-engine
|
2018-06-29 16:09:21 +03:00
|
|
|
steps:
|
2018-07-10 13:01:02 +03:00
|
|
|
- checkout
|
2018-07-26 08:47:21 +03:00
|
|
|
- *setup_remote_docker
|
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- server-deps-cache-{{ checksum "server/graphql-engine.cabal" }}-{{ checksum "server/stack.yaml" }}
|
2018-07-10 13:01:02 +03:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- server-app-cache-{{ .Branch }}-{{ .Revision }}
|
|
|
|
- run:
|
2018-07-26 08:47:21 +03:00
|
|
|
name: Build the server
|
2018-07-10 13:01:02 +03:00
|
|
|
working_directory: ./server
|
|
|
|
command: |
|
2018-07-26 08:47:21 +03:00
|
|
|
# for PRs non-optimized build, else optimized build
|
|
|
|
if [[ "$CIRCLE_BRANCH" =~ ^(dev|release) || "$CIRCLE_TAG" =~ ^v ]]; then
|
|
|
|
echo "Branch starts with dev or release, or tagged commit starts with v. Optimized build"
|
|
|
|
make ci-binary
|
|
|
|
else
|
2018-10-05 15:37:19 +03:00
|
|
|
echo "Non-release branch, non-optimized build with coverage"
|
|
|
|
BUILD_FLAGS="--fast --coverage" make ci-binary
|
2018-07-26 08:47:21 +03:00
|
|
|
fi
|
2018-07-10 13:01:02 +03:00
|
|
|
make ci-image
|
|
|
|
make ci-save-image
|
|
|
|
- save_cache:
|
|
|
|
key: server-app-cache-{{ .Branch }}-{{ .Revision }}
|
|
|
|
paths:
|
2018-07-26 08:47:21 +03:00
|
|
|
- ./server/.stack-work
|
2018-07-10 13:01:02 +03:00
|
|
|
- save_cache:
|
2018-07-26 08:47:21 +03:00
|
|
|
key: server-deps-cache-{{ checksum "server/graphql-engine.cabal" }}-{{ checksum "server/stack.yaml" }}
|
2018-07-10 13:01:02 +03:00
|
|
|
paths:
|
|
|
|
- ~/.stack
|
|
|
|
- store_artifacts:
|
|
|
|
path: /build/_server_output
|
|
|
|
destination: server
|
|
|
|
- persist_to_workspace:
|
|
|
|
root: /build
|
|
|
|
paths:
|
|
|
|
- _server_output # binary is called graphql-engine
|
|
|
|
|
2018-07-26 08:47:21 +03:00
|
|
|
|
|
|
|
# job to execute when all server tests pass. later we can collect test
|
|
|
|
# reports and publish them etc.
|
|
|
|
all_server_tests_pass:
|
|
|
|
docker:
|
|
|
|
- image: alpine:edge
|
|
|
|
steps:
|
|
|
|
- run:
|
|
|
|
name: All server tests passed
|
2018-10-05 15:37:19 +03:00
|
|
|
command: echo 'all server tests passed!'
|
2018-07-26 08:47:21 +03:00
|
|
|
|
2018-09-18 09:21:57 +03:00
|
|
|
# pytest the server with postgres versions >= 9.5
|
|
|
|
pytest_server_pg_10.4:
|
|
|
|
<<: *pytest_server
|
|
|
|
environment:
|
|
|
|
PG_VERSION: "10_4"
|
|
|
|
docker:
|
|
|
|
- image: hasura/graphql-engine-server-builder:v0.3.2
|
|
|
|
- image: circleci/postgres:10.4-alpine
|
|
|
|
<<: *test_pg_env
|
|
|
|
|
|
|
|
pytest_server_pg_9.6:
|
|
|
|
<<: *pytest_server
|
|
|
|
environment:
|
|
|
|
PG_VERSION: "9_6"
|
|
|
|
docker:
|
|
|
|
- image: hasura/graphql-engine-server-builder:v0.3.2
|
|
|
|
- image: circleci/postgres:9.6-alpine
|
|
|
|
<<: *test_pg_env
|
|
|
|
|
|
|
|
pytest_server_pg_9.5:
|
|
|
|
<<: *pytest_server
|
|
|
|
environment:
|
|
|
|
PG_VERSION: "9_5"
|
|
|
|
docker:
|
|
|
|
- image: hasura/graphql-engine-server-builder:v0.3.2
|
|
|
|
- image: circleci/postgres:9.5-alpine
|
|
|
|
<<: *test_pg_env
|
|
|
|
|
2018-07-10 13:01:02 +03:00
|
|
|
# test and build cli
|
|
|
|
test_and_build_cli:
|
2018-06-29 16:09:21 +03:00
|
|
|
docker:
|
2018-08-30 18:54:12 +03:00
|
|
|
- image: hasura/graphql-engine-cli-builder:v0.3
|
2018-07-10 13:01:02 +03:00
|
|
|
- image: circleci/postgres:10-alpine
|
|
|
|
environment:
|
|
|
|
POSTGRES_USER: gql_test
|
|
|
|
POSTGRES_DB: gql_test
|
2018-06-29 16:09:21 +03:00
|
|
|
working_directory: /go/src/github.com/hasura/graphql-engine
|
|
|
|
steps:
|
|
|
|
- checkout
|
2018-07-10 13:01:02 +03:00
|
|
|
- attach_workspace:
|
|
|
|
at: /build
|
2018-06-29 16:09:21 +03:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- cli-vendor-{{ checksum "cli/Gopkg.toml" }}-{{ checksum "cli/Gopkg.lock" }}
|
|
|
|
- run:
|
2018-07-03 20:10:13 +03:00
|
|
|
name: get cli dependencies
|
2018-07-10 13:01:02 +03:00
|
|
|
working_directory: cli
|
2018-06-29 16:09:21 +03:00
|
|
|
command: make deps
|
|
|
|
- save_cache:
|
|
|
|
key: cli-vendor-{{ checksum "cli/Gopkg.toml" }}-{{ checksum "cli/Gopkg.lock" }}
|
|
|
|
paths:
|
|
|
|
- cli/vendor
|
2018-07-10 13:01:02 +03:00
|
|
|
- *wait_for_postgres
|
|
|
|
- run:
|
|
|
|
name: test cli
|
|
|
|
command: .circleci/test-cli.sh
|
2018-06-29 16:09:21 +03:00
|
|
|
- run:
|
|
|
|
name: build cli
|
2018-07-10 13:01:02 +03:00
|
|
|
working_directory: cli
|
2018-06-29 16:09:21 +03:00
|
|
|
command: |
|
|
|
|
make build
|
|
|
|
make compress
|
2018-07-10 13:01:02 +03:00
|
|
|
make ci-copy-binary
|
2018-06-29 16:09:21 +03:00
|
|
|
- store_artifacts:
|
2018-07-10 13:01:02 +03:00
|
|
|
path: /build/_cli_output
|
2018-07-03 20:10:13 +03:00
|
|
|
destination: cli
|
|
|
|
- persist_to_workspace:
|
2018-07-10 13:01:02 +03:00
|
|
|
root: /build
|
2018-07-03 20:10:13 +03:00
|
|
|
paths:
|
2018-07-10 13:01:02 +03:00
|
|
|
- _cli_output
|
|
|
|
|
|
|
|
# test and build console
|
|
|
|
test_and_build_console:
|
|
|
|
docker:
|
2018-08-30 18:54:12 +03:00
|
|
|
- image: hasura/graphql-engine-console-builder:v0.3
|
2018-09-08 20:31:14 +03:00
|
|
|
environment:
|
|
|
|
CYPRESS_KEY: 983be0db-0f19-40cc-bfc4-194fcacd85e1
|
2018-07-10 13:01:02 +03:00
|
|
|
- image: circleci/postgres:10-alpine
|
|
|
|
environment:
|
|
|
|
POSTGRES_USER: gql_test
|
|
|
|
POSTGRES_DB: gql_test
|
|
|
|
working_directory: ~/graphql-engine
|
2018-09-08 20:31:14 +03:00
|
|
|
parallelism: 4
|
2018-07-10 13:01:02 +03:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- attach_workspace:
|
|
|
|
at: /build
|
|
|
|
- restore_cache:
|
2018-07-11 15:02:29 +03:00
|
|
|
key:
|
2018-07-10 13:01:02 +03:00
|
|
|
console-npm-cache-{{ checksum "console/package.json" }}-{{ checksum "console/package-lock.json" }}
|
|
|
|
- run:
|
|
|
|
name: install dependencies
|
|
|
|
working_directory: console
|
|
|
|
command: make ci-deps
|
|
|
|
- save_cache:
|
2018-07-11 15:02:29 +03:00
|
|
|
key:
|
2018-07-10 13:01:02 +03:00
|
|
|
console-npm-cache-{{ checksum "console/package.json" }}-{{ checksum "console/package-lock.json" }}
|
|
|
|
paths:
|
|
|
|
- console/node_modules
|
|
|
|
- ~/.npm
|
|
|
|
- ~/.cache
|
|
|
|
- *wait_for_postgres
|
2018-07-11 15:02:29 +03:00
|
|
|
- run:
|
|
|
|
name: test console
|
|
|
|
command: .circleci/test-console.sh
|
2018-07-10 13:01:02 +03:00
|
|
|
- run:
|
|
|
|
name: build console
|
|
|
|
working_directory: console
|
|
|
|
command: |
|
|
|
|
make build
|
|
|
|
make ci-copy-assets
|
|
|
|
- store_artifacts:
|
|
|
|
path: /build/_console_output
|
|
|
|
destination: console
|
|
|
|
- persist_to_workspace:
|
|
|
|
root: /build
|
|
|
|
paths:
|
|
|
|
- _console_output
|
|
|
|
|
|
|
|
deploy:
|
|
|
|
docker:
|
2018-08-30 18:54:12 +03:00
|
|
|
- image: hasura/graphql-engine-deployer:v0.3
|
2018-07-10 13:01:02 +03:00
|
|
|
working_directory: ~/graphql-engine
|
|
|
|
steps:
|
2018-07-26 08:47:21 +03:00
|
|
|
- *setup_remote_docker
|
2018-07-10 13:01:02 +03:00
|
|
|
- checkout
|
|
|
|
- attach_workspace:
|
|
|
|
at: /build
|
|
|
|
- run:
|
|
|
|
name: deploy
|
|
|
|
command: .circleci/deploy.sh
|
|
|
|
|
2018-06-29 16:09:21 +03:00
|
|
|
workflows:
|
|
|
|
version: 2
|
2018-07-10 13:01:02 +03:00
|
|
|
build_and_test:
|
2018-06-29 16:09:21 +03:00
|
|
|
jobs:
|
2018-07-18 08:30:52 +03:00
|
|
|
- check_build_worthiness: *filter_only_vtags
|
2018-07-26 08:47:21 +03:00
|
|
|
- build_server:
|
2018-07-18 08:30:52 +03:00
|
|
|
<<: *filter_only_vtags
|
|
|
|
requires:
|
|
|
|
- check_build_worthiness
|
2018-09-18 09:21:57 +03:00
|
|
|
- pytest_server_pg_10.4:
|
|
|
|
<<: *filter_only_vtags
|
|
|
|
requires:
|
|
|
|
- build_server
|
|
|
|
- pytest_server_pg_9.6:
|
|
|
|
<<: *filter_only_vtags
|
|
|
|
requires:
|
|
|
|
- build_server
|
|
|
|
- pytest_server_pg_9.5:
|
|
|
|
<<: *filter_only_vtags
|
|
|
|
requires:
|
|
|
|
- build_server
|
2018-07-26 08:47:21 +03:00
|
|
|
- all_server_tests_pass:
|
|
|
|
<<: *filter_only_vtags
|
|
|
|
requires:
|
2018-09-18 09:21:57 +03:00
|
|
|
- pytest_server_pg_10.4
|
|
|
|
- pytest_server_pg_9.6
|
|
|
|
- pytest_server_pg_9.5
|
2018-07-11 15:02:29 +03:00
|
|
|
- test_and_build_cli:
|
2018-07-10 13:01:02 +03:00
|
|
|
<<: *filter_only_vtags
|
|
|
|
requires:
|
2018-07-26 08:47:21 +03:00
|
|
|
- build_server
|
2018-07-10 13:01:02 +03:00
|
|
|
- test_and_build_console:
|
|
|
|
<<: *filter_only_vtags
|
|
|
|
requires:
|
|
|
|
- test_and_build_cli
|
2018-07-11 15:02:29 +03:00
|
|
|
- deploy:
|
2018-07-11 11:37:34 +03:00
|
|
|
<<: *filter_only_vtags_dev_release_branches
|
2018-07-10 13:01:02 +03:00
|
|
|
requires:
|
2018-07-11 10:13:07 +03:00
|
|
|
- test_and_build_console
|
2018-07-26 08:47:21 +03:00
|
|
|
- all_server_tests_pass
|