Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade semantic-release #181

Merged
merged 1 commit into from
Aug 8, 2018
Merged
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
35 changes: 18 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
sudo: false
language: node_js
node_js:
- "8"
- "6"
- "4"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving nodejs versions to travis (parallel build stages) in order to enable the release job as a separate stage.

cache:
directories:
- node_modules
Expand All @@ -11,26 +15,23 @@ notifications:
on_pull_requests: false
rooms:
secure: mWzYwXXkaPJ/t24kG9gz6hYyRGoGX+zsjKDa+IzjhY4NeMJyzgHyN3x1vWwSXhfG1jQuBTFyT5RTWN8Jfo2Za/XDKYfMXXP5gCMtNkeWdflYWaUC7sAZepRANUB3gzkCTvkc/DOY/FI07xCcLMJoZ7jGiADNakTaWvzdExJUBs6NuhGdIUmOT+chbip02yN7mSPeqyU7/vFqpCxxEoPeNzaNshLufbZUEWgmLm0bm5Uxdo7Yi5rL0/nA7oqXUzzWTtgQEu0mOG4Oqu7oXAki2rLISw8enZwt5/fUbxGgK1J3UB86vgnDrxbTAhuNUuddaSxUuDsg1+3xyRzU74cyKUWnWqL10Tyy9KgDR0A+48w2v8DH/pOvnvfXA+FL0zLtDJ9jPuSK0dFbceRYmolEGMDF53Q/s2W+waC13Bi3nHRQJKYmT+bOnoLABLpfm5fbV/2br4LVTQwiP80HJ+19Vy4lriF55zu1yjESUBzdvvX1Dhp5E3AXZZv6xB0v4gyZZeOoIv6BxqinLauZiS3nM7O9vu1QnFvbo4HH0Df651fyy1kOU5UAAD+CNRgpZ8GMc+EegvnLbS3nzbNOPlkACmhxMNcpEvD6MomcB4UV2dPWAYIQSfrRV5h+iZlNSqCkA2pl3p6TTZhLMvoSxziRzUZZx7GQe/cnUGN6GbzyyRk=
matrix:
include:
- node_js: "8"
- node_js: "6"
- node_js: "4"
before_install:
# tests are failing on npm@5, remove this once this is not an issue
- npm i -g npm@^3.0.0
before_script:
- npm prune
script:
- npm run snyk-auth
# tests are failing on npm@5, downgrade to npm@3 if >3 is installed
- test "$(npm -v | cut -d'.' -f1)" -le 3 || npm i -g npm@^3.0.0
- npm test
after_success:
- npm run travis-coverage
- python scripts/travis_after_all.py
- export $(cat .to_export_back)
- npm run semantic-release
- bash scripts/travis_after_success.sh
jobs:
include:
- stage: Release
node_js: "8"
script:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this from after_success to script so that if it fails, the job fails

# run only if this is a 'push' build
# 1. grab and run semantic-release
# (not used as a dev dep because it pulls in new `npm` and breaks our tests)
# 2. run post-release actions
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npx semantic-release && bash scripts/travis_after_success.sh; fi'
branches:
except:
- "/^v\\d+\\.\\d+\\.\\d+$/"
- /^released-/
only:
- "master"
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ install:
# Post-install test scripts.
test_script:
- npm run snyk-auth-windows
- npm run windows-tests
- npm run tap
14 changes: 1 addition & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
"node": ">=4"
},
"scripts": {
"coverage": "tap --cov --coverage-report=lcov test/*.test.js",
"tap": "COVERALLS_REPO_TOKEN=0 tap --timeout=180 --cov --coverage-report=text-summary test/*.test.js",
"tap": "tap test/*.test.js -R spec --timeout=180",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing coveralls, unifying appveyor and travis test target.

"test": "npm run test-common && npm run tap",
"test-common": "npm run check-tests && npm run lint && node cli/index.js test --org=snyk",
"windows-tests": "tap -R spec test/*.test.js --timeout=120",
"lint": "jscs `find ./cli -name '*.js'` -v && jscs `find ./lib -name '*.js'` -v",
"check-tests": "! grep 'test\\.only' test/*.test.js -n",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semantic-release is external to the package.json file, managed via travis settings.

"snyk-auth": "node cli auth $SNYK_API_KEY",
"snyk-auth-windows": "node cli auth %SNYK_API_KEY%"
},
Expand Down Expand Up @@ -70,7 +67,6 @@
"nock": "^9.2.5",
"proxyquire": "^1.7.4",
"restify": "^4.1.1",
"semantic-release": "^8",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semantic-release is external to the package.json file, managed via travis settings.

"sinon": "^1.17.2",
"strip-ansi": "^4.0.0",
"tap": "^5.7.1",
Expand All @@ -81,14 +77,6 @@
"type": "git",
"url": "https://github.com/snyk/snyk.git"
},
"nyc": {
"exclude": [
"test",
"test{,-*}.js",
"**/*.test.js",
"**/__tests__/**"
]
},
"pkg": {
"scripts": [
"cli/**/*.js",
Expand Down
21 changes: 0 additions & 21 deletions scripts/test-vulns.sh

This file was deleted.

122 changes: 0 additions & 122 deletions scripts/travis_after_all.py

This file was deleted.

13 changes: 13 additions & 0 deletions scripts/travis_after_success.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

# trigger external services into post-release action
if [ "$TRAVIS_BRANCH" = "master" ]; then
# manually detect master branch push, and post a dockerhub trigger to build the docker images
curl -s -H "Content-Type: application/json" --data "{\"build\": true}" -X POST "https://registry.hub.docker.com/u/snyk/snyk-cli/trigger/${DOCKER_TOKEN}/"
Expand All @@ -10,3 +11,15 @@ if [ "$TRAVIS_BRANCH" = "master" ]; then
curl "https://g.codefresh.io/api/builds/$GRADLE28_BUILD_ID" -H "content-type:application/json; charset=utf-8" -H "x-access-token: $CF_ACCESS_TOKEN" --data-binary "{\"repoOwner\":\"snyk\",\"repoName\":\"snyk\",\"serviceId\":\"$GRADLE28_BUILD_ID\",\"branch\":\"master\",\"type\":\"build\"}" --compressed
curl "https://g.codefresh.io/api/builds/$GRADLE44_BUILD_ID" -H "content-type:application/json; charset=utf-8" -H "x-access-token: $CF_ACCESS_TOKEN" --data-binary "{\"repoOwner\":\"snyk\",\"repoName\":\"snyk\",\"serviceId\":\"$GRADLE44_BUILD_ID\",\"branch\":\"master\",\"type\":\"build\"}" --compressed
fi

# grab latest version and publish its assets
npm i -g snyk # must install to get the proper `version` key
cd $(dirname $(which snyk))/../lib/node_modules/snyk

npx pkg . # create standalone binaries based on the latest `pkg`

export SNYK_VERSION=$(./cli/index.js -v)

# upload assets built by `pkg`
# GH_TOKEN is set as Travis env var
GITHUB_TOKEN=$GH_TOKEN npx github-release upload --owner snyk --repo snyk --tag "v${SNYK_VERSION}" --name "v${SNYK_VERSION}" ./snyk-linux ./snyk-macos ./snyk-win.exe
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied from our internal documentation, please verify correctness :)