graphql-engine/.circleci/config.yml
Shahidh K Muhammed 183cbb169b only deploy dev|release branches (#76)
* remove special characters from version string
2018-07-10 11:52:13 +00:00

208 lines
5.4 KiB
YAML

# 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
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.*/
filter_only_dev_release_branches: &filter_only_dev_release_branches
filters:
branches:
only: /^(dev|release).*/
filter_ignore_branches: &filter_ignore_branches
filters:
branches:
ignore: /.*/
filter_ignore_release_branches: &filter_ignore_release_branches
filters:
branches:
ignore: /^release-v.*/
version: 2
jobs:
# test build the server binary
test_and_build_server:
docker:
- image: hasura/graphql-engine-server-builder:v0.2
- image: circleci/postgres:10-alpine
environment:
POSTGRES_USER: gql_test
POSTGRES_DB: gql_test
working_directory: ~/graphql-engine
steps:
- checkout
- setup_remote_docker:
version: 17.09.0-ce
docker_layer_caching: true
- restore_cache:
keys:
- server-app-cache-{{ .Branch }}-{{ .Revision }}
- server-deps-cache-v1
- *wait_for_postgres
- run:
name: test and build server binary
working_directory: ./server
command: |
# TODO: make test
make ci-binary
make ci-image
make ci-save-image
- save_cache:
key: server-app-cache-{{ .Branch }}-{{ .Revision }}
paths:
- server/.stack-work
- save_cache:
key: server-deps-cache-v1
paths:
- ~/.stack
- store_artifacts:
path: /build/_server_output
destination: server
- persist_to_workspace:
root: /build
paths:
- _server_output # binary is called graphql-engine
# test and build cli
test_and_build_cli:
docker:
- image: hasura/graphql-engine-cli-builder:v0.2
- image: circleci/postgres:10-alpine
environment:
POSTGRES_USER: gql_test
POSTGRES_DB: gql_test
working_directory: /go/src/github.com/hasura/graphql-engine
steps:
- checkout
- attach_workspace:
at: /build
- restore_cache:
keys:
- cli-vendor-{{ checksum "cli/Gopkg.toml" }}-{{ checksum "cli/Gopkg.lock" }}
- run:
name: get cli dependencies
working_directory: cli
command: make deps
- save_cache:
key: cli-vendor-{{ checksum "cli/Gopkg.toml" }}-{{ checksum "cli/Gopkg.lock" }}
paths:
- cli/vendor
- *wait_for_postgres
- run:
name: test cli
command: .circleci/test-cli.sh
- run:
name: build cli
working_directory: cli
command: |
make build
make compress
make ci-copy-binary
- store_artifacts:
path: /build/_cli_output
destination: cli
- persist_to_workspace:
root: /build
paths:
- _cli_output
# test and build console
test_and_build_console:
docker:
- image: hasura/graphql-engine-console-builder:v0.2
- image: circleci/postgres:10-alpine
environment:
POSTGRES_USER: gql_test
POSTGRES_DB: gql_test
working_directory: ~/graphql-engine
steps:
- checkout
- attach_workspace:
at: /build
- restore_cache:
key:
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:
key:
console-npm-cache-{{ checksum "console/package.json" }}-{{ checksum "console/package-lock.json" }}
paths:
- console/node_modules
- ~/.npm
- ~/.cache
- *wait_for_postgres
# ignore console test for now
# - run:
# name: test console
# command: .circleci/test-console.sh
- 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:
- image: hasura/graphql-engine-deployer:v0.2
working_directory: ~/graphql-engine
steps:
- setup_remote_docker:
version: 17.09.0-ce
docker_layer_caching: true
- checkout
- attach_workspace:
at: /build
- run:
name: deploy
command: .circleci/deploy.sh
workflows:
version: 2
build_and_test:
jobs:
- test_and_build_server: *filter_only_vtags
- test_and_build_cli:
<<: *filter_only_vtags
requires:
- test_and_build_server
- test_and_build_console:
<<: *filter_only_vtags
requires:
- test_and_build_server
- test_and_build_cli
- deploy:
<<: *filter_only_vtags
<<: *filter_only_dev_release_branches
requires:
- test_and_build_console