Skip to content
This repository was archived by the owner on Oct 28, 2023. It is now read-only.

Commit 930f876

Browse files
committed
Initialize CircleCI config and db-migrate #8 #9
Incomplete config for CircleCI Added database configuration for db-migrate Added sample migration Missing implementation to hide user database credentials in hidden.js
1 parent bf5f3e6 commit 930f876

File tree

7 files changed

+516
-34
lines changed

7 files changed

+516
-34
lines changed

.circleci/config.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
# specify the version you desire here
10+
- image: circleci/node:10-browsers
11+
12+
- image: circleci/mysql:5.7.23
13+
environment:
14+
- MYSQL_USER: dbuser
15+
- MYSQL_PASSWORD: very-secret
16+
17+
working_directory: ~/repo
18+
19+
steps:
20+
- checkout
21+
22+
# Download and cache dependencies
23+
- restore_cache:
24+
keys:
25+
- v1-dependencies-{{ checksum "package.json" }}
26+
# fallback to using the latest cache if no exact match is found
27+
28+
- run: npm install
29+
30+
- save_cache:
31+
paths:
32+
- node_modules
33+
key: v1-dependencies-{{ checksum "package.json" }}
34+
35+
- run:
36+
name: setup database
37+
command: npm run migrate db:create anansi_db && npm run migrate up
38+
39+
- run:
40+
name: test
41+
command: npm test
42+
43+
- run:
44+
name: coverage
45+
command: npm run coverage
46+
47+
- run:
48+
name: lint
49+
command: npm run lint
50+
51+
- store_artifacts: # TODO
52+
path: test-results.xml
53+
prefix: tests
54+
- store_artifacts: # TODO
55+
path: coverage
56+
prefix: coverage
57+
- store_test_results: # TODO
58+
path: test-results.xml

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
node_modules/
2-
config.js
2+
hidden.js

config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var config = {
2+
db: {
3+
host: '127.0.0.1',
4+
user: 'dbuser',
5+
password: 'very-secret',
6+
db: 'anansi_db'
7+
}
8+
};
9+
10+
// TODO: import hidden.js and extract credentials
11+
module.exports = config;

database.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"defaultEnv": "dev",
3+
"dev": {
4+
"driver": "mysql",
5+
"host": "localhost",
6+
"user": "dbuser",
7+
"password": "very-secret",
8+
"database": "anansi_db"
9+
},
10+
"test": {
11+
"driver": "mysql",
12+
"host": "localhost",
13+
"user": "root",
14+
"password": "",
15+
"database": "anansi_db"
16+
}
17+
}

migrations/20180922063557-init-db.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
3+
var dbm;
4+
var type;
5+
var seed;
6+
7+
/**
8+
* We receive the dbmigrate dependency from dbmigrate initially.
9+
* This enables us to not have to rely on NODE_PATH.
10+
*/
11+
exports.setup = function (options, seedLink) {
12+
dbm = options.dbmigrate;
13+
type = dbm.dataType;
14+
seed = seedLink;
15+
};
16+
17+
exports.up = function (db) {
18+
return db.createTable('test',
19+
{
20+
id: { type: 'int', primaryKey: true },
21+
name: 'string'
22+
}
23+
);
24+
};
25+
26+
exports.down = function (db) {
27+
return db.dropTable('test');
28+
};
29+
30+
exports._meta = {
31+
'version': 1
32+
};

0 commit comments

Comments
 (0)