Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update action to allow more felxibilty #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,15 @@ with:
working-directory: "frontend"
```

### Process jest result and publish

```yaml
uses: mattallty/jest-github-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
process-only: true
results-file: "jest.results.json"
```

See the [actions tab](https://github.com/mattallty/jest-github-action/actions) for runs of this action! :rocket:
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ branding:
icon: "check"
color: "blue"
inputs:
process-only:
description: "Only process the result file"
required: false
default: "false"
results-file:
description: "Filename for the jest result file"
required: false
default: "jest.results.json"
test-command:
description: "The test command to run"
required: false
Expand Down
16 changes: 12 additions & 4 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ const COVERAGE_HEADER = ":loop: **Code coverage**\n\n"
export async function run() {
let workingDirectory = core.getInput("working-directory", { required: false })
let cwd = workingDirectory ? resolve(workingDirectory) : process.cwd()
const CWD = cwd + sep
const RESULTS_FILE = join(CWD, "jest.results.json")
const resultFileName = core.getInput("results-file", { required: false }) || "jest.results.json"
let processOnly = core.getInput("process-only", { required: false })

const CWD = cwd + sep
const RESULTS_FILE = join(CWD, resultFileName)

try {
const token = process.env.GITHUB_TOKEN
if (token === undefined) {
Expand All @@ -29,9 +32,14 @@ export async function run() {
return
}

const cmd = getJestCommand(RESULTS_FILE)
if (processOnly === "true") {
console.log("Processing file: " + RESULTS_FILE)
} else {
const cmd = getJestCommand(RESULTS_FILE)

await execJest(cmd, CWD)
await execJest(cmd, CWD)

}

// octokit
const octokit = new GitHub(token)
Expand Down