|
1 | 1 | language: node_js
|
2 | 2 |
|
3 |
| -matrix: |
4 |
| - include: |
5 |
| - - node_js: '4' |
6 |
| - - node_js: '6' |
7 |
| - - node_js: '8' |
8 |
| - - node_js: '10' |
9 |
| - - node_js: '10' |
10 |
| - env: |
11 |
| - - DISABLE_TESTS=true |
12 |
| - - LINTING=true |
| 3 | +git: |
| 4 | + # Minimize git history, but ensure to not break things: |
| 5 | + # - Merging multiple PR's around same time may introduce a case where it's not |
| 6 | + # the last merge commit that is to be tested |
| 7 | + # - Aside of merge commit we need a previous commit to be able to detect a version switch |
| 8 | + depth: 30 |
| 9 | + |
| 10 | +cache: |
| 11 | + # Not relying on 'npm' shortcut, as per Travis docs it's the only 'node_modules' that it'll cache |
| 12 | + directories: |
| 13 | + - $HOME/.npm |
| 14 | + - node_modules |
| 15 | + |
| 16 | +branches: |
| 17 | + only: # Do not build PR branches |
| 18 | + # Release branches |
| 19 | + - master |
| 20 | + # Release tags |
| 21 | + - /^v\d+\.\d+\.\d+$/ # Ensure to build release tags |
| 22 | + |
| 23 | +stages: |
| 24 | + - name: Test |
| 25 | + if: tag IS NOT present |
| 26 | + - name: Tag on Release |
| 27 | + if: branch = master AND type = push |
| 28 | + - name: Deploy |
| 29 | + if: tag =~ ^v\d+\.\d+\.\d+$ |
13 | 30 |
|
14 |
| -sudo: false |
| 31 | +env: |
| 32 | + global: |
| 33 | + - FORCE_COLOR=1 # Ensure colored output (color support is not detected in some cases) |
15 | 34 |
|
| 35 | +# Ensure to install dependencies at their latest versions |
16 | 36 | install:
|
17 |
| - - travis_retry npm install |
| 37 | + # Note: `npm update` has issues which we need to workaround: |
| 38 | + # - There seems no way to update all project dependency groups in one run |
| 39 | + # Hence different calls for prod and dev dependencies |
| 40 | + # - The bigger depth, the longer update takes (-9999 as proposed in npm docs hangs the process). |
| 41 | + # Therefore we keep at 3 which should ensure most of dependencies are at latest versions |
| 42 | + # - Depth setting makes optional dependencies not optional (install error crashes process) |
| 43 | + # Hence we skip install of optional dependencies completely, with --no-optional |
| 44 | + # Note: this patch works only for npm@5+ |
| 45 | + # - npm documents --dev option for dev dependencies update, but it's only --save-dev that works |
| 46 | + - npm update --depth 3 --no-optional --no-save |
| 47 | + - npm update --depth 3 --save-dev --no-save |
| 48 | + |
| 49 | +before_script: |
| 50 | + # Fail build right after first script fails. Travis doesn't ensure that: https://github.com/travis-ci/travis-ci/issues/1066 |
| 51 | + # More info on below line: https://www.davidpashley.com/articles/writing-robust-shell-scripts/#idm5413512 |
| 52 | + - set -e |
| 53 | + - git config --global user.email "platform@serverless.com" |
| 54 | + - git config --global user.name "Serverless CI" |
| 55 | + |
| 56 | +jobs: |
| 57 | + include: |
| 58 | + # In most cases it's best to configure one job per platform & Node.js version combination |
| 59 | + # (job boot & setup takes ca 1 minute, one task run lasts ca few seconds) |
| 60 | + |
| 61 | + # PR's from branches |
| 62 | + # Ensure commit messages follow CC, and confirm on changelog in case of release PR's |
| 63 | + - name: 'Prettier check updated, Lint updated, Commitlint, Changelog confirm (on release), Unit Tests - Node.js v12' |
| 64 | + if: type = pull_request AND fork = false |
| 65 | + node_js: 12 |
| 66 | + script: |
| 67 | + - npm run prettier-check:updated |
| 68 | + - npm run lint:updated |
| 69 | + - npm run commitlint:pull-request |
| 70 | + # If release PR, confirm we have a changelog |
| 71 | + - | |
| 72 | + tagName=`git diff master package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || : |
| 73 | + if [ -n "$tagName" ]; |
| 74 | + then |
| 75 | + npx dump-release-notes-from-cc-changelog $tagName |
| 76 | + fi |
| 77 | + - npm test |
18 | 78 |
|
19 |
| -script: |
20 |
| - - if [[ ! -z "$DISABLE_TESTS" && ! -z "$LINTING" ]]; then npm run lint; fi |
| 79 | + # PR's from forks |
| 80 | + # Do not validate commit messages, |
| 81 | + # (if user didn't ensure CC, PR should be squash merged with a valid CC commit message) |
| 82 | + - name: 'Prettier check updated, Lint updated, Unit Tests - Node.js v12' |
| 83 | + if: type = pull_request AND fork = true |
| 84 | + node_js: 12 |
| 85 | + script: |
| 86 | + - npm run prettier-check:updated |
| 87 | + - npm run lint:updated |
| 88 | + - npm test |
21 | 89 |
|
22 |
| -after_success: |
23 |
| - - ./node_modules/jest/bin/jest.js --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage |
| 90 | + # master branch |
| 91 | + - name: 'Unit Tests - Node.js v12' |
| 92 | + if: type != pull_request |
| 93 | + node_js: 12 |
| 94 | + |
| 95 | + - name: 'Unit Tests, Coverage - Node.js v13' |
| 96 | + node_js: 13 |
| 97 | + script: |
| 98 | + - npm run coverage |
| 99 | + - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js |
| 100 | + |
| 101 | + - name: 'Unit Tests - Node.js v10' |
| 102 | + node_js: 10 |
| 103 | + |
| 104 | + - name: 'Unit Tests - Node.js v8' |
| 105 | + node_js: 8 |
| 106 | + |
| 107 | + - name: 'Unit Tests - Node.js v6' |
| 108 | + node_js: 6 |
| 109 | + |
| 110 | + - name: 'Unit Tests - Node.js v4' |
| 111 | + node_js: 4 |
| 112 | + |
| 113 | + - stage: Tag on Release |
| 114 | + name: 'Tag on Release' |
| 115 | + node_js: 12 |
| 116 | + env: |
| 117 | + # GITHUB_TOKEN |
| 118 | + - secure: Eu4uYULeMcBVkj3AJxKTGTytCkGBDZAl5z/26Jnv1sH3hK02UQeJdE2L8gTk/TfMS/MMLInSb0YqD4S8qEz6C3zg4Q9z9/N653JaKSbpQPjjc8BsOaZlgo0rrUJWu/BwdYLou1zAhAGd4cUtyAAnIkvJW30XAnH6A73EyGY3GgRRIUGb/PxUB2cHrqalq/V/u6kuNw5Sf26SmVVdJMhj5/es+kQdI2EeykEQMO2FRXKV2GRXs5TFikW/doTENHQAK6QPWJbVX1PHF4Via9vJuLhaOo4QjH3XCpDYX5UYsR7gvOChSsY3VMjHgLkjgTyabiv0mnrhjsLkkvlVsSzmmYmMShyGbJSjnqAa+C69oGFJo9Tim5qQOEJIZ5R7A1ctS8wZSmb2YUc7YU/1/kTjQ8ccU1MgAPp4w9drdwCZXLTQ8fc1MYPo4+sDoAdJVSpS9YQ5qsenZH1lgyJ3iV+RwLjzltdRTs4FjeAOxCaEjpdhXkVZpH58wiDYm4F4OfzfvvSYPSxa2eoZVSI+YV4YEtHQrFgxWwNHgIt8rH8zETKjhlva6PCirZdWfmQg1LU/3Jly1lNw9fkTy9UzAfsLaSQM8hEbjOR6nh7AQCUqp9Fq7jH7lV/t/yGEIH5Ie/qW/uFcZpV1RLicgeGAnI+7RM55vSB9tyO8tiJcWBQZgLw= |
| 119 | + script: |
| 120 | + - | |
| 121 | + tagName=`git diff HEAD^ package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || : |
| 122 | + if [ -n "$tagName" ]; |
| 123 | + then |
| 124 | + git tag v$tagName |
| 125 | + git push -q https://$GITHUB_TOKEN@github.com/serverless/test --tags |
| 126 | + fi |
| 127 | +
|
| 128 | + # version tag |
| 129 | + - stage: Deploy |
| 130 | + env: |
| 131 | + # GITHUB_TOKEN |
| 132 | + - secure: Eu4uYULeMcBVkj3AJxKTGTytCkGBDZAl5z/26Jnv1sH3hK02UQeJdE2L8gTk/TfMS/MMLInSb0YqD4S8qEz6C3zg4Q9z9/N653JaKSbpQPjjc8BsOaZlgo0rrUJWu/BwdYLou1zAhAGd4cUtyAAnIkvJW30XAnH6A73EyGY3GgRRIUGb/PxUB2cHrqalq/V/u6kuNw5Sf26SmVVdJMhj5/es+kQdI2EeykEQMO2FRXKV2GRXs5TFikW/doTENHQAK6QPWJbVX1PHF4Via9vJuLhaOo4QjH3XCpDYX5UYsR7gvOChSsY3VMjHgLkjgTyabiv0mnrhjsLkkvlVsSzmmYmMShyGbJSjnqAa+C69oGFJo9Tim5qQOEJIZ5R7A1ctS8wZSmb2YUc7YU/1/kTjQ8ccU1MgAPp4w9drdwCZXLTQ8fc1MYPo4+sDoAdJVSpS9YQ5qsenZH1lgyJ3iV+RwLjzltdRTs4FjeAOxCaEjpdhXkVZpH58wiDYm4F4OfzfvvSYPSxa2eoZVSI+YV4YEtHQrFgxWwNHgIt8rH8zETKjhlva6PCirZdWfmQg1LU/3Jly1lNw9fkTy9UzAfsLaSQM8hEbjOR6nh7AQCUqp9Fq7jH7lV/t/yGEIH5Ie/qW/uFcZpV1RLicgeGAnI+7RM55vSB9tyO8tiJcWBQZgLw= |
| 133 | + node_js: 12 |
| 134 | + script: skip |
| 135 | + # Ensure to fail build if deploy fails, Travis doesn't ensure that: https://github.com/travis-ci/travis-ci/issues/921 |
| 136 | + before_deploy: |
| 137 | + - set -e |
| 138 | + # Remove eventual old npm logs |
| 139 | + - rm -rf ~/.npm/_logs |
| 140 | + after_deploy: |
| 141 | + - | |
| 142 | + # npm creates log only on failure |
| 143 | + if [ -d ~/.npm/_logs ] |
| 144 | + then |
| 145 | + # Undocumented way to force Travis build to fail |
| 146 | + travis_terminate 1 |
| 147 | + fi |
| 148 | + - npx github-release-from-cc-changelog $TRAVIS_TAG |
| 149 | + deploy: |
| 150 | + edge: true # Workaorund Travis regression: https://travis-ci.community/t/missing-api-key-when-deploying-to-github-releases/5761 |
| 151 | + provider: npm |
| 152 | + email: services@serverless.com |
| 153 | + on: |
| 154 | + tags: true |
| 155 | + api_key: |
| 156 | + secure: GxHxrCEjTIwzcHW6EEJm6/6Lwm3H+aTmOSrDHgwMwiwg98fTqQ2pD1L06CppSiaq9T33RPEim4kuBHIpTtmiJwVVQMIdEQheUfE05OwWBWcOEta2h3ahbGPX8iA48aVdRuXD4/Vpiho2a7zPuVBIsgDH1OzLO/WiYx10afzqlOOvwBITOkRy6eKD/I/Omxid6KjvMwfrHYScWvL9JTo7aV0MhFL4MV+9fN3nutF5+wSSIjfkzTmhxKmHEi/nlcuFCVS8yfutX7sMLugxNilqbv815SbjHMrkgZwkzrnalTbF3B2ohV8zYcuCrUEwDPRlrWbmoFMGJdcuXE90HPiHagn2Olv5e28f5ToQGFzwzYWrAO2Rc4l6gyUn8uwonN/xrK6N8ucEti9b/vzQz2/bH3rB+S++ZPiYAUcgZ8eLUp6TXkFoxanRuH/k2I8kfBj3bQrfvJofbaQKcrsGPFmR+AEsxDiZ2fCQfZHuZS4t8JD5VtDXacTSbbZzqwiKHF0sdJIIzE8EXQ7OejK8UQ2nSUZMlVUzvwuAnhPgjOC9QCNpQwprSX2Hn5d8lvcxI+TDj7XWYxqbhIlRHxPLghKTMicIH/luwy3OpCP4769Hjmy4e2M6kjyUKjhrV7BvrBVZSVPSP0vuh3oZCPGZSRXl3JfelQGXrUNufxomZu/gLZM= |
0 commit comments