diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 605ea07..35a36d6 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -16,7 +16,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: npm ci - - run: npm test + - run: make unit-test command-test # - run: make prune package release # env: # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index 63bcc1e..7b2f409 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,11 @@ docker-shell: unit-test: npx mocha test +command-test: + BATCH=1234 GIT_BRANCH=test BUILD_NUMBER=test node src/index.js \ + --setting-files samples/enrichment-pipeline.settings.yml \ + -f samples/enrichment-pipeline.yml \ + validate + integration-test: npx mocha integration-test - diff --git a/src/index.js b/src/index.js index ee782ce..c268ebf 100644 --- a/src/index.js +++ b/src/index.js @@ -4,7 +4,10 @@ const Config = require('./config') const EmrRunner = require('./emr_runner') const logger = require('./logger') -const getConfig = () => new Config(program.configFile, program.settingFiles) +const getConfig = () => { + const opts = program.opts(); + return new Config(opts.configFile, opts.settingFiles); +} process.on('unhandledRejection', error => { logger.error(error.stack) @@ -24,10 +27,12 @@ const program = new Command() program .command('validate') .description('Validate config files') - .action((cmd) => { + .action(() => { logger.info('Validate configs'); - logger.info(`- setting files ${program.settingFiles}`); - logger.info(`- config file ${program.configFile}`); + const opts = program.opts(); + logger.info(opts); + logger.info(`- setting files ${opts.settingFiles}`); + logger.info(`- config file ${opts.configFile}`); getConfig().load() @@ -37,21 +42,21 @@ program program .command('resources') .description('Setup resources stack for running EMR steps') - .action((cmd) => { + .action(() => { return new EmrRunner(getConfig().load()).deployResources() }); program .command('delete-resources') .description('Delete resources stack') - .action((cmd) => { + .action(() => { return new EmrRunner(getConfig().load()).deleteResources() }); program .command('start-cluster') .description('Start a new EMR cluster. You need to manually terminate the cluster.') - .action((cmd) => { + .action(() => { return new EmrRunner(getConfig().load()).startCluster() .then(cluster_id => logger.info(`Cluster ${cluster_id} started`)) });