Skip to content

Instantly share code, notes, and snippets.

@DanPurdy
Created April 6, 2016 19:03
Show Gist options
  • Save DanPurdy/240f4c9d755778d031e3763e9af666c7 to your computer and use it in GitHub Desktop.
Save DanPurdy/240f4c9d755778d031e3763e9af666c7 to your computer and use it in GitHub Desktop.
Checks your Karma output (karma-mocha-reporter format) for errors and reports the status back to github via the status API
## Check for Karma errors
if [ -e "test-reports/karma.mocha.json" ]; then
if (grep -c '\"failures\": 0,' "./test-reports/karma.mocha.json" 1> /dev/null 2>&1); then
curl -H "Authorization: token <YOUR-GITHUB-TOKEN-HERE>" \
--request POST \
--data \
'{
"state": "success",
"context": "Karma - Unit tests",
"description": "The unit tests were successful",
"target_url": "${bamboo.buildResultsUrl}"
}' \
https://GITHUB-URL/api/v3/repos/GITHUB-USER/REPO/statuses/${bamboo.repository.revision.number} > /dev/null
else
curl -H "Authorization: token <YOUR-GITHUB-TOKEN-HERE>" \
--request POST \
--data \
'{
"state": "failure",
"context": "Karma - Unit tests",
"description": "The unit tests failed",
"target_url": "${bamboo.buildResultsUrl}"
}' \
https://GITHUB-URL/api/v3/repos/GITHUB-USER/REPO/statuses/${bamboo.repository.revision.number} > /dev/null
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment