Skip to content

Commit

Permalink
feat: Check if cluster cancelled to determine success or failure (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
weixu365 authored May 31, 2023
1 parent adfa92c commit efe6868
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

19 changes: 12 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()

Expand All @@ -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`))
});
Expand Down

0 comments on commit efe6868

Please sign in to comment.