Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

[IN_PROGRESS] - Adding code coverage report #113

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
7 changes: 6 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ module.exports = function (config) {
"directory": "coverage",
"subdirectory": "report"
},
"text-summary": ""
"text-summary": "",
"json-summary": {
"directory": "coverage",
"subdirectory": "summary",
"filename": "json-summary.json"
}
},
compilerOptions: {
lib: [
Expand Down
50 changes: 47 additions & 3 deletions ps_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,64 @@ stages:
name: PR Test
when:
- pull_request
- pull_request:
trigger_phrase: test it
image: node:13
compute_size: small
commands:
- npm install
- echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- apt-get update && apt-get -y install google-chrome-stable
- apt-get update && apt-get -y install google-chrome-stable && apt-get -y install jq
- export CHROME_BIN='/usr/bin/google-chrome'
- npm run test
- npm run lint
- npm run build
- npx madge --circular --extensions ts --ts-config tsconfig.json src
- |

echo "start"

COVERGAE_JSON_SUMMARY_FILE=coverage/summary/json-summary.json

echo "### Unit Test Coverage Report\n\n" > comments.txt

COVERAGE_JSON_SUMMARY_BODY="<dl>"

if [ -f $COVERGAE_JSON_SUMMARY_FILE ]; then
for k in $(jq -r '.total | keys | .[]' $COVERGAE_JSON_SUMMARY_FILE); do
if [ "$k" != "linesCovered" ]; then
echo $k
value=$(jq -r ".total.$k" $COVERGAE_JSON_SUMMARY_FILE)
echo $value
total=$(jq -r ".total.$k.covered" $COVERGAE_JSON_SUMMARY_FILE)
covered=$(jq -r ".total.$k.covered" $COVERGAE_JSON_SUMMARY_FILE)
skipped=$(jq -r ".total.$k.skipped" $COVERGAE_JSON_SUMMARY_FILE)
pct=$(jq -r ".total.$k.pct" $COVERGAE_JSON_SUMMARY_FILE)
COVERAGE_JSON_SUMMARY_BODY+="<dt>$k</dt><dd>$pct% $covered/$total</dd>"
echo "$covered - $skipped - $total - $pct ---- $COVERAGE_JSON_SUMMARY_BODY"
fi
done
COVERAGE_JSON_SUMMARY_BODY+="</dl>"
echo "$COVERAGE_JSON_SUMMARY_BODY \n\n" >> comments.txt
else
echo "⚠️ **WARNING** - coverage json data not found. Add **json-summary** to .karmaTypescriptConfig.reports in **karma.conf.js** " > comments.txt
fi

CODEBUILD_SOURCE_VERSION_WARNING="master"
if [ "$CODEBUILD_SOURCE_VERSION" = "$CODEBUILD_SOURCE_VERSION_WARNING" ]; then
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.2
GITHUB_TOKEN=$ALPS_GH_TOKEN
PKGNAME=$(node -e 'console.log(require("./package.json").name)')
PKGVERSION=$(node -e 'console.log(require("./package.json").version)')
LATEST_VERSION=$(npm show $PKGNAME version)
echo "⚠️ **WARNING** - Merging this pull request will result in a publish of **$PKGNAME** to npm from version **$LATEST_VERSION** to **$PKGVERSION**" >> comments.txt

fi

bin/hub api repos/alertlogic/$ALPS_REPO_NAME/issues/$ALPS_PR_NUMBER/comments --field [email protected]

- echo done

-
name: Master Push - Publish
Expand Down Expand Up @@ -58,8 +104,6 @@ stages:
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.2
GITHUB_TOKEN=$ALPS_GH_TOKEN



npm install

if [ "$WORDCOUNT" -eq 0 ]; then
Expand Down