forked from alertlogic/nepal-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ps_spec.yml
117 lines (98 loc) · 5.18 KB
/
ps_spec.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
version: 1.0
service_name: nepal-common
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 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
- |
#code coverage section
COVERGAE_JSON_SUMMARY_FILE=coverage/summary/json-summary.json
echo "### Unit Test Coverage Report\n\n" > comments.txt
if [ -f $COVERGAE_JSON_SUMMARY_FILE ]; then
echo "<dl>" >> comments.txt
for k in $(jq -r '.total | keys | .[]' $COVERGAE_JSON_SUMMARY_FILE); do
if [ "$k" != "linesCovered" ]; then
total=$(jq -r ".total.$k.total" $COVERGAE_JSON_SUMMARY_FILE)
covered=$(jq -r ".total.$k.covered" $COVERGAE_JSON_SUMMARY_FILE)
pct=$(jq -r ".total.$k.pct" $COVERGAE_JSON_SUMMARY_FILE)
echo "<dt>$k</dt><dd>$pct% $covered/$total</dd>" >> comments.txt
fi
done
echo "</dl>\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
#end code coverage section
CODEBUILD_SOURCE_VERSION_WARNING="master"
PKGVERSION=$(node -e 'console.log(require("./package.json").version)')
LATEST_VERSION=$(npm show $PKGNAME version)
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.2
GITHUB_TOKEN=$ALPS_GH_TOKEN
if [ "$CODEBUILD_SOURCE_VERSION" = "$CODEBUILD_SOURCE_VERSION_WARNING" -a "$PKGVERSION" != "$LATEST_VERSION"]; then
PKGNAME=$(node -e 'console.log(require("./package.json").name)')
echo "⚠️ **WARNING** - Merging this pull request will result in a publish of **$PKGNAME** to npm from version **$LATEST_VERSION** to **$PKGVERSION**" >> comments.txt
fi
#comments api call
bin/hub api repos/alertlogic/$ALPS_REPO_NAME/issues/$ALPS_PR_NUMBER/comments --field [email protected]
- echo done
-
name: Master Push - Publish
when:
- push: ['master']
image: node:13
compute_size: small
commands:
- 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
- export CHROME_BIN='/usr/bin/google-chrome'
- |
set -ex
printenv
if [ -z "$NPM_TOKEN" ]
then
echo "\$NPM_TOKEN is empty"
exit 1
fi
#git config --global --add url."[email protected]:".insteadOf "https://github.com/"
echo //registry.npmjs.org/:_authToken="$NPM_TOKEN" > .npmrc
npm whoami
PKGNAME=$(node -e 'console.log(require("./package.json").name)')
PKGVERSION=$(node -e 'console.log(require("./package.json").version)')
V_VERSION=v$PKGVERSION
WORDCOUNT=$(npm view "${PKGNAME}@${PKGVERSION}" | wc -c)
#git tag -a $V_VERSION -m "$PKGNAME release $V_VERSION" HEAD
# Release section
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
echo "PUBLISHING $PKGNAME $PKGVERSION"
npm run build
# git push origin $V_VERSION
npm publish --access public
echo "Continuous Delivery release for ${PKGNAME}@${PKGVERSION}" > release_notes.txt
echo "CREATING RELEASE FOR ${PKGNAME}@${PKGVERSION}"
# Create a GitHub Release from master using release notes from release_notes.txt file
# See: https://hub.github.com/hub-release.1.html
bin/hub release create -F release_notes.txt -t $CODEBUILD_SOURCE_VERSION $V_VERSION
# End release section
else
echo "NOT PUBLISHING $PKGNAME $PKGVERSION"
fi
- echo done