From e3af6c861287ba098c2b7876cbceecb2df46f1b8 Mon Sep 17 00:00:00 2001 From: Huan LI Date: Fri, 10 Nov 2017 17:53:35 +0800 Subject: [PATCH] Update travis ci to use stage & deploy on branch (#956) --- .travis.yml | 53 ++++++++++++++++++++++++++++++---------------------- package.json | 2 +- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9e077b0a..06dda86a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,4 @@ -sudo: false language: node_js - node_js: - "8" @@ -19,22 +17,46 @@ cache: directories: - node_modules -before_install: - install: - - if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew update; brew cleanup; brew cask cleanup; fi - # - if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew uninstall --force brew-cask; brew update; fi + - if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew update; fi + - if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew cleanup; fi + - if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew cask cleanup; fi + - if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew install jq; fi - if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew install moreutils; fi - if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew install shellcheck; fi - - if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew install jq; fi - npm install script: - echo $TRAVIS_OS_NAME - node --version - npm --version - - npm run test - - npm run test:npm && echo 'Npm packing test is passed' + - npm test + +after_success: + - if [ "$TRAVIS_OS_NAME" == 'osx' ]; then npm run coverage; fi + +stages: + - test + - pack + - name: deploy + if: branch = /^(master|v\d+\.\d+)/ + +jobs: + include: + - stage: pack + script: + - npm run test:pack && echo 'Npm packing test is passed' + + - stage: deploy + script: + - echo "Deploying to NPM ..." + - npm version + - npm run dist + + deploy: + provider: npm + email: zixia@zixia.net + api_key: "$NPM_TOKEN" notifications: webhooks: @@ -46,16 +68,3 @@ notifications: email: on_success: change on_failure: change - -after_success: - - if [ "$TRAVIS_OS_NAME" == 'osx' ]; then npm run coverage; fi - -before_deploy: - - npm version - - npm run dist - -deploy: - provider: npm - email: zixia@zixia.net - api_key: "$NPM_TOKEN" - skip_cleanup: true diff --git a/package.json b/package.json index 2917dc8f..30a53c7f 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "sloc": "sloc bin example src test index.ts --details --format cli-table --keys total,source,comment && sloc bin example src test index.ts", "test": "npm run clean && npm run lint && npm run test:unit && npm run test:shell && npm run sloc", "test:linux": "npm run pretest && parallel ts-node -- ./src/**/*.spec.ts ./test/**/*.spec.ts && npm run posttest", - "test:npm": "npm run dist && export TMPDIR=/tmp/wechaty.$$ && npm pack && mkdir $TMPDIR && mv wechaty-*.*.*.tgz $TMPDIR && cp test/fixture/smoke-testing.js $TMPDIR && cd $TMPDIR && npm init -y && npm i wechaty-*.*.*.tgz && node smoke-testing.js", + "test:pack": "npm run dist && export TMPDIR=/tmp/wechaty.$$ && npm pack && mkdir $TMPDIR && mv wechaty-*.*.*.tgz $TMPDIR && cp test/fixture/smoke-testing.js $TMPDIR && cd $TMPDIR && npm init -y && npm i wechaty-*.*.*.tgz && node smoke-testing.js", "test:shell": "shellcheck bin/*.sh", "test:unit": "blue-tape -r ts-node/register -r source-map-support/register \"src/**/*.spec.ts\" \"tests/**/*.spec.ts\"", "test:win32": "npm run test:unit", -- GitLab