-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1: Bootstrap project.
- Loading branch information
Showing
10 changed files
with
6,187 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,279 @@ | ||
# https://circleci.com/docs/2.1/language-javascript/ | ||
version: 2.1 | ||
commands: | ||
extract-changelog-version: | ||
steps: | ||
- run: | ||
name: extract changelog version | ||
working_directory: ~/json-transform-stream | ||
command: | | ||
VERSION=$(head -n1 CHANGELOG.md | grep -o '\([0-9]\+\.\)\{2\}[0-9]\+') | ||
echo "export VERSION=${VERSION}" >> $BASH_ENV | ||
echo "export CHANGELOG_VERSION=${VERSION}" >> $BASH_ENV | ||
echo "changelog version: ${VERSION}" | ||
extract-package-json-version: | ||
steps: | ||
- run: | ||
name: extract package.json version | ||
working_directory: ~/json-transform-stream | ||
command: | | ||
PACKAGE_JSON_VERSION=$(node -e "console.info(require('./package').version)") | ||
echo "export PACKAGE_JSON_VERSION=${PACKAGE_JSON_VERSION}" >> $BASH_ENV | ||
echo "package.json version: ${PACKAGE_JSON_VERSION}" | ||
extract-published-version: | ||
steps: | ||
- run: | ||
name: extract latest published version | ||
working_directory: ~/json-transform-stream | ||
command: | | ||
LIVE_VERSION=$(npm show @haensl/json-transform-stream version || echo '0.0.0') | ||
echo "export LIVE_VERSION=${LIVE_VERSION}" >> ${BASH_ENV} | ||
echo "latest published version: ${LIVE_VERSION}" | ||
extract-versions: | ||
steps: | ||
- extract-package-json-version | ||
- extract-changelog-version | ||
- extract-published-version | ||
|
||
init: | ||
steps: | ||
- run: | ||
name: update npm | ||
command: sudo npm install -g npm@latest | ||
|
||
prepare-repo: | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
keys: | ||
- json-transform-stream-dependencies-{{ checksum "package.json" }} | ||
- run: | ||
name: install dependencies | ||
command: npm install | ||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: json-transform-stream-dependencies-{{ checksum "package.json" }} | ||
- extract-versions | ||
|
||
create-test-project: | ||
steps: | ||
- run: | ||
working_directory: /tmp | ||
name: create test application | ||
command: | | ||
mkdir -p test-app && cd test-app && npm init -y | ||
bundle-test-setup: | ||
steps: | ||
- attach_workspace: | ||
at: ~/json-transform-stream | ||
- create-test-project | ||
- run: | ||
name: test setup | ||
working_directory: /tmp/test-app | ||
command: | | ||
npm i -D jest | ||
npm i -S ~/json-transform-stream/haensl-json-transform-stream.tgz | ||
cp ~/json-transform-stream/json-transform-stream.package.test.js ./ | ||
package-test-setup: | ||
steps: | ||
- attach_workspace: | ||
at: ~/json-transform-stream | ||
- create-test-project | ||
- extract-versions | ||
- run: | ||
name: test setup | ||
working_directory: /tmp/test-app | ||
command: | | ||
npm i -D jest | ||
npm i -S @haensl/json-transform-stream@${VERSION} | ||
cp ~/json-transform-stream/json-transform-stream.package.test.js ./ | ||
package-information: | ||
steps: | ||
- run: | ||
name: install tree | ||
command: sudo apt-get -y install tree | ||
- run: | ||
name: gather bundle information | ||
command: | | ||
npm info @haensl/json-transform-stream@${VERSION} > ./bundle.info | ||
tree -s node_modules/@haensl/json-transform-stream >> ./bundle.info | ||
- store_artifacts: | ||
path: bundle.info | ||
|
||
workflows: | ||
version: 2 | ||
default: | ||
when: always | ||
jobs: | ||
- lint | ||
- test | ||
- ensure-versioned-correctly | ||
- bundle: | ||
requires: | ||
- lint | ||
- test | ||
- bundle-test: | ||
requires: | ||
- bundle | ||
- publish: | ||
requires: | ||
- ensure-versioned-correctly | ||
- bundle-test | ||
filters: | ||
branches: | ||
only: master | ||
- package-test: | ||
requires: | ||
- publish | ||
- publish-github-release: | ||
requires: | ||
- package-test | ||
|
||
jobs: | ||
lint: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: ~/json-transform-stream | ||
steps: | ||
- init | ||
- prepare-repo | ||
- run: | ||
name: create test-results-folder | ||
command: mkdir -p test-results/eslint | ||
- run: | ||
name: lint | ||
command: npm run lint:ci | ||
- store_test_results: | ||
path: test-results | ||
|
||
test: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: ~/json-transform-stream | ||
steps: | ||
- init | ||
- prepare-repo | ||
- run: | ||
name: unit tests | ||
command: npm run test:ci | ||
- store_test_results: | ||
path: test-results | ||
|
||
ensure-versioned-correctly: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: ~/json-transform-stream | ||
steps: | ||
- init | ||
- prepare-repo | ||
- extract-versions | ||
- run: | ||
name: changelog matches package.json | ||
command: | | ||
test ${PACKAGE_JSON_VERSION} = ${CHANGELOG_VERSION} | ||
- run: | ||
name: pacakge.json greater than live | ||
command: | | ||
node \<<VERSION_CHECK | ||
const pkgVersion = require('./package').version | ||
.split('.') | ||
.map((i) => parseInt(i, 10)); | ||
const liveVersion = process.env.LIVE_VERSION | ||
.split('.') | ||
.map((i) => parseInt(i, 10)); | ||
const isGreater = pkgVersion.reduce((isGreater, part, i) => { | ||
return isGreater || (part > liveVersion[i]); | ||
}, false); | ||
if (!isGreater) { | ||
process.exit(1); | ||
} | ||
VERSION_CHECK | ||
bundle: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: ~/json-transform-stream | ||
steps: | ||
- init | ||
- prepare-repo | ||
- run: | ||
name: generate tarball | ||
command: | | ||
npm pack | ||
mv haensl-json-transform-stream-${VERSION}.tgz haensl-json-transform-stream.tgz | ||
- store_artifacts: | ||
path: haensl-json-transform-stream.tgz | ||
- persist_to_workspace: | ||
root: ./ | ||
paths: | ||
- CHANGELOG.md | ||
- index.js | ||
- README.md | ||
- LICENSE | ||
- package.json | ||
- package-lock.json | ||
- haensl-json-transform-stream.tgz | ||
- json-transform-stream.package.test.js | ||
- .npmignore | ||
|
||
bundle-test: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: /tmp/test-app | ||
steps: | ||
- init | ||
- bundle-test-setup | ||
- run: | ||
name: test node.js module | ||
command: node_modules/.bin/jest --runInBand | ||
|
||
publish: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: ~/json-transform-stream | ||
steps: | ||
- attach_workspace: | ||
at: ~/json-transform-stream | ||
- init | ||
- run: | ||
name: setup npm registry token | ||
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | ||
- run: | ||
name: publish node module | ||
command: npm publish | ||
|
||
package-test: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: /tmp/test-app | ||
steps: | ||
- init | ||
- package-test-setup | ||
- run: | ||
name: test node.js module | ||
command: node_modules/.bin/jest --runInBand | ||
|
||
publish-github-release: | ||
docker: | ||
- image: cibuilds/github | ||
steps: | ||
- attach_workspace: | ||
at: ~/json-transform-stream | ||
- extract-changelog-version | ||
- run: | ||
name: publish github release | ||
working_directory: ~/json-transform-stream | ||
command: | | ||
cp ./haensl-json-transform-stream.tgz ./haensl-json-transform-stream-${VERSION}.tgz | ||
CHANGES=$(awk "/## ${VERSION}/,/^$/" CHANGELOG.md) | ||
echo "Publishing release v${VERSION} to Github.\nChanges:" | ||
echo $CHANGES | ||
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete -n "v${VERSION}" -b "${CHANGES}" "v${VERSION}" ./haensl-json-transform-stream-${VERSION}.tgz | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
test-results/ | ||
node_modules/ | ||
*.token.png | ||
deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
__fixtures__/ | ||
test-results/ | ||
*.md | ||
.* | ||
*.test.* | ||
deploy | ||
*.token.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## 1.0.0 | ||
* [#1: Bootstrap project.](https://github.com/haensl/json-transform-stream/issues/1) |
Oops, something went wrong.