Skip to content

Commit

Permalink
chore: Implement Semantic Release
Browse files Browse the repository at this point in the history
Closes #438
  • Loading branch information
honzajavorek committed Aug 11, 2016
1 parent d76defe commit 4516d11
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 60 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -2,7 +2,6 @@
/lib

# Common for .gitignore and .npmignore
CHANGELOG-Generated.md
src-cov/
lcov/
site/
Expand Down
2 changes: 0 additions & 2 deletions .npmignore
Expand Up @@ -2,7 +2,6 @@
/src

# Common for .gitignore and .npmignore
CHANGELOG-Generated.md
src-cov/
lcov/
site/
Expand All @@ -26,4 +25,3 @@ Vagrantfile
# Regardless the rules above, never ignore following
!LICENSE
!README.md
!CHANGELOG.md
22 changes: 15 additions & 7 deletions .travis.yml
@@ -1,25 +1,33 @@
sudo: "required"
dist: "trusty"
language: "node_js"
env:
global:
- secure: "io+3qwINOL+43e0qNPOr0oOEoMYUXDJroSGMwVXC4jgPW3YUe10lPRMCr39iEHg9iIOUj30xtqN8nqDdrljVIT1nM4pcrnrCcMegKXZ5dzQYFW0CW3DN06lLHt7K1Kdcah+3fXCSWPwIahns0R/SC/QRedZcOgDhD3KG7gBeoag="
matrix:
- "DRAFTER=JS"
- "DRAFTER=CPP"
node_js:
- "0.10"
- "0.12"
- "4"
- "6"
env:
global:
# GH_TOKEN and NPM_TOKEN encrypted by 'travis encrypt' utility
- secure: "gO5DrzOfF+l3hjvs0kLYUrGEnYVwrDy7NTGNrtPmLrrfdS6qmUNbTVggjra2aDM82lZYo0slZaOtjedSd8GMNE41egHAq0aGMJfhNrXjr+ROOIkc1BRUn3vTp5lk/n4eU7bLozoiriBphmKHHwZqekSn2orvIpAtoWL/JPVzheY="
matrix:
- "DRAFTER=JS"
- "DRAFTER=CPP"
cache:
directories:
- "node_modules"
before_install:
- "npm -g install npm@latest"
- "gem install travis"
- "curl -Lo travis_after_all.py https://raw.githubusercontent.com/dmakhno/travis_after_all/master/travis_after_all.py"
before_script:
- "npm run lint"
script:
- "if [[ $DRAFTER = JS ]]; then find ./node_modules -name protagonist -type d -exec rm -rf {} +; fi"
- "npm test"
- "if [[ $DRAFTER = JS ]]; then npm run test:hooks-handlers; fi"
after_success:
after_success: # travis_after_all.py is needed due to travis-ci/travis-ci#1548 & travis-ci/travis-ci#929
- "npm run coveralls"
- "python travis_after_all.py"
- "export $(cat .to_export_back)"
- "npm run semantic-release || true"
29 changes: 15 additions & 14 deletions package.json
@@ -1,26 +1,26 @@
{
"name": "dredd",
"version": "1.5.0",
"version": "0.0.0-semantically-released",
"description": "HTTP API Testing Framework",
"main": "lib/dredd.js",
"bin": {
"dredd": "bin/dredd"
},
"scripts": {
"postinstall": "coffee ./scripts/print-installation-guidelines.coffee",
"postupdate": "coffee ./scripts/print-installation-guidelines.coffee",
"lint": "coffeelint ./src",
"postinstall": "coffee scripts/print-installation-guidelines.coffee",
"postupdate": "coffee scripts/print-installation-guidelines.coffee",
"lint": "coffeelint src",
"docs:build": "mkdocs build",
"docs:serve": "mkdocs serve",
"compile": "coffee -b -c -o lib/ src/ && coffee ./scripts/generate-cli-docs.coffee",
"pretest": "npm run compile",
"test": "./scripts/test",
"test:bdd": "./scripts/test -w",
"test:stress": "./scripts/test-stress",
"test:hooks-handlers": "coffee ./scripts/test-hooks-handlers.coffee",
"prepublish": "npm run compile",
"coverage": "./scripts/cov",
"coveralls": "npm run coverage && cat ./cov.info | ./node_modules/coveralls/bin/coveralls.js"
"build": "coffee -b -c -o lib/ src/ && coffee scripts/generate-cli-docs.coffee",
"pretest": "npm run build",
"test": "mocha test/**/*-test.coffee",
"test:stress": "scripts/test-stress",
"test:hooks-handlers": "coffee scripts/test-hooks-handlers.coffee",
"prepublish": "npm run build",
"coverage": "scripts/cov",
"coveralls": "npm run coverage && cat cov.info | coveralls",
"semantic-release": "scripts/semantic-release"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -59,14 +59,15 @@
"coffeelint": "^1.15.7",
"coveralls": "^2.11.9",
"cz-conventional-changelog": "^1.1.6",
"drafter": "^1.0.0",
"ect": "^0.5.9",
"express": "^4.14.0",
"jscoverage": "^0.6.0",
"lcov-result-merger": "^1.2.0",
"mocha": "^3.0.0",
"mocha-lcov-reporter": "^1.2.0",
"nock": "^8.0.0",
"drafter": "^1.0.0",
"semantic-release": "^4.3.5",
"sinon": "^1.17.4",
"sync-exec": "^0.6.2"
},
Expand Down
5 changes: 2 additions & 3 deletions scripts/cov
Expand Up @@ -13,7 +13,7 @@ rm -rf ./src-cov ./lcov ./cov.info
mkdir ./src-cov ./lcov

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

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

# Merging LCOV reports
$MERGER './lcov/*.info' ./cov.info
Expand Down
20 changes: 20 additions & 0 deletions scripts/semantic-release
@@ -0,0 +1,20 @@
#!/bin/sh
# Runs tests. All arguments given to this script will be passed to mocha.


SEMANTIC_RELEASE=./node_modules/.bin/semantic-release


add_stable_dist_tag() {
PACKAGE_NAME=$(coffee -e 'console.log(require("./package.json").name)')
PACKAGE_VERSION=$(coffee -e 'console.log(require("./package.json").version)')

npm dist-tag add "$PACKAGE_NAME@$PACKAGE_VERSION" stable
return $?
}


$SEMANTIC_RELEASE pre && \
npm publish && \
add_stable_dist_tag && \
$SEMANTIC_RELEASE post
6 changes: 0 additions & 6 deletions scripts/test

This file was deleted.

12 changes: 6 additions & 6 deletions scripts/test-hooks-handlers.coffee
Expand Up @@ -33,7 +33,7 @@
# build will fail. Instead, we should integrate with commit
# corresponding to the latest release of the hook handler implementation.
# * If repository of the hook handler project has something in the `master`
# branch which would print the GITHUB_TOKEN environment variable during
# branch which would print the GH_TOKEN environment variable during
# the Travis CI build, the token gets disclosed in the corresponding
# dependent build output. Preventing this is impossible if we want
# to work with GitHub in the dependent build, so as of now we rely
Expand Down Expand Up @@ -157,9 +157,9 @@ ensureGitAuthor = (testedCommit) ->
# Adds remote origin URL with GitHub token so the script could push to the Dredd
# repository. GitHub token is encrypted in Dredd's .travis.yml.
ensureGitOrigin = ->
if process.env.GITHUB_TOKEN
if process.env.GH_TOKEN
console.log('Applying GitHub token')
repo = "https://#{process.env.GITHUB_TOKEN}@github.com/apiaryio/dredd.git"
repo = "https://#{process.env.GH_TOKEN}@github.com/apiaryio/dredd.git"
execSync("git remote set-url origin #{repo} #{DROP_OUTPUT}")


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

Expand Down Expand Up @@ -250,7 +250,7 @@ adjustTravisBuildConfig = (pullRequestId, testedCommit, jobName, matrixName) ->

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

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

escapedJson = JSON.stringify(data).replace(/"/g, '\\"')
command += " -d \"#{escapedJson}\""
Expand Down
21 changes: 0 additions & 21 deletions scripts/test-stress

This file was deleted.

0 comments on commit 4516d11

Please sign in to comment.