-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from haensl/22
#22: Migrate to CircleCI.
- Loading branch information
Showing
7 changed files
with
377 additions
and
27 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,275 @@ | ||
# https://circleci.com/docs/2.1/language-javascript/ | ||
version: 2.1 | ||
commands: | ||
extract-changelog-version: | ||
steps: | ||
- run: | ||
name: extract changelog version | ||
working_directory: ~/gulp-minify-inline-json | ||
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: ~/gulp-minify-inline-json | ||
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: ~/gulp-minify-inline-json | ||
command: | | ||
LIVE_VERSION=$(npm show gulp-minify-inline-json version || true) | ||
[ -z "${LIVE_VERSION}" ] && LIVE_VERSION='0.0.0' | ||
echo "export LIVE_VERSION=${LIVE_VERSION}" >> ${BASH_ENV} | ||
echo "latest published version: ${LIVE_VERSION}" | ||
extract-versions: | ||
steps: | ||
- extract-changelog-version | ||
- extract-package-json-version | ||
- extract-published-version | ||
|
||
init: | ||
steps: | ||
- run: | ||
name: update npm | ||
command: sudo npm install -g npm@latest | ||
|
||
prepare-repo: | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
keys: gulp-minify-inline-json-dependencies-{{ checksum "package-lock.json" }} | ||
- run: | ||
name: install dependencies | ||
command: npm i | ||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: gulp-minify-inline-json-dependencies-{{ checksum "package-lock.json" }} | ||
- extract-versions | ||
|
||
create-test-project: | ||
parameters: | ||
project_name: | ||
description: project name | ||
type: string | ||
default: test-app | ||
steps: | ||
- run: | ||
working-directory: /tmp | ||
name: create test application | ||
command: | | ||
mkdir /tmp/<< parameters.project_name >> | ||
cd /tmp/<< parameters.project_name >> && npm init -y && echo "Created package.json" && cat package.json | ||
package-information: | ||
steps: | ||
- run: | ||
name: install tree | ||
command: sudo apt-get -y install tree | ||
- run: | ||
name: gather bundle information | ||
command: | | ||
npm info gulp-minify-inline-json@${VERSION} > ./bundle.info | ||
tree -s node_modules/gulp-minify-inline-json >> ./bundle.info | ||
- store_artifacts: | ||
path: bundle.info | ||
|
||
workflows: | ||
version: 2 | ||
default: | ||
when: always | ||
jobs: | ||
- lint | ||
- test | ||
- bundle: | ||
requires: | ||
- lint | ||
- test | ||
- bundle-test: | ||
requires: | ||
- bundle | ||
- ensure-versioned-correctly: | ||
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: ~/gulp-minify-inline-json | ||
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: ~/gulp-minify-inline-json | ||
steps: | ||
- init | ||
- prepare-repo | ||
- run: | ||
name: unit tests | ||
command: npm run test:ci | ||
- store_test_results: | ||
path: test-results | ||
|
||
bundle: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: ~/gulp-minify-inline-json | ||
steps: | ||
- init | ||
- prepare-repo | ||
- extract-versions | ||
- run: | ||
name: pack | ||
environment: | ||
NODE_ENV: 'production' | ||
command: | | ||
npm pack | ||
mv gulp-minify-inline-json-${VERSION}.tgz gulp-minify-inline-json.tgz | ||
- store_artifacts: | ||
path: gulp-minify-inline-json.tgz | ||
- persist_to_workspace: | ||
root: ./ | ||
paths: | ||
- CHANGELOG.md | ||
- lib | ||
- README.md | ||
- LICENSE | ||
- package.json | ||
- package-lock.json | ||
- .npmignore | ||
- gulp-minify-inline-json.tgz | ||
|
||
bundle-test: | ||
docker: | ||
- image: circleci/node:lts | ||
steps: | ||
- init | ||
- attach_workspace: | ||
at: ~/gulp-minify-inline-json | ||
- extract-versions | ||
- create-test-project | ||
- run: | ||
name: install module | ||
working_directory: /tmp/test-app | ||
command: | | ||
npm i -S ~/gulp-minify-inline-json/gulp-minify-inline-json.tgz | ||
- run: | ||
name: test module exports function | ||
working_directory: /tmp/test-app | ||
command: | | ||
node -e "const gulpMinifyInlineJson = require('gulp-minify-inline-json'); const assert = require('assert').strict; assert.deepEqual(typeof gulpMinifyInlineJson, 'function');" | ||
ensure-versioned-correctly: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: ~/gulp-minify-inline-json | ||
steps: | ||
- init | ||
- attach_workspace: | ||
at: ~/gulp-minify-inline-json | ||
- 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 | ||
publish: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: ~/gulp-minify-inline-json | ||
steps: | ||
- init | ||
- attach_workspace: | ||
at: ~/gulp-minify-inline-json | ||
- run: | ||
name: setup npm registry token | ||
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | ||
- run: | ||
name: publish node module | ||
command: npm publish --access public | ||
|
||
package-test: | ||
docker: | ||
- image: circleci/node:lts | ||
steps: | ||
- init | ||
- create-test-project | ||
- run: | ||
name: install module | ||
working_directory: /tmp/test-app | ||
command: | | ||
npm i -S gulp-minify-inline-json | ||
- run: | ||
name: test module exports function | ||
working_directory: /tmp/test-app | ||
command: | | ||
node -e "const gulpMinifyInlineJson = require('gulp-minify-inline-json'); const assert = require('assert').strict; assert.deepEqual(typeof gulpMinifyInlineJson, 'function');" | ||
- package-information | ||
|
||
publish-github-release: | ||
docker: | ||
- image: cibuilds/github | ||
steps: | ||
- attach_workspace: | ||
at: ~/gulp-minify-inline-json | ||
- extract-changelog-version | ||
- run: | ||
name: publish github release | ||
working_directory: ~/gulp-minify-inline-json | ||
command: | | ||
cp ./gulp-minify-inline-json.tgz ./gulp-minify-inline-json-${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}" ./gulp-minify-inline-json-${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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.* | ||
*.md | ||
*.config.js | ||
test/ | ||
CHANGELOG.md | ||
test-results/ |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.