Skip to content

Commit

Permalink
Updated documentation, made more variables environment variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
travis-ci committed Apr 7, 2018
1 parent 155f5bd commit 650899e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,51 @@ This module hacks around the problem of running a Travis-CI job and wanting to n
This is a start on solving [Handle Ant's JUnit XML formatted output from test/spec runs](https://github.com/travis-ci/travis-ci/issues/239).


1. To update an issue from Travis-ci, get a GitHub token
1. On [GitHub](https://github.com), under your account on the upper right, click on Settings -> Developer Settings -> Personal access tokens -> [Generate new token](https://github.com/settings/tokens)
2. The new token should have `public_repo` status
3. On [Travis-ci](https://travis-ci.org), on your project page, click on More options -> Settings, then add the token from the step above as `GITHUB_TOKEN`
4. For testing purposes, set the GITHUB_TOKEN environment variable on your local machine
2. Create an issue in your GitHub repo that will be the issue that gets updated with the test results, for example `junit-results`

3. In your environment, set the JUNIT_LABEL variable to the name of the label.
```
export JUNIT_LABEL=junit-results
```

4. Update the variables in `scripts/config.js`

5. To test:
```
node ./scripts/junit-results.js
```

6. To actually upload the results to an issue:
```
export JUNIT_RESULTS_NOT_DRY_RUN=false
node junit-results.js
```

7. To have Travis do the update, create a script:
```
#!/bin/bash
mkdir node_modules
npm install @icyphy/github-issue-junit
export JUNIT_LABEL=junit-results
export JUNIT_RESULTS_NOT_DRY_RUN=false
export GITHUB_ISSUE_JUNIT=https://api.github.com/repos/cxbrooks/travis-junit
(cd node_modules/@icyphy/github-issue-junit/scripts; node junit-results.js)
```

# How to publish updates to this module

1. Update the patch number in package.json
2. Login to npm
npm login

Username: icyphy-npm
Password: See https://wiki.eecs.berkeley.edu/ptolemy/Ptolemy/Accounts
Email: [email protected]
3. Publish:
npm publish --access public
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@terraswarm/github-issue-junit",
"name": "@icyphy/github-issue-junit",
"version": "0.1.0",
"description": "Read JUnit HTML output and add a comment to an open issue on GitHub.",
"author": {
Expand Down
13 changes: 11 additions & 2 deletions scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ const ms = require('ms');

const config = {};

// The repo that has an issue with label that will be updated.
// Typical: export GITHUB_ISSUE_JUNIT=https://api.github.com/repos/cxbrooks/travis-junit
config.apiUrl = process.env.GITHUB_ISSUE_JUNIT

// The label of an issue in the repo.
// Typical: export JUNIT_LABEL=junit-results
config.issuesLabel = process.env.JUNIT_LABEL;

// Invoke "export JUNIT_RESULTS_NOT_DRY_RUN=true" to actually post/delete comments
// To actually post or delete a comment: Invoke "export JUNIT_RESULTS_NOT_DRY_RUN=true" and then.
config.dryRun = !process.env.JUNIT_RESULTS_NOT_DRY_RUN;

// The GitHub personal access token should have public_repo access.
config.githubToken = process.env.GITHUB_TOKEN
config.apiUrl = 'https://api.github.com/repos/cxbrooks/travis-junit';

// This is used to extract the URL of the JUnit Summary page from the issue.
// This is probably excess generality, but we leave it for now.
config.junit_url_reg = /https:\/\/.*\/reports\/junit\/html\/overview-summary.html/ig;

config.jUnitResultsRetryOptions = {
retries: 5,
Expand Down

0 comments on commit 650899e

Please sign in to comment.