Skip to content

Upgrade to new maintance rules #197

New issue

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

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

Already on GitHub? # to your account

Merged
merged 19 commits into from
Feb 27, 2020
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
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

16 changes: 0 additions & 16 deletions .eslintrc.js

This file was deleted.

50 changes: 6 additions & 44 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,44 +1,6 @@
# Logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Jest
jest*

# ESLint
.eslintcache

package-lock.json
/.eslintcache
/.nyc_output
/coverage
/node_modules
npm-debug.log
/package-lock.json
167 changes: 149 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,157 @@
language: node_js

matrix:
include:
- node_js: '4'
- node_js: '6'
- node_js: '8'
- node_js: '10'
- node_js: '10'
env:
- DISABLE_TESTS=true
- LINTING=true
git:
# Minimize git history, but ensure to not break things:
# - Merging multiple PR's around same time may introduce a case where it's not
# the last merge commit that is to be tested
# - Aside of merge commit we need a previous commit to be able to detect a version switch
depth: 30

cache:
# Not relying on 'npm' shortcut, as per Travis docs it's the only 'node_modules' that it'll cache
directories:
- $HOME/.npm
- node_modules

branches:
only: # Do not build PR branches
# Release branches
- master
# Release tags
- /^v\d+\.\d+\.\d+$/ # Ensure to build release tags

sudo: false
stages:
- name: Test
if: tag IS NOT present
- name: Tag on Release
if: branch = master AND type = push
- name: Deploy
if: tag =~ ^v\d+\.\d+\.\d+$

env:
global:
- FORCE_COLOR=1 # Ensure colored output (color support is not detected in some cases)

# Ensure to install dependencies at their latest versions
install:
- travis_retry npm install
# Note: `npm update` has issues which we need to workaround:
# - There seems no way to update all project dependency groups in one run
# Hence different calls for prod and dev dependencies
# - The bigger depth, the longer update takes (-9999 as proposed in npm docs hangs the process).
# Therefore we keep at 3 which should ensure most of dependencies are at latest versions
# - Depth setting makes optional dependencies not optional (install error crashes process)
# Hence we skip install of optional dependencies completely, with --no-optional
# Note: this patch works only for npm@5+
# - npm documents --dev option for dev dependencies update, but it's only --save-dev that works
- npm update --depth 3 --no-optional --no-save
- npm update --depth 3 --save-dev --no-save

before_script:
# Fail build right after first script fails. Travis doesn't ensure that: https://github.com/travis-ci/travis-ci/issues/1066
# More info on below line: https://www.davidpashley.com/articles/writing-robust-shell-scripts/#idm5413512
- set -e
- git config --global user.email "platform@serverless.com"
- git config --global user.name "Serverless CI"

jobs:
include:
# In most cases it's best to configure one job per platform & Node.js version combination
# (job boot & setup takes ca 1 minute, one task run lasts ca few seconds)

script:
- npm test
# PR's from branches
# Ensure commit messages follow CC, and confirm on changelog in case of release PR's
- name: 'Prettier check updated, Lint updated, Commitlint, Changelog confirm (on release), Unit Tests - Node.js v12'
if: type = pull_request AND fork = false
node_js: 12
script:
- npm run prettier-check:updated
- npm run lint:updated
- npm run commitlint:pull-request
# If release PR, confirm we have a changelog
- |
tagName=`git diff -U0 master package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || :
if [ -n "$tagName" ];
then
npx dump-release-notes-from-cc-changelog $tagName
fi
- npm test

script:
- if [[ ! -z "$DISABLE_TESTS" && ! -z "$LINTING" ]]; then npm run lint; fi
# PR's from forks
# Do not validate commit messages,
# (if user didn't ensure CC, PR should be squash merged with a valid CC commit message)
- name: 'Prettier check updated, Lint updated, Unit Tests - Node.js v12'
if: type = pull_request AND fork = true
node_js: 12
script:
- npm run prettier-check:updated
- npm run lint:updated
- npm test

after_success:
- ./node_modules/jest/bin/jest.js --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
# master branch
- name: 'Unit Tests - Node.js v12'
if: type != pull_request
node_js: 12

- name: 'Unit Tests, Coverage - Node.js v13'
node_js: 13
script:
- npm run coverage
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

- name: 'Unit Tests - Node.js v10'
node_js: 10

- name: 'Unit Tests - Node.js v8'
node_js: 8

- name: 'Unit Tests - Node.js v6'
node_js: 6
before_install:
# npm@3 doesn't seem handle `--no-optional` option of `npm update` command.
# Upgrade npm to version which is distributed with Node.js v8
- npm i -g npm@6.4.1

- stage: Tag on Release
name: 'Tag on Release'
node_js: 12
env:
# GITHUB_TOKEN
- 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=
script:
- |
tagName=`git diff -U0 HEAD^ package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || :
if [ -n "$tagName" ];
then
git tag v$tagName
git push -q https://$GITHUB_TOKEN@github.com/serverless/test --tags
fi

# version tag
- stage: Deploy
env:
# GITHUB_TOKEN
- 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=
node_js: 12
script: skip
# Ensure to fail build if deploy fails, Travis doesn't ensure that: https://github.com/travis-ci/travis-ci/issues/921
before_deploy:
- set -e
# Remove eventual old npm logs
- rm -rf ~/.npm/_logs
after_deploy:
- |
# npm creates log only on failure
if [ -d ~/.npm/_logs ]
then
# Undocumented way to force Travis build to fail
travis_terminate 1
fi
- npx github-release-from-cc-changelog $TRAVIS_TAG
deploy:
edge: true # Workaorund Travis regression: https://travis-ci.community/t/missing-api-key-when-deploying-to-github-releases/5761
provider: npm
email: services@serverless.com
on:
tags: true
api_key:
secure: GxHxrCEjTIwzcHW6EEJm6/6Lwm3H+aTmOSrDHgwMwiwg98fTqQ2pD1L06CppSiaq9T33RPEim4kuBHIpTtmiJwVVQMIdEQheUfE05OwWBWcOEta2h3ahbGPX8iA48aVdRuXD4/Vpiho2a7zPuVBIsgDH1OzLO/WiYx10afzqlOOvwBITOkRy6eKD/I/Omxid6KjvMwfrHYScWvL9JTo7aV0MhFL4MV+9fN3nutF5+wSSIjfkzTmhxKmHEi/nlcuFCVS8yfutX7sMLugxNilqbv815SbjHMrkgZwkzrnalTbF3B2ohV8zYcuCrUEwDPRlrWbmoFMGJdcuXE90HPiHagn2Olv5e28f5ToQGFzwzYWrAO2Rc4l6gyUn8uwonN/xrK6N8ucEti9b/vzQz2/bH3rB+S++ZPiYAUcgZ8eLUp6TXkFoxanRuH/k2I8kfBj3bQrfvJofbaQKcrsGPFmR+AEsxDiZ2fCQfZHuZS4t8JD5VtDXacTSbbZzqwiKHF0sdJIIzE8EXQ7OejK8UQ2nSUZMlVUzvwuAnhPgjOC9QCNpQwprSX2Hn5d8lvcxI+TDj7XWYxqbhIlRHxPLghKTMicIH/luwy3OpCP4769Hjmy4e2M6kjyUKjhrV7BvrBVZSVPSP0vuh3oZCPGZSRXl3JfelQGXrUNufxomZu/gLZM=
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Serverless
Copyright (c) 2020 Serverless

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
44 changes: 44 additions & 0 deletions RELEASE_PROCESS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Release process

## Semi-automation

This project relies on [semantic commit messages](https://www.conventionalcommits.org/en/v1.0.0-beta.4/#summary) which allows to streamline the release process (versioning and changelog generation is automated)

See proposed [Commit Message Guidelines](https://docs.google.com/document/d/1hKUs3qt_aVp_PBI1UqvfaIqKma3jAJimEoGCRGGbOqs/edit#)

In PR's as coming from forks (community contributions) while its welcome, we do not require to follow semantic commit messages. Yet, such PR is expected to be squash merged by project member with single semantic commit message.

PR's comming from branches have commit messages validated with [commmitlint](https://commitlint.js.org/#/)

## Release flow

Releases are triggered manually by preparing a release PR's as follows

1. Create a `release` branch (should derive from current `master` state)
2. Bump version ranges of _all_ dependencies to latest supported versions (e.g. if latest version of a dependency is `2.3.5` and range in a `package.json` is `^2.2.4` then it should be updated to `^2.3.5`)
_Note: Unfortunately there seems no reliable utility to automate that (there's a [request at `npm-check-updates`](https://github.com/tjunnone/npm-check-updates/issues/581))
If you handle installation of dependencies through [npm-cross-link](https://github.com/medikoo/npm-cross-link#npm-cross-link) then [`--bump-deps`](https://github.com/medikoo/npm-cross-link#general-options) option will bump version ranges as expected_
3. Commit eventual dependency version updates with following commit message:
`chore: Bump dependencies`
4. Run `npm run prepare-release` command.
_It'll automatically bump version in `package.json` to expected one (by inspecting changes since previous release) and will generate new changelog entry._
5. If needed improve generated changelog entry in `CHANGELOG.md`
6. Commit `package.json` and `CHANGELOG.md` changes with following commit message:
`chore: Release`
**Note: For automation purpose it is important that it's the last commit in the PR**
7. Push branch upstream and create a PR.
_Release PR's are automatically detected in CI by fact of `version` in `package.json` file being changed in last commit. In context of that build, existence of new version changelog entry (in `CHANGELOG.md`) is validated._
8. After PR is accepted by CI and one of the reviewers, merge it via _"Rebase and merge"_ option

Further actions are automated in CI context:

8. `master` CI build detects that release PR was merged (by fact that it covers change of `version` field in `package.json` file). Having that (after successufl tests pass) version tag is created and pushed to the repository.
9. _tag_ CI build, publishes new version to npm, also it retrieves release notes from CHANGELOG.md and publishes them to GitHub.

### Updating release notes for already published versions

Improvements to release notes can be done at anytime to any already published version:

1. Update `CHANGELOG.md` with desired changes (ensure they'd also end in `master`)
2. Push updated release notes to GitHub by running:
`npx github-release-from-cc-changelog <version>`
23 changes: 23 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

module.exports = {
rules: {
'body-leading-blank': [2, 'always'],
'body-max-line-length': [2, 'always', 72],
'footer-leading-blank': [2, 'always'],
'footer-max-line-length': [2, 'always', 72],
'header-max-length': [2, 'always', 72],
'scope-case': [2, 'always', 'start-case'],
'scope-enum': [2, 'always', ['']],
'subject-case': [2, 'always', 'sentence-case'],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [
2,
'always',
['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'style', 'test'],
],
},
};
28 changes: 15 additions & 13 deletions deploy/googleDeploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,23 @@ class GoogleDeploy {
monitorDeployment,
uploadArtifacts,
updateDeployment,
cleanupDeploymentBucket);
cleanupDeploymentBucket
);

this.hooks = {
'before:deploy:deploy': () => BbPromise.bind(this)
.then(this.validate)
.then(this.setDefaults),

'deploy:deploy': () => BbPromise.bind(this)
.then(this.createDeployment)
.then(this.setDeploymentBucketName)
.then(this.uploadArtifacts)
.then(this.updateDeployment),

'after:deploy:deploy': () => BbPromise.bind(this)
.then(this.cleanupDeploymentBucket),
'before:deploy:deploy': () =>
BbPromise.bind(this)
.then(this.validate)
.then(this.setDefaults),

'deploy:deploy': () =>
BbPromise.bind(this)
.then(this.createDeployment)
.then(this.setDeploymentBucketName)
.then(this.uploadArtifacts)
.then(this.updateDeployment),

'after:deploy:deploy': () => BbPromise.bind(this).then(this.cleanupDeploymentBucket),
};
}
}
Expand Down
Loading