Skip to content

Commit

Permalink
chore: use circleci for all builds
Browse files Browse the repository at this point in the history
drop travis-ci from the builds by using the matrix
functionality in circleci to run multiple node versions
plus refactor the way builds work to allow splitting
and joining builds together more easily
  • Loading branch information
imnotjames committed Jul 24, 2020
1 parent 9abab82 commit 453f402
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 412 deletions.
199 changes: 112 additions & 87 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,77 @@
# Javascript Node CircleCI 2.0 configuration file
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
version: 2
version: 2.1

orbs:
node: circleci/node@3.0.1
codecov: codecov/codecov@1.1.1

commands:
create-typeorm-config:
parameters:
only-databases:
type: string
default: ""
steps:
- when:
condition:
equal: [ << parameters.only-databases >>, "" ]
steps:
- run:
name: "Enabling Databases in ORM config: << parameters.only-databases >>"
command: cp ormconfig.circleci-common.json ./ormconfig.json
- unless:
condition:
equal: [ << parameters.only-databases >>, "" ]
steps:
- run:
name: "Enabling Databases in ORM config: << parameters.only-databases >>"
command: >
cat ormconfig.circleci-common.json \
| jq 'map(.skip = if (.name | IN($ARGS.positional[])) then false else true end)' --args << parameters.only-databases >> \
> ormconfig.json
- run:
name: Check ORMConfig
command: cat ormconfig.json

jobs:
common:
lint:
working_directory: ~/typeorm
docker:
- image: circleci/node:12
steps:
- checkout
- node/install-packages:
app-dir: ~/typeorm
include-branch-in-cache-key: false
- run: npm run lint

build:
working_directory: ~/typeorm
docker:
- image: circleci/node:12
steps:
- checkout
- node/install-packages:
app-dir: ~/typeorm
include-branch-in-cache-key: false
- run: npm run compile
- persist_to_workspace:
root: ~/typeorm
paths:
- build/

test:
parameters:
only-databases:
type: string
default: ""
node-version:
type: string
default: "10"
working_directory: ~/typeorm
docker:
- image: circleci/node:10.16.0
- image: circleci/node:<< parameters.node-version >>
- image: mysql:5.7.24
name: mysql
environment:
MYSQL_ROOT_PASSWORD: "admin"
MYSQL_DATABASE: "test"
Expand All @@ -16,99 +81,59 @@ jobs:
MYSQL_ROOT_PASSWORD: "admin"
MYSQL_DATABASE: "test"
- image: circleci/postgres:9.6.11-postgis
name: postgres
environment:
POSTGRES_USER: "test"
POSTGRES_PASSWORD: "test"
POSTGRES_DB: "test"
- image: cockroachdb/cockroach:latest
name: cockroachdb
command: start --insecure
- image: circleci/mongo:3.4.18
# - image: mcr.microsoft.com/mssql/server:2017-latest-ubuntu
# environment:
# SA_PASSWORD: "Admin12345"
# ACCEPT_EULA: "Y"
name: mongodb
- image: mcr.microsoft.com/mssql/server:2017-latest
name: mssql
environment:
SA_PASSWORD: "Admin123"
ACCEPT_EULA: "Y"

steps:
- checkout
- run: cp ormconfig.circleci-common.json ormconfig.json
- attach_workspace:
at: ~/typeorm
- create-typeorm-config:
only-databases: << parameters.only-databases >>
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: npm run lint
- run: npm test
- node/install-packages:
app-dir: ~/typeorm
include-branch-in-cache-key: false
- run: npx nyc npm run test-fast
- store_artifacts:
path: coverage
- codecov/upload

cockroachdb:
working_directory: ~/typeorm
docker:
- image: circleci/node:10.15.0
- image: cockroachdb/cockroach:latest
command: start --insecure
steps:
- checkout
- run: cp ormconfig.circleci-cockroach.json ormconfig.json
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: npm run lint
- run:
npm test
oracle:
working_directory: ~/typeorm
docker:
- image: circleci/node:10.16.0
- image: "store/oracle/database-enterprise:12.2.0.1-slim"
auth:
username: $DOCKER_USER
password: $DOCKER_PASSWORD
environment:
DB_SID: "sys"
SYS_PASSWORD: "ORCLCDB"
steps:
- run: if [ -z "$DOCKER_USER" ]; then echo "DOCKER_USER is unset"; circleci step halt; fi
- checkout
- run: sudo npm install -g npm@latest
- run: cp ormconfig.circleci-oracle.json ormconfig.json
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: wget https://download.oracle.com/otn_software/linux/instantclient/195000/instantclient-basiclite-linux.x64-19.5.0.0.0dbru.zip
- run: unzip instantclient-basiclite-linux.x64-19.5.0.0.0dbru.zip -d /tmp/oracle
- run: wget https://download.oracle.com/otn_software/linux/instantclient/195000/instantclient-sqlplus-linux.x64-19.5.0.0.0dbru.zip
- run: unzip instantclient-sqlplus-linux.x64-19.5.0.0.0dbru.zip -d /tmp/oracle
- run: echo "export LD_LIBRARY_PATH=/tmp/oracle/instantclient_19_5" >> $BASH_ENV
- run: sudo sh -c "echo /tmp/oracle/instantclient_19_5 > /etc/ld.so.conf.d/oracle-instantclient.conf";sudo ldconfig
- run: sh -c 'echo WHENEVER SQLERROR EXIT FAILURE > /tmp/user.sql; echo CREATE USER typeorm IDENTIFIED BY Passw0rd\; >> /tmp/user.sql; echo GRANT CONNECT TO typeorm\; >> /tmp/user.sql; echo GRANT UNLIMITED TABLESPACE TO typeorm\; >> /tmp/user.sql; echo exit >> /tmp/user.sql'
- run: sudo apt install libaio1
- run: until /tmp/oracle/instantclient_19_5/sqlplus -L -S sys/Oradoc_db1@//localhost:1521/orclpdb1.localdomain as sysdba @/tmp/user.sql ; do echo waiting for oracle; sleep 10; done;
- run: npm install oracledb --no-save
- run: npm run lint
- run: npm test
workflows:
version: 2
test:
jobs:
- common
- cockroachdb
# - oracle
- lint
- build
- test:
name: test-common-node<< matrix.node-version >>
requires:
- lint
- build
matrix:
parameters:
node-version:
- "10"
- "11"
- "12"
- "13"
- test:
name: test-cockroachdb-node12
requires:
- lint
- build
only-databases: "cockroachdb"
node-version: "12"
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

98 changes: 0 additions & 98 deletions ormconfig.circleci-cockroach.json

This file was deleted.

Loading

0 comments on commit 453f402

Please sign in to comment.