Skip to content

Commit 81bed66

Browse files
authored
CI/CD: Integrate with Travis CI & semantic-release (#12)
* 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
1 parent 9514a1d commit 81bed66

File tree

4 files changed

+876
-25
lines changed

4 files changed

+876
-25
lines changed

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: node_js
2+
node_js:
3+
- "8"
4+
cache: yarn
5+
install:
6+
# Per docs the 'prepublish' script is ran after a local install:
7+
# https://docs.npmjs.com/misc/scripts
8+
#
9+
# Have yarn install our dependencies and not run any scripts after install with the
10+
# '--ignore-scripts' flag. This will help us reduce the CI build time by not running the tests
11+
# multiple times. In the 'script' step in the CI build lifecycle we can just run the 'prepublish'
12+
# script.
13+
- yarn install --ignore-scripts
14+
script:
15+
- yarn prepublish
16+
after_success:
17+
- yarn semantic-release

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# MUIPlacesAutocomplete
2+
[![Travis CI](https://img.shields.io/travis/Giners/mui-places-autocomplete/master.svg)](https://travis-ci.org/Giners/mui-places-autocomplete/builds)
3+
14
# Features
25
* Easy to use input for searching for places
36
* Place suggestions displayed in realtime
@@ -9,15 +12,17 @@
912
To install this component run the following command:
1013

1114
```
12-
yarn add mui-places-autocomplete
15+
yarn add mui-places-autocomplete --ignore-scripts
1316
```
1417

1518
or
1619

1720
```
18-
npm install mui-places-autocomplete --save
21+
npm install mui-places-autocomplete --save --ignore-scripts
1922
```
2023

24+
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).
25+
2126
# Setup
2227
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:
2328
1. Enable the Google Places API Web Service

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mui-places-autocomplete",
3-
"version": "1.0.3",
3+
"version": "0.0.0-development",
44
"description": "Material-UI React component that provides suggestions/autocompletes places using the Google Places API",
55
"repository": {
66
"type": "git",
@@ -15,7 +15,17 @@
1515
"test:eslint": "eslint --max-warnings 0 --cache --ext .js,.jsx src test demo",
1616
"demo": "webpack-dev-server --config demo/webpack.config.js --content-base dist --hot",
1717
"build": "rm -rf dist/ && webpack",
18-
"prepublish": "yarn test && yarn build"
18+
"prepublish": "yarn build && yarn test",
19+
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
20+
},
21+
"release": {
22+
"branch": "master",
23+
"analyzeCommits": {
24+
"preset": "eslint"
25+
},
26+
"generateNotes": {
27+
"preset": "eslint"
28+
}
1929
},
2030
"dependencies": {
2131
"autosuggest-highlight": "^3.1.0",
@@ -37,6 +47,7 @@
3747
"babel-preset-react": "^6.24.1",
3848
"chai": "^4.1.2",
3949
"chai-jest-snapshot": "^1.3.0",
50+
"conventional-changelog-eslint": "^0.2.1",
4051
"enzyme": "^3.1.0",
4152
"enzyme-adapter-react-16": "^1.0.2",
4253
"enzyme-to-json": "^3.1.4",
@@ -55,6 +66,7 @@
5566
"mocha": "^4.0.1",
5667
"react": "^16.0.0",
5768
"react-dom": "^16.0.0",
69+
"semantic-release": "^8.2.0",
5870
"webpack": "^3.7.1",
5971
"webpack-dev-server": "^2.9.1",
6072
"webpack-node-externals": "^1.6.0"

0 commit comments

Comments
 (0)