Skip to content

Commit

Permalink
CI/CD: Integrate with Travis CI & semantic-release (#12)
Browse files Browse the repository at this point in the history
* Initial configuration of Travis CI

It's time to get with the program and start using CI processes with this
project. It would have helped avoid some silly mistakes that I have made
thus far in regards to believing I'm ready to publish our
project/package. This commit provides the initial configuration for the
Travis CI integration/hook. Note that Travis CI has already been enabled
for this repo. I'm sure moving forward we will evolve our Travis CI
configuration/process.
	new file:   .travis.yml

* Build before we run tests in the 'prepublish' script

Per NPM docs the 'prepublish' script is ran after a local install. See:
https://docs.npmjs.com/misc/scripts. We modify our 'prepublish' script
to build before we run tests. Prior, if someone cloned our repo, would
fail the linting part of our tests as imports from 'dist' made by our
demo wouldn't resolve as the 'dist' folder wouldn't have been built yet.
Note that the 'prepublish' script will still fail after someone cloned
our repo if they don't have a Google API key set as an environment
variable. But our CI does! :)

We also have changed the CI build lifecycle to not run the 'prepublish'
script during dependency install. This ought to help reduce the build
time by not duplicating script runs during different parts of the CI
build lifecycle.
	modified:   .travis.yml
	modified:   package.json

* Add Travis CI build badge to README.md

Because badges! w00t! My first badge. :)
	modified:   README.md

* Use latest Node 8 release with Travis CI build

Previously I used the latest Node 6 release with the Travis CI build as
this was what I had running locally. I realized that what we would
deploy would run on the latest Node so I upgrade locally to the latest
Node which is 8. Also 8 is the most recent Node version to be under LTS.
As a result I've now changed the Travis CI build to use Node 8 as well
to match what we will deploy under and what we ought to be using locally
for development.
	modified:   .travis.yml

* Build: Setup CI/CD to automate package publishing with semantic-release

This commit sets up our CI/CD pipeline to automate our package
publishing with the `semantic-release` package. We have configured
`semantic-release` to use the ESLint rules for writing commit messages
as they seem simpler than the default Angular rules. Docs for writing
ESLint commit messages can be found here:
https://eslint.org/docs/developer-guide/contributing/pull-requests#step-2-make-your-changes
	modified:   .travis.yml
	modified:   package.json
	modified:   yarn.lock
  • Loading branch information
Giners authored Dec 11, 2017
1 parent 9514a1d commit 81bed66
Show file tree
Hide file tree
Showing 4 changed files with 876 additions and 25 deletions.
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: node_js
node_js:
- "8"
cache: yarn
install:
# Per docs the 'prepublish' script is ran after a local install:
# https://docs.npmjs.com/misc/scripts
#
# Have yarn install our dependencies and not run any scripts after install with the
# '--ignore-scripts' flag. This will help us reduce the CI build time by not running the tests
# multiple times. In the 'script' step in the CI build lifecycle we can just run the 'prepublish'
# script.
- yarn install --ignore-scripts
script:
- yarn prepublish
after_success:
- yarn semantic-release
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# MUIPlacesAutocomplete
[![Travis CI](https://img.shields.io/travis/Giners/mui-places-autocomplete/master.svg)](https://travis-ci.org/Giners/mui-places-autocomplete/builds)

# Features
* Easy to use input for searching for places
* Place suggestions displayed in realtime
Expand All @@ -9,15 +12,17 @@
To install this component run the following command:

```
yarn add mui-places-autocomplete
yarn add mui-places-autocomplete --ignore-scripts
```

or

```
npm install mui-places-autocomplete --save
npm install mui-places-autocomplete --save --ignore-scripts
```

Note that if you exclude the `--ignore-scripts` option when installing a package then the `prepublish` script in `package.json` is ran after installing locally. Tests are ran as part of the `prepublish` script and they will fail if you haven't yet set a Google API key to the enivronment variable `GOOGLE_API_KEY` (see setup section).

# Setup
This component relies on some basic setup before usage. It makes use of services provided by Google. To properly make use of the services you will need to do three things:
1. Enable the Google Places API Web Service
Expand Down
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mui-places-autocomplete",
"version": "1.0.3",
"version": "0.0.0-development",
"description": "Material-UI React component that provides suggestions/autocompletes places using the Google Places API",
"repository": {
"type": "git",
Expand All @@ -15,7 +15,17 @@
"test:eslint": "eslint --max-warnings 0 --cache --ext .js,.jsx src test demo",
"demo": "webpack-dev-server --config demo/webpack.config.js --content-base dist --hot",
"build": "rm -rf dist/ && webpack",
"prepublish": "yarn test && yarn build"
"prepublish": "yarn build && yarn test",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"release": {
"branch": "master",
"analyzeCommits": {
"preset": "eslint"
},
"generateNotes": {
"preset": "eslint"
}
},
"dependencies": {
"autosuggest-highlight": "^3.1.0",
Expand All @@ -37,6 +47,7 @@
"babel-preset-react": "^6.24.1",
"chai": "^4.1.2",
"chai-jest-snapshot": "^1.3.0",
"conventional-changelog-eslint": "^0.2.1",
"enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.2",
"enzyme-to-json": "^3.1.4",
Expand All @@ -55,6 +66,7 @@
"mocha": "^4.0.1",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"semantic-release": "^8.2.0",
"webpack": "^3.7.1",
"webpack-dev-server": "^2.9.1",
"webpack-node-externals": "^1.6.0"
Expand Down
Loading

0 comments on commit 81bed66

Please sign in to comment.