From f49330cf1a89d1963e41e6fa2a301766646e5e53 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Thu, 4 Apr 2019 22:28:23 +0200 Subject: [PATCH] chore: add circleci --- .circleci/config.yml | 173 +++++++++++++++++++++++++++++++++++++++++++ .npmignore | 2 +- package.json | 3 +- scripts/publish.sh | 10 +++ 4 files changed, 185 insertions(+), 3 deletions(-) create mode 100644 .circleci/config.yml create mode 100755 scripts/publish.sh diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..b7f13c4 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,173 @@ +version: 2 + +aliases: + - &defaults + working_directory: ~/verdaccio + - &node8_executor + docker: + - image: circleci/node:8 + - &node10_executor + docker: + - image: circleci/node:10 + - &node11_executor + docker: + - image: circleci/node:11.10.1 + - &default_executor + <<: *node10_executor + - &repo_key + repo-{{ .Branch }}-{{ .Revision }} + - &coverage_key + coverage-{{ .Branch }}-{{ .Revision }} + - &base_config_key + base-config-{{ .Branch }}-{{ .Revision }} + - &yarn_cache_key + yarn-sha-{{ checksum "yarn.lock" }} + - &restore_repo + attach_workspace: + at: ~/verdaccio + - &ignore_non_dev_branches + filters: + tags: + only: /.*/ + branches: + ignore: + - gh-pages + - l10n_master + - /release\/.*/ + - &execute_on_release + filters: + tags: + only: /v?[0-9]+(\.[0-9]+)+([-+\.][0-9a-zA-Z]+)*/ + branches: + ignore: + - /.*/ + +jobs: + prepare: + <<: *defaults + <<: *default_executor + steps: + - checkout + - restore_cache: + key: *base_config_key + - run: + name: 'Base environment setup' + command: | + git config --global user.email "verdacciobot@users.noreply.github.com" + git config --global user.name "Verdaccio bot for Deployments" + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc + echo "machine github.com login verdacciobot password $GITHUB_TOKEN" > ~/.netrc + - save_cache: + key: *base_config_key + paths: + - ~/.npmrc + - ~/.gitconfig + - ~/.netrc + - restore_cache: + key: *yarn_cache_key + - run: + name: Install Js dependencies + command: yarn install --no-progress --registry https://registry.verdaccio.org + - run: + name: Prepare CI + command: yarn lint + - run: + name: Build project + command: yarn build + - save_cache: + key: *yarn_cache_key + paths: + - ~/.yarn + - ~/.cache/yarn + - node_modules + - persist_to_workspace: + root: ~/verdaccio + paths: + - ./* + + test_node8: + <<: *defaults + <<: *node8_executor + steps: + - *restore_repo + - run: + name: Test with Node 8 + command: | + yarn test + test_node10: + <<: *defaults + <<: *node10_executor + steps: + - *restore_repo + - run: + name: Test with Node 10 + command: | + yarn test + + test_node11: + <<: *defaults + <<: *node11_executor + steps: + - *restore_repo + - run: + name: Test with Node 11 + command: | + yarn run test + coverage: + <<: *defaults + <<: *default_executor + steps: + - *restore_repo + - restore_cache: + key: *coverage_key + - run: + name: Publish coverage + command: yarn run coverage:publish + - store_artifacts: + path: coverage/clover.xml + prefix: tests + - store_artifacts: + path: coverage + prefix: coverage + - store_test_results: + path: coverage/clover.xml + + publish_package: + <<: *defaults + <<: *default_executor + steps: + - *restore_repo + - restore_cache: + key: *base_config_key + - run: + name: Publish + command: scripts/publish.sh + +workflows: + version: 2 + workflow: + jobs: + - prepare: + <<: *ignore_non_dev_branches + - test_node8: + requires: + - prepare + <<: *ignore_non_dev_branches + - test_node10: + requires: + - prepare + <<: *ignore_non_dev_branches + - test_node11: + requires: + - prepare + <<: *ignore_non_dev_branches + - coverage: + requires: + - test_node8 + - test_node10 + - test_node11 + <<: *ignore_non_dev_branches + - publish_package: + requires: + - coverage + <<: *execute_on_release diff --git a/.npmignore b/.npmignore index f5534d6..93caabf 100644 --- a/.npmignore +++ b/.npmignore @@ -3,5 +3,5 @@ /* !/static/* !index.js - +!README.md diff --git a/package.json b/package.json index 999b924..a707080 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@verdaccio/ui-theme", - "version": "0.0.1", + "version": "0.0.2", "description": "Verdaccio User Interface", "author": { "name": "Verdaccio Core Team" @@ -104,7 +104,6 @@ "test:clean": "npx jest --clearCache", "test": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC FORCE_COLOR=1 jest --config ./jest.config.js --maxWorkers 2 --passWithNoTests", "test:size": "bundlesize", - "pre:ci": "npm run lint && npm run build:webui", "lint": "npm run flow && npm run lint:js && npm run lint:css", "lint:js": "eslint .", "lint:css": "stylelint 'src/webui/**/styles.js'", diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 0000000..620586e --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Get the last tag from GitHub +lastTag=$(git describe --tags $(git rev-list --tags --max-count=1)) + +# Print it to the console for verification +echo "Bumping version to new tag: ${lastTag}" + +# Publish to NPM +npm publish --registry https://registry.npmjs.org/