Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit c3fd314

Browse files
authored
Merge pull request #595 from apiaryio/honzajavorek/semantic-release
Implement Semantic Release
2 parents d76defe + 7f445d6 commit c3fd314

File tree

9 files changed

+58
-61
lines changed

9 files changed

+58
-61
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/lib
33

44
# Common for .gitignore and .npmignore
5-
CHANGELOG-Generated.md
65
src-cov/
76
lcov/
87
site/

.npmignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/src
33

44
# Common for .gitignore and .npmignore
5-
CHANGELOG-Generated.md
65
src-cov/
76
lcov/
87
site/
@@ -26,4 +25,3 @@ Vagrantfile
2625
# Regardless the rules above, never ignore following
2726
!LICENSE
2827
!README.md
29-
!CHANGELOG.md

.travis.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
sudo: "required"
22
dist: "trusty"
33
language: "node_js"
4-
env:
5-
global:
6-
- secure: "io+3qwINOL+43e0qNPOr0oOEoMYUXDJroSGMwVXC4jgPW3YUe10lPRMCr39iEHg9iIOUj30xtqN8nqDdrljVIT1nM4pcrnrCcMegKXZ5dzQYFW0CW3DN06lLHt7K1Kdcah+3fXCSWPwIahns0R/SC/QRedZcOgDhD3KG7gBeoag="
7-
matrix:
8-
- "DRAFTER=JS"
9-
- "DRAFTER=CPP"
104
node_js:
115
- "0.10"
126
- "0.12"
137
- "4"
148
- "6"
9+
env:
10+
global:
11+
# GH_TOKEN and NPM_TOKEN encrypted by 'travis encrypt' utility
12+
- secure: "gO5DrzOfF+l3hjvs0kLYUrGEnYVwrDy7NTGNrtPmLrrfdS6qmUNbTVggjra2aDM82lZYo0slZaOtjedSd8GMNE41egHAq0aGMJfhNrXjr+ROOIkc1BRUn3vTp5lk/n4eU7bLozoiriBphmKHHwZqekSn2orvIpAtoWL/JPVzheY="
13+
matrix:
14+
- "DRAFTER=JS"
15+
- "DRAFTER=CPP"
16+
cache:
17+
directories:
18+
- "node_modules"
1519
before_install:
1620
- "npm -g install npm@latest"
1721
- "gem install travis"
22+
- "curl -Lo travis_after_all.py https://raw.githubusercontent.com/dmakhno/travis_after_all/master/travis_after_all.py"
1823
before_script:
1924
- "npm run lint"
2025
script:
2126
- "if [[ $DRAFTER = JS ]]; then find ./node_modules -name protagonist -type d -exec rm -rf {} +; fi"
2227
- "npm test"
2328
- "if [[ $DRAFTER = JS ]]; then npm run test:hooks-handlers; fi"
24-
after_success:
29+
after_success: # travis_after_all.py is needed due to travis-ci/travis-ci#1548 & travis-ci/travis-ci#929
2530
- "npm run coveralls"
31+
- "python travis_after_all.py"
32+
- "export $(cat .to_export_back)"
33+
- "npm run semantic-release || true"

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
{
22
"name": "dredd",
3-
"version": "1.5.0",
3+
"version": "0.0.0-semantically-released",
44
"description": "HTTP API Testing Framework",
55
"main": "lib/dredd.js",
66
"bin": {
77
"dredd": "bin/dredd"
88
},
99
"scripts": {
10-
"postinstall": "coffee ./scripts/print-installation-guidelines.coffee",
11-
"postupdate": "coffee ./scripts/print-installation-guidelines.coffee",
12-
"lint": "coffeelint ./src",
10+
"postinstall": "coffee scripts/print-installation-guidelines.coffee",
11+
"postupdate": "coffee scripts/print-installation-guidelines.coffee",
12+
"lint": "coffeelint src",
1313
"docs:build": "mkdocs build",
1414
"docs:serve": "mkdocs serve",
15-
"compile": "coffee -b -c -o lib/ src/ && coffee ./scripts/generate-cli-docs.coffee",
16-
"pretest": "npm run compile",
17-
"test": "./scripts/test",
18-
"test:bdd": "./scripts/test -w",
19-
"test:stress": "./scripts/test-stress",
20-
"test:hooks-handlers": "coffee ./scripts/test-hooks-handlers.coffee",
21-
"prepublish": "npm run compile",
22-
"coverage": "./scripts/cov",
23-
"coveralls": "npm run coverage && cat ./cov.info | ./node_modules/coveralls/bin/coveralls.js"
15+
"build": "coffee -b -c -o lib/ src/ && coffee scripts/generate-cli-docs.coffee",
16+
"pretest": "npm run build",
17+
"test": "mocha \"test/**/*-test.coffee\"",
18+
"test:hooks-handlers": "coffee scripts/test-hooks-handlers.coffee",
19+
"prepublish": "npm run build",
20+
"coverage": "scripts/cov",
21+
"coveralls": "npm run coverage && cat cov.info | coveralls",
22+
"semantic-release": "scripts/semantic-release"
2423
},
2524
"repository": {
2625
"type": "git",
@@ -59,14 +58,15 @@
5958
"coffeelint": "^1.15.7",
6059
"coveralls": "^2.11.9",
6160
"cz-conventional-changelog": "^1.1.6",
61+
"drafter": "^1.0.0",
6262
"ect": "^0.5.9",
6363
"express": "^4.14.0",
6464
"jscoverage": "^0.6.0",
6565
"lcov-result-merger": "^1.2.0",
6666
"mocha": "^3.0.0",
6767
"mocha-lcov-reporter": "^1.2.0",
6868
"nock": "^8.0.0",
69-
"drafter": "^1.0.0",
69+
"semantic-release": "^4.3.5",
7070
"sinon": "^1.17.4",
7171
"sync-exec": "^0.6.2"
7272
},

scripts/cov

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# ./scripts/cov
44

55

6-
COV=./node_modules/coffee-coverage/bin/coffeecoverage
6+
COV=./node_modules/.bin/coffeeCoverage
77
MOCHA=./node_modules/.bin/mocha
88
MERGER=./node_modules/.bin/lcov-result-merger
99

@@ -13,7 +13,7 @@ rm -rf ./src-cov ./lcov ./cov.info
1313
mkdir ./src-cov ./lcov
1414

1515
# Creating directory with instrumented JS code
16-
$COV --exclude node_modules,.git,test --path=relative . ./src-cov 1>&2
16+
$COV --exclude=node_modules,.git,test --path=relative . ./src-cov 1>&2
1717
cp ./package.json ./src-cov
1818
cp -r ./test ./src-cov/test
1919
cp -r ./bin ./src-cov/bin
@@ -25,8 +25,7 @@ echo 'beforeEach( -> process.stderr.write("."))' | tee -a ./src-cov/test/**/*-te
2525

2626
# Testing
2727
export COLLECT_COVERAGE='true'
28-
find ./src-cov/test/ -name '*-test.coffee' | xargs "$MOCHA" \
29-
--reporter='mocha-lcov-reporter' >> ./lcov/mocha.info
28+
$MOCHA "./src-cov/test/**/*-test.coffee" --reporter='mocha-lcov-reporter' >> ./lcov/mocha.info
3029

3130
# Merging LCOV reports
3231
$MERGER './lcov/*.info' ./cov.info

scripts/semantic-release

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
# Publishes new Dredd release to npm registry
3+
4+
5+
SEMANTIC_RELEASE=./node_modules/.bin/semantic-release
6+
7+
8+
add_stable_dist_tag() {
9+
PACKAGE_NAME=$(coffee -e 'console.log(require("./package.json").name)')
10+
PACKAGE_VERSION=$(coffee -e 'console.log(require("./package.json").version)')
11+
12+
npm dist-tag add "$PACKAGE_NAME@$PACKAGE_VERSION" stable
13+
return $?
14+
}
15+
16+
17+
$SEMANTIC_RELEASE pre && \
18+
npm publish && \
19+
add_stable_dist_tag && \
20+
$SEMANTIC_RELEASE post

scripts/test

Lines changed: 0 additions & 6 deletions
This file was deleted.

scripts/test-hooks-handlers.coffee

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# build will fail. Instead, we should integrate with commit
3434
# corresponding to the latest release of the hook handler implementation.
3535
# * If repository of the hook handler project has something in the `master`
36-
# branch which would print the GITHUB_TOKEN environment variable during
36+
# branch which would print the GH_TOKEN environment variable during
3737
# the Travis CI build, the token gets disclosed in the corresponding
3838
# dependent build output. Preventing this is impossible if we want
3939
# to work with GitHub in the dependent build, so as of now we rely
@@ -157,9 +157,9 @@ ensureGitAuthor = (testedCommit) ->
157157
# Adds remote origin URL with GitHub token so the script could push to the Dredd
158158
# repository. GitHub token is encrypted in Dredd's .travis.yml.
159159
ensureGitOrigin = ->
160-
if process.env.GITHUB_TOKEN
160+
if process.env.GH_TOKEN
161161
console.log('Applying GitHub token')
162-
repo = "https://#{process.env.GITHUB_TOKEN}@github.com/apiaryio/dredd.git"
162+
repo = "https://#{process.env.GH_TOKEN}@github.com/apiaryio/dredd.git"
163163
execSync("git remote set-url origin #{repo} #{DROP_OUTPUT}")
164164

165165

@@ -205,7 +205,7 @@ adjustTravisBuildConfig = (pullRequestId, testedCommit, jobName, matrixName) ->
205205
# We will want to report under the Pull Request, so we will need GitHub
206206
# token present in the configuration.
207207
execSync("""\
208-
travis encrypt GITHUB_TOKEN=#{process.env.GITHUB_TOKEN} \
208+
travis encrypt GH_TOKEN=#{process.env.GH_TOKEN} \
209209
--add --append --no-interactive --repo=apiaryio/dredd #{DROP_OUTPUT}
210210
""")
211211

@@ -250,7 +250,7 @@ adjustTravisBuildConfig = (pullRequestId, testedCommit, jobName, matrixName) ->
250250

251251
config.after_success.push('if [[ $TRAVIS_BRANCH = master ]]; then echo "Deleting aborted (master)" && exit 1; fi')
252252
config.after_success.push('git branch -D $TRAVIS_BRANCH')
253-
config.after_success.push("git remote set-url origin \"https://$GITHUB_TOKEN@github.com/apiaryio/dredd.git\" #{DROP_OUTPUT}")
253+
config.after_success.push("git remote set-url origin \"https://$GH_TOKEN@github.com/apiaryio/dredd.git\" #{DROP_OUTPUT}")
254254
config.after_success.push("git push origin -f --delete $TRAVIS_BRANCH #{DROP_OUTPUT}")
255255

256256
# Save all changes
@@ -263,7 +263,7 @@ adjustTravisBuildConfig = (pullRequestId, testedCommit, jobName, matrixName) ->
263263
createStatusCommand = (testedCommit, data) ->
264264
command = 'curl -X POST'
265265
command += ' -H "Content-Type: application/json"'
266-
command += ' -H "Authorization: token $GITHUB_TOKEN"'
266+
command += ' -H "Authorization: token $GH_TOKEN"'
267267

268268
escapedJson = JSON.stringify(data).replace(/"/g, '\\"')
269269
command += " -d \"#{escapedJson}\""

scripts/test-stress

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)