From 31f974ea6dac5ce847c8e84fdc42673d5255814c Mon Sep 17 00:00:00 2001 From: HP Dietz Date: Tue, 2 Feb 2021 18:39:26 +0100 Subject: [PATCH 1/3] Migrate to CircleCI. --- .circleci/config.yml | 275 +++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 22 ---- CHANGELOG.md | 3 + README.md | 2 +- package.json | 2 +- 5 files changed, 280 insertions(+), 24 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 .travis.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..679d491 --- /dev/null +++ b/.circleci/config.yml @@ -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 \< 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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f6e2900..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: node_js -node_js: - - 'lts/*' - - 'node' - - '6.9.4' - -stages: - - test - - name: deploy - if: branch = master - -jobs: - include: - - stage: test - script: npm test - - stage: test - script: npm run lint - - stage: deploy - deploy: - provider: npm - api_key: $NPM_API_KEY - email: $NPM_MAIL diff --git a/CHANGELOG.md b/CHANGELOG.md index dffba55..dde3bdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.4.0 +* [#22: Migrate to CircleCI.](https://github.com/haensl/gulp-minify-inline-json/issues/22) + ## 1.3.5 * [#19: Update dependencies.](https://github.com/haensl/gulp-minify-inline-json/issues/19) * Internalize eslint configuration into `package.json`. diff --git a/README.md b/README.md index cdf7cd4..958c32d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![NPM](https://nodei.co/npm/gulp-minify-inline-json.png?downloads=true)](https://nodei.co/npm/gulp-minify-inline-json/) [![npm version](https://badge.fury.io/js/gulp-minify-inline-json.svg)](http://badge.fury.io/js/gulp-minify-inline-json) -[![Build Status](https://travis-ci.org/haensl/gulp-minify-inline-json.svg?branch=master)](https://travis-ci.org/haensl/gulp-minify-inline-json) +[![CircleCI](https://circleci.com/gh/haensl/gulp-minify-inline-json.svg?style=svg)](https://circleci.com/gh/haensl/gulp-minify-inline-json) Minifies inline `