diff --git a/README.md b/README.md index 315c17a..53dadae 100644 --- a/README.md +++ b/README.md @@ -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: icyphy-npm@icyphy.org +3. Publish: + npm publish --access public diff --git a/package.json b/package.json index add551a..6d7c527 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/scripts/config.js b/scripts/config.js index ce4f0fa..7c932f8 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -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,