-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(scripts): add commands and subcommands to scripts
- Loading branch information
Showing
20 changed files
with
110 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,53 @@ | ||
import { $ } from 'zx'; | ||
|
||
import { DOCKER_COMPOSE_PATH, PROJECT_NAME } from './utils/constants.mjs'; | ||
import { parseInput, serializeParams } from './utils/params.mjs'; | ||
|
||
const main = async () => { | ||
const { params } = parseInput(); | ||
import { serializeParams } from './utils/params.mjs'; | ||
|
||
const getArgs = (scriptParams) => { | ||
const composeArgs = [`-p`, PROJECT_NAME, `-f`, DOCKER_COMPOSE_PATH]; | ||
const runArgs = []; | ||
|
||
if (params['watchAll']) { | ||
if (scriptParams['watchAll']) { | ||
runArgs.push('-it'); | ||
} | ||
|
||
await $`docker compose ${composeArgs} run ${runArgs} tests ${serializeParams(params)}`.stdio( | ||
return { | ||
composeArgs, | ||
runArgs, | ||
}; | ||
}; | ||
|
||
const runTests = ({ composeArgs, runArgs, scriptParams }) => | ||
$`docker compose ${composeArgs} run ${runArgs} tests ${serializeParams(scriptParams)}`.stdio( | ||
'inherit', | ||
'inherit', | ||
'inherit', | ||
); | ||
|
||
const main = async (scriptParams) => { | ||
await functional(scriptParams); | ||
await integration(scriptParams); | ||
}; | ||
|
||
export const functional = async (scriptParams) => { | ||
await runTests({ | ||
...getArgs(scriptParams), | ||
scriptParams: { | ||
...scriptParams, | ||
selectProjects: 'functional', | ||
}, | ||
}); | ||
}; | ||
|
||
export const integration = async (scriptParams) => { | ||
await runTests({ | ||
...getArgs(scriptParams), | ||
scriptParams: { | ||
...scriptParams, | ||
selectProjects: 'integration', | ||
runInBand: true, | ||
}, | ||
}); | ||
}; | ||
|
||
await main(); | ||
export default main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,3 @@ | ||
import { argv } from 'zx'; | ||
|
||
export const serializeParams = (params) => { | ||
return Object.entries(params).map(([key, value]) => `--${key}=${value}`); | ||
}; | ||
|
||
export const parseInput = () => { | ||
const { _, ...params } = argv; | ||
|
||
return { | ||
argv: _, // the first element is the path to the script | ||
params, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
it('example', () => {}); |