Skip to content

Commit

Permalink
Add Actions CI (#908)
Browse files Browse the repository at this point in the history
# Add Actions CI

* Run Actions CI in addition to Travis
* Make database user name for tests dynamic

In order to that, I replaced config.json with config.js.
If `DATABASE_USER_TEST` is set in the environment, it is used, otherwise
we default to the user running the process, which is the default for
MacOS setups.

* Make test its own step

Instead of doing, install, build and test in one step, I prefer having
a dedicated test step.

* Try building multiple node versions
This should help us detect issues with the next node version early on.
  • Loading branch information
Dennis Sivia authored Aug 21, 2019
1 parent 32db8ec commit d615bb7
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 28 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: GitHub CI

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
env:
NODE_ENV: test
- name: npm install, build
env:
NODE_ENV: test
DB_USERNAME_TEST: "postgres"
run: |
npm install
./node_modules/.bin/sequelize db:create --env test
./node_modules/.bin/sequelize db:migrate --env test
- name: npm test
env:
NODE_ENV: test
DB_USERNAME_TEST: "postgres"
run: |
npm test
services:
postgresql:
image: postgres
ports:
- 5432:5432
redis:
image: redis
ports:
- 6379:6379
8 changes: 4 additions & 4 deletions .sequelizerc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require('path');

module.exports = {
"config": path.resolve('./db/config.json'),
"models-path": path.resolve('./lib/models'),
"seeders-path": path.resolve('./db/seeders'),
"migrations-path": path.resolve('./db/migrations')
"config": path.resolve('db', 'config.js'),
"models-path": path.resolve('db', 'models'),
"seeders-path": path.resolve('db', 'seeders'),
"migrations-path": path.resolve('db', 'migrations')
};
27 changes: 27 additions & 0 deletions db/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require('dotenv').config();
const os = require('os');

module.exports = {
development: {
database: 'slack-dev',
host: '127.0.0.1',
dialect: 'postgres',
operatorsAliases: false,
},
test: {
database: 'slack-test',
host: '127.0.0.1',
dialect: 'postgres',
operatorsAliases: false,
username: process.env.DB_USERNAME_TEST || os.userInfo().username,
},
production: {
use_env_variable: 'DATABASE_URL',
disable_sql_logging: true,
operatorsAliases: false,
ssl: true,
dialectOptions: {
ssl: true,
},
},
};
23 changes: 0 additions & 23 deletions db/config.json

This file was deleted.

2 changes: 1 addition & 1 deletion lib/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Sequelize = require('sequelize');

const basename = path.basename(module.filename);
const env = process.env.NODE_ENV || 'development';
const config = require('../../db/config.json')[env];
const config = require('../../db/config.js')[env];

const logger = require('../logger');

Expand Down

0 comments on commit d615bb7

Please sign in to comment.