Skip to content

Commit

Permalink
feat: allow specifying a test command
Browse files Browse the repository at this point in the history
  • Loading branch information
ziishaned authored Dec 7, 2019
2 parents c942c2c + 6f8b71a commit 872c105
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ inputs:
github-token:
description: "Github token"
required: true
test-command:
description: "Specify a command to run the tests"
required: false
runs:
using: "node12"
main: "index.js"
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const main = async () => {
const repoName = context.repo.repo;
const repoOwner = context.repo.owner;
const githubToken = core.getInput("github-token");
const testCommand = core.getInput("test-command") || "npx jest";

const githubClient = new GitHub(githubToken);
const commitPRs = await githubClient.repos.listPullRequestsAssociatedWithCommit(
Expand All @@ -17,7 +18,7 @@ const main = async () => {
);
const prNumber = commitPRs.data[0].number;

const codeCoverage = execSync("npx jest").toString();
const codeCoverage = execSync(testCommand).toString();
let coveragePercentage = execSync(
"npx coverage-percentage ./coverage/lcov.info --lcov"
).toString();
Expand Down
9 changes: 7 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ This action comments a pull request with the jest code coverage

**Required** Github token.

### `test-command`

**Optional** A custom command to run the tests. (defaults to `npx jest` if not specified)

## Example usage

```yml
uses: ziishaned/[email protected]
with:
github-token: 'github-token'
```
github-token: ${{ secrets.GITHUB_TOKEN }}
test-command: "yarn jest --coverage"
```

0 comments on commit 872c105

Please sign in to comment.