diff --git a/README.md b/README.md index 6a07357..131b7ac 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,14 @@ GitHub repository that store the tests GitHub specific branch +### `npm-start` + +Run npm start and waits to url before testing + +### `wait-for` + +Url that npm start command waits for + ## Outputs ### `result` @@ -30,6 +38,8 @@ Pull Request number that trigger build. with: repository-test-name: my-org/my-repo repository-test-branch: master # master is default + npm-start: true # false is default + wait-for: 'http://localhost:8080' # http://localhost:3000 is default ``` ## How to get result output diff --git a/action.yml b/action.yml index 210f936..7049557 100644 --- a/action.yml +++ b/action.yml @@ -8,6 +8,12 @@ inputs: description: 'GitHub specific branch' default: 'master' required: true + npm-start: + description: 'Run npm start and waits to url before testing' + default: false + wait-for: + description: 'Url that npm start command waits for' + default: 'http://localhost:3000' outputs: result: description: 'Jest unit tests JSON results in base64 format.' @@ -19,3 +25,5 @@ runs: args: - ${{ inputs.repository-test-name }} - ${{ inputs.repository-test-branch }} + - ${{ inputs.npm-start }} + - ${{ inputs.wait-for }} diff --git a/entrypoint.sh b/entrypoint.sh index 4f99e4e..c3163b2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,11 +3,18 @@ set -x REPOSITORY_NAME=$1 REPOSITORY_BRANCH=$2 +run_npm_start=$3 +wait_for_url=$4 git clone --branch $REPOSITORY_BRANCH https://github.com/$REPOSITORY_NAME.git /project-tests rm -rf /project-tests/.git cp -r /project-tests/* . npm install + +if $run_npm_start ; then + npm start & npx wait-on $wait_for_url +fi + npm test -- --json --outputFile=evaluation.json node /evaluator.js evaluation.json .trybe/requirements.json result.json