Skip to content

Commit

Permalink
chore: improve ci config and process (#627)
Browse files Browse the repository at this point in the history
* chore: improve ci config and process

* fix: indent level in appveyor.yml matrix config

* fix: remove before_script in appveyor.yml

* fix: run lint and flow in circle ci builds

* fix: remove prefer builtins flag on resolve plugin

* fix: use | instead of > in circle.yml

* fix: add parallelism back to circle ci builds

* fix: use os.tmpdir() to resolve tmp dir path

* dx: log database driver in circle ci builds

* fix: tmpdir errors

* fix: use lux:db reset instead of manual manipulation of sqlite file

* fix: run database bootstrap commands from circle.yml

* chore: typo in database driver log in test setup

* refactor: resolve database driver from circle.yml

* fix: predefine db setup as function in circle.yml

* fix: indent level in circle.yml

* refactor: reorginize circle.yml

* dx: add deployment config to circle.yml

* fix: update appveyor.yml config

* deps: remove release dependency

* deps: update 3rd party type declarations

* fix: appveyor.yml error

* fix: add build command to appveyor.yml

* fix: set database password env var in appveyor.yml

* fix: add dropdb command to postgres setup in appveyor.yml

* fix: add --if-exists flag to dropdb in appveyor.yml

* fix: mysql db setup in appveyor.yml

* test: failing fs module tests

test: failing fs module tests

* fix: prevent test from trying to create root dir on windows
  • Loading branch information
zacharygolba authored Jan 14, 2017
1 parent d0795c3 commit 682d6fe
Show file tree
Hide file tree
Showing 34 changed files with 430 additions and 356 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
],
"newlines-between": "always"
}],
"import/extensions": 0,
"import/no-dynamic-require": 0,
"import/prefer-default-export": 0,
"flowtype/semi": 2,
Expand Down
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

[version]
0.37.4
^0.37.4
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
*.lcov
.nyc_output/
coverage/
dist/
.nyc_output/
*test-results.xml

# dependencies
node_modules/
Expand Down
39 changes: 33 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
image: Visual Studio 2015
build: off
platform: x64
services:
- mysql
- postgresql
environment:
nodejs_version: 6
NODE_ENV: test
CREATE_DATABASE: CREATE DATABASE lux_test;
DROP_DATABASE: DROP DATABASE IF EXISTS lux_test;
DATABASE_PASSWORD: Password12!
matrix:
- DATABASE_DRIVER: pg
DATABASE_USERNAME: postgres
- DATABASE_DRIVER: mysql2
DATABASE_USERNAME: root
- DATABASE_DRIVER: sqlite3
services:
- mysql
install:
- ps: C:\projects\lux\scripts\appveyor\install.ps1
- ps: Install-Product node $env:nodejs_version $env:platform
- npm install
- npm link
- ps: Set-Location C:\projects\lux\test\test-app
- npm install
- ps: Set-Location C:\projects\lux
before_test:
- ps: C:\projects\lux\scripts\appveyor\before-test.ps1
- |
SET PGUSER=postgres
SET PGPASSWORD=%DATABASE_PASSWORD%
PATH=C:\Program Files\PostgreSQL\9.5\bin\;%PATH%
dropdb --if-exists lux_test
createdb lux_test
- ps: |
$env:MYSQL_PWD="$env:DATABASE_PASSWORD"
$mysql="C:\Program Files\MySql\MySQL Server 5.7\bin\mysql"
Invoke-Expression "& '$mysql' -e '$env:DROP_DATABASE' -u root"
Invoke-Expression "& '$mysql' -e '$env:CREATE_DATABASE' -u root"
Remove-Item C:\projects\lux\test\test-app\db\* -Force -Include *.sqlite
Write-Host $null >> C:\projects\lux\test\test-app\db\lux_test_test.sqlite
- npm run clean
- npm run build
test_script:
- npm run flow
- npm run lint
- npm test
build: off
70 changes: 19 additions & 51 deletions bin/lux
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,25 @@ const { red, green } = require('chalk');

const { version: VERSION } = require('../package.json');

const PWD = process.cwd();
const PROJECT_REQUIRED = [
'test',
'build',
'serve',
'console',
'generate',
'destroy',
'db:seed',
'db:reset',
'db:migrate'
];

function writeOut(...lines) {
lines.forEach(line => {
process.stdout.write(`${line}\n`);
});
}

function writeErr(...lines) {
lines.forEach(line => {
process.stderr.write(`${line}\n`);
});
}

function inLuxProject() {
if (PWD.indexOf(path.join('lux', 'test', 'test-app')) >= 0) {
const cwd = process.cwd();

if (cwd.indexOf(path.join('lux', 'test', 'test-app')) >= 0) {
return true;
}

try {
const { dependencies } = require(path.join(PWD, 'package.json'));

return Reflect.has(dependencies, 'lux-framework');
return Boolean(require(path.join(cwd, 'package.json'))['lux-framework']);
} catch (err) {
return false;
}
}

function commandNotFound(cmd) {
writeOut(
`${EOL} ${red(cmd)} is not a valid command${EOL}\n`,
` Use ${green('lux --help')} for a full list of commands${EOL}`
// eslint-disable-next-line no-console
console.log(
`${EOL} ${red(cmd)} is not a valid command.${EOL.repeat(2)}`,
` Use ${green('lux --help')} for a full list of commands.${EOL}`
);
}

Expand All @@ -65,35 +41,27 @@ function setEnvVar(key, val, def) {
}

function exec(cmd, ...args) {
let handler;

if (PROJECT_REQUIRED.indexOf(cmd) >= 0 && !inLuxProject()) {
return Promise.reject(
'Error: Directory does not contain a valid Lux application.'
);
}
const handler = require('../dist')[cmd];
const needsProject = new RegExp(
'^(?:db:.+|test|build|serve|console|generate|destroy)$'
);

try {
handler = require(path.join(
PWD,
'node_modules',
'lux-framework',
'dist',
cmd
))[cmd];
} catch (err) {
handler = require(path.join(__dirname, '..', 'dist', cmd))[cmd];
if (needsProject.test(cmd) && !inLuxProject()) {
return Promise.reject(new Error(
'Directory does not contain a valid Lux application.'
));
}

return Reflect.apply(handler, null, args);
return handler(...args);
}

function exit(code) {
process.exit(typeof code === 'number' ? code : 0);
}

function rescue(err) {
writeErr(err.stack);
// eslint-disable-next-line
console.error(err.stack);
exit(1);
}

Expand Down
71 changes: 64 additions & 7 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,74 @@
test:
override:
- bash -e scripts/circle/before-script.sh:
parallel: true
- npm test && npm run test:codecov:
parallel: true
machine:
node:
version: 6
environment:
NODE_ENV: test
DROP_DATABASE: DROP DATABASE IF EXISTS lux_test;
CREATE_DATABASE: CREATE DATABASE lux_test;
DATABASE_USERNAME: ubuntu
database:
override:
- psql -c "$DROP_DATABASE" -U postgres
- psql -c "$CREATE_DATABASE" -U postgres
- mysql -e "$DROP_DATABASE"
- mysql -e "$CREATE_DATABASE"
dependencies:
pre:
- |
cd ../
if [ -d watchman ]; then
cd watchman
sudo make install
else
git clone https://github.com/facebook/watchman.git
cd watchman
git checkout v4.7.0
./autogen.sh
./configure
make
sudo make install
fi
cd ../lux
override:
- bash -e scripts/circle/install.sh
- npm install
- npm link
post:
- |
cd test/test-app
npm install
cd ../../
cache_directories:
- /home/ubuntu/watchman
compile:
pre:
- npm run clean
override:
- npm run build
test:
pre:
- case $CIRCLE_NODE_INDEX in 0) export DATABASE_DRIVER="pg" ;; 1) export DATABASE_DRIVER="mysql2" ;; 2) export DATABASE_DRIVER="sqlite3" ;; esac:
parallel: true
override:
- npm run flow:
parallel: true
- npm run lint:
parallel: true
- npm test -- -R mocha-junit-reporter:
parallel: true
environment:
MOCHA_FILE: $CIRCLE_TEST_REPORTS/junit/test-results.xml
post:
- npm run codecov:
parallel: true
deployment:
release:
tag: /^(?:v\d.\d.\d)$/
commands:
- npm run clean
- npm run build
- rm -rf ~/.npmrc && touch ~/.npmrc
- echo //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN >> ~/.npmrc
- npm publish
4 changes: 2 additions & 2 deletions flow-typed/npm/ansi-regex_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 51d72f02b42fb5856f5027bc57785f68
// flow-typed version: <<STUB>>/ansi-regex_v2.0.0/flow_v0.37.4
// flow-typed signature: 9b3aecebef31bed240b9f09d539603dc
// flow-typed version: <<STUB>>/ansi-regex_v2.1.1/flow_v0.37.4

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/babel-plugin-istanbul_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 5cc218c4d830cb34beb520dcd4da50ef
// flow-typed version: <<STUB>>/babel-plugin-istanbul_v3.0.0/flow_v0.37.4
// flow-typed signature: b5285f464d367e850dd916f9ae452562
// flow-typed version: <<STUB>>/babel-plugin-istanbul_v3.1.2/flow_v0.37.4

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/eslint-config-airbnb-base_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 59ad9a8f24a0677df47d8e8a86aa5b1e
// flow-typed version: <<STUB>>/eslint-config-airbnb-base_v11.0.0/flow_v0.37.4
// flow-typed signature: 4135f954a32de9c94dae9aca777deca4
// flow-typed version: <<STUB>>/eslint-config-airbnb-base_v11.0.1/flow_v0.37.4

/**
* This is an autogenerated libdef stub for:
Expand Down
11 changes: 9 additions & 2 deletions flow-typed/npm/eslint_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 502a8fda1ab0385e20354b5cbe96c473
// flow-typed version: <<STUB>>/eslint_v3.12.1/flow_v0.37.4
// flow-typed signature: 0214478b11475749d03c1a26b4fc24c9
// flow-typed version: <<STUB>>/eslint_v3.13.1/flow_v0.37.4

/**
* This is an autogenerated libdef stub for:
Expand Down Expand Up @@ -1018,6 +1018,10 @@ declare module 'eslint/lib/rules/prefer-const' {
declare module.exports: any;
}

declare module 'eslint/lib/rules/prefer-destructuring' {
declare module.exports: any;
}

declare module 'eslint/lib/rules/prefer-numeric-literals' {
declare module.exports: any;
}
Expand Down Expand Up @@ -1986,6 +1990,9 @@ declare module 'eslint/lib/rules/prefer-arrow-callback.js' {
declare module 'eslint/lib/rules/prefer-const.js' {
declare module.exports: $Exports<'eslint/lib/rules/prefer-const'>;
}
declare module 'eslint/lib/rules/prefer-destructuring.js' {
declare module.exports: $Exports<'eslint/lib/rules/prefer-destructuring'>;
}
declare module 'eslint/lib/rules/prefer-numeric-literals.js' {
declare module.exports: $Exports<'eslint/lib/rules/prefer-numeric-literals'>;
}
Expand Down
59 changes: 59 additions & 0 deletions flow-typed/npm/mocha-junit-reporter_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// flow-typed signature: fb594485a8922c0c9f7af828ca88909b
// flow-typed version: <<STUB>>/mocha-junit-reporter_v1.13.0/flow_v0.37.4

/**
* This is an autogenerated libdef stub for:
*
* 'mocha-junit-reporter'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/

declare module 'mocha-junit-reporter' {
declare module.exports: any;
}

/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'mocha-junit-reporter/test/helpers/mock-runner' {
declare module.exports: any;
}

declare module 'mocha-junit-reporter/test/helpers/mock-test' {
declare module.exports: any;
}

declare module 'mocha-junit-reporter/test/mocha-junit-reporter-spec' {
declare module.exports: any;
}

declare module 'mocha-junit-reporter/test/mock-results' {
declare module.exports: any;
}

// Filename aliases
declare module 'mocha-junit-reporter/index' {
declare module.exports: $Exports<'mocha-junit-reporter'>;
}
declare module 'mocha-junit-reporter/index.js' {
declare module.exports: $Exports<'mocha-junit-reporter'>;
}
declare module 'mocha-junit-reporter/test/helpers/mock-runner.js' {
declare module.exports: $Exports<'mocha-junit-reporter/test/helpers/mock-runner'>;
}
declare module 'mocha-junit-reporter/test/helpers/mock-test.js' {
declare module.exports: $Exports<'mocha-junit-reporter/test/helpers/mock-test'>;
}
declare module 'mocha-junit-reporter/test/mocha-junit-reporter-spec.js' {
declare module.exports: $Exports<'mocha-junit-reporter/test/mocha-junit-reporter-spec'>;
}
declare module 'mocha-junit-reporter/test/mock-results.js' {
declare module.exports: $Exports<'mocha-junit-reporter/test/mock-results'>;
}
4 changes: 2 additions & 2 deletions flow-typed/npm/ora_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: d84ef127f35065e0ef87b961704566b7
// flow-typed version: <<STUB>>/ora_v0.4.0/flow_v0.37.4
// flow-typed signature: 9beb90fa1e742c051ba8c0706cf0190a
// flow-typed version: <<STUB>>/ora_v0.4.1/flow_v0.37.4

/**
* This is an autogenerated libdef stub for:
Expand Down
Loading

0 comments on commit 682d6fe

Please sign in to comment.