-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using workflows and greenkeeper-lockfile
- Loading branch information
Showing
2 changed files
with
111 additions
and
53 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,112 @@ | ||
version: 2 | ||
|
||
job_common: &job_common | ||
docker: | ||
- image: circleci/node:6 | ||
|
||
save: &save | ||
save_cache: | ||
key: code-{{ .Revision }} | ||
paths: | ||
- . | ||
- ".git" | ||
|
||
restore: &restore | ||
restore_cache: | ||
key: code-{{ .Revision }} | ||
|
||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/node:6 | ||
environment: | ||
- NODE_ENV=test | ||
- DATABASE_URL_POSTGRES=postgres://ubuntu@localhost:5432/circle_test | ||
- DATABASE_URL_COCKROACH=postgresql://root@localhost:26257/circle_test | ||
- image: postgres:10.4-alpine | ||
environment: | ||
- POSTGRES_USER=ubuntu | ||
- POSTGRES_DB=circle_test | ||
- image: cockroachdb/cockroach:v1.1.8 | ||
command: ['start', '--insecure', '--host=localhost'] | ||
steps: | ||
- checkout | ||
- run: | ||
name: update-npm | ||
command: | | ||
mkdir ~/.npm-global | ||
npm config set prefix '~/.npm-global' | ||
echo 'export NPM_CONFIG_PREFIX=~/.npm-global' >> $BASH_ENV | ||
echo 'export PATH=~/.npm-global/bin:$PATH' >> $BASH_ENV | ||
source $BASH_ENV | ||
npm install -g [email protected] | ||
- restore_cache: | ||
key: dependency-cache-{{ checksum "package.json" }} | ||
- run: | ||
name: install-npm | ||
command: npm ci | ||
- save_cache: | ||
key: dependency-cache-{{ checksum "package.json" }} | ||
paths: | ||
- ./node_modules | ||
- run: | ||
name: lint | ||
command: npm run lint | ||
- run: | ||
name: create-cockroach-db | ||
command: node -e '(new require("pg").Pool({connectionString:process.env.DATABASE_URL_COCKROACH})).query("CREATE DATABASE circle_test").then(function(){process.exit(0)})' | ||
- run: | ||
name: test | ||
command: npm test | ||
install: | ||
<<: *job_common | ||
steps: | ||
- checkout | ||
- run: | ||
name: update-npm | ||
command: | | ||
mkdir ~/.npm-global | ||
npm config set prefix '~/.npm-global' | ||
echo 'export NPM_CONFIG_PREFIX=~/.npm-global' >> $BASH_ENV | ||
echo 'export PATH=~/.npm-global/bin:$PATH' >> $BASH_ENV | ||
source $BASH_ENV | ||
npm install -g [email protected] | ||
- restore_cache: | ||
key: dependency-cache-{{ checksum "package.json" }} | ||
- run: | ||
name: install-greenkeeper | ||
command: | | ||
npm install -g greenkeeper-lockfile | ||
greenkeeper-lockfile-update | ||
- run: npm i | ||
- save_cache: | ||
key: dependency-cache-{{ checksum "package.json" }} | ||
paths: | ||
- ./node_modules | ||
- <<: *save | ||
lint: | ||
<<: *job_common | ||
steps: | ||
- <<: *restore | ||
- run: npm run lint | ||
test: | ||
<<: *job_common | ||
steps: | ||
- <<: *restore | ||
- run: npm test | ||
test-pg: | ||
<<: *job_common | ||
docker: | ||
- image: postgres:10.4-alpine | ||
environment: | ||
- POSTGRES_USER=ubuntu | ||
- POSTGRES_DB=circle_test | ||
steps: | ||
- <<: *restore | ||
- run: | ||
name: test | ||
environment: | ||
- DATABASE_URL=postgres://ubuntu@localhost:5432/circle_test | ||
command: npm run migrate up -- -m test/migrations && npm run migrate down 0 -- -m test/migrations --timestamps | ||
test-cocroach: | ||
<<: *job_common | ||
docker: | ||
- image: cockroachdb/cockroach:v1.1.8 | ||
command: ['start', '--insecure', '--host=localhost'] | ||
steps: | ||
- <<: *restore | ||
- run: | ||
name: create-cockroach-db | ||
command: node -e '(new require("pg").Pool({connectionString:process.env.DATABASE_URL_COCKROACH})).query("CREATE DATABASE circle_test").then(function(){process.exit(0)})' | ||
- run: | ||
name: test | ||
environment: | ||
- DATABASE_URL=postgresql://root@localhost:26257/circle_test | ||
command: npm run migrate up -- -m test/cockroach -s '' --migrations-schema circle_test --no-lock && npm run migrate down 0 -- -m test/cockroach -s '' --migrations-schema circle_test --no-lock --timestamps | ||
- run: greenkeeper-lockfile-upload | ||
finish: | ||
<<: *job_common | ||
steps: | ||
- <<: *restore | ||
- run: greenkeeper-lockfile-upload | ||
|
||
workflows: | ||
version: 2 | ||
main_workflow: | ||
jobs: | ||
- install | ||
- lint: | ||
requires: | ||
- install | ||
- test: | ||
requires: | ||
- install | ||
- test-pg: | ||
requires: | ||
- install | ||
- test-cocroach: | ||
requires: | ||
- install | ||
- finish: | ||
requires: | ||
- test | ||
- test-pg | ||
- test-cocroach |
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