diff --git a/.circleci/config.yml b/.circleci/config.yml index 82e28d8cf..5fce2f672 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,14 +4,11 @@ defaults: &defaults working_directory: ~/repo docker: - image: circleci/node:latest - # environment variables for all commands executed in the primary container - # environment: - # JEST_JUNIT_OUTPUT: reports/junit/js-test-results.xml - # COVERALLS_SERVICE_NAME: circleci - # COVERALLS_SERVICE_JOB_ID: $CIRCLE_BUILD_NUM jobs: - setup: + + # Run on successful merge/commit to vNext + test-merge: <<: *defaults steps: - checkout @@ -24,41 +21,43 @@ jobs: paths: - node_modules key: v1-dependencies-{{ checksum "package.json" }} - # - persist_to_workspace: - # root: ~/repo - # paths: . - # test-merge: - # <<: *defaults - # steps: - # - attach_workspace: - # at: ~/repo - # - run: - # name: "JavaScript Test Suite" - # environment: - # JEST_JUNIT_OUTPUT: reports/junit/js-test-results.xml - # COVERALLS_SERVICE_NAME: circleci - # COVERALLS_SERVICE_JOB_ID: $CIRCLE_BUILD_NUM - # command: npm run test:ci - # # Store our test results + Output - # - store_test_results: - # path: reports/junit - # - store_artifacts: - # path: reports/junit - # # Allows deploy to pickup where this job leaves off - # - persist_to_workspace: - # root: ~/repo - # paths: . - # test-pr: - # <<: *defaults - # steps: - # - attach_workspace: - # at: ~/repo - run: - name: "JavaScript Test Suite" + name: Jest Tests && Coveralls Report environment: JEST_JUNIT_OUTPUT: reports/junit/js-test-results.xml COVERALLS_SERVICE_NAME: circleci COVERALLS_SERVICE_JOB_ID: $CIRCLE_BUILD_NUM + command: npm run test:ci + # Store our test results + Output + - store_test_results: + path: reports/junit + - store_artifacts: + path: reports/junit + # Allows deploy to pickup where this job leaves off + - persist_to_workspace: + root: ~/repo + paths: . + + # Note: We do not expose project environment variables + # to pull requests from forks (security reasons). This + # job should never rely on such an environment variable. + test-pr: + <<: *defaults + steps: + - checkout + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + - v1-dependencies- + - run: npm install + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + - run: + name: Jest Tests && Coverage Report + environment: + JEST_JUNIT_OUTPUT: reports/junit/js-test-results.xml command: npm run test:unit -- --coverage --coverageReporters=text-lcov # Store our test results + Output - store_test_results: @@ -66,54 +65,42 @@ jobs: - store_artifacts: path: reports/junit # Allows deploy to pickup where this job leaves off - # - persist_to_workspace: - # root: ~/repo - # paths: . - # deploy: - # <<: *defaults - # steps: - # - attach_workspace: - # at: ~/repo - # # - run: echo -e "$NPM_USER\n$NPM_PASS\n$NPM_EMAIL" | npm login + - persist_to_workspace: + root: ~/repo + paths: . + + # Used to publish latest under @next tag + deploy: + <<: *defaults + steps: - run: name: Write NPM Token to ~/.npmrc command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc - # - run: git config --global user.email "danny.ri.brown@gmail.com" - # - run: git config --global user.name "Daniel Brown" - run: name: Bump version number command: sh ~/repo/.circleci/version.sh - run: name: Publish package - command: npm publish --tag next || true - - store_artifacts: - path: ~/.npm/_logs - - store_artifacts: - path: ~/repo/.npmrc - - run: printenv + command: npm publish --tag next workflows: version: 2 + # Pull Requests build-test: jobs: - - setup: + - test-pr: filters: branches: - only: vNext - - test-pr: - requires: - - setup + ignore: vNext + # Merges to vNext build-test-deploy: jobs: - - setup: + - test-merge: filters: branches: - ignore: vNext - # - test-pr: - # requires: - # - setup - # - deploy: - # requires: - # - test-pr \ No newline at end of file + only: vNext + - deploy: + requires: + - test-merge \ No newline at end of file diff --git a/.circleci/version.sh b/.circleci/version.sh index 16fae7317..caf470b86 100644 --- a/.circleci/version.sh +++ b/.circleci/version.sh @@ -14,7 +14,6 @@ then # uses npm-version to set version in package.json # see https://docs.npmjs.com/cli/version npm version $NEW_PACKAGE_VERSION --no-git-tag-version - npm run webpack # git config credential.helper 'cache --timeout=120' git config user.email "danny.ri.brown@gmail.com" diff --git a/package.json b/package.json index d97facb34..648e1012a 100755 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "eslint": "eslint -c .eslintrc.js src", "eslint-quiet": "eslint -c .eslintrc.js --quiet src", "eslint-fix": "eslint -c .eslintrc.js --fix src", + "prepare": "npm run webpack", "start": "npm run webpack", "start:dev": "webpack-dev-server --config ./config/webpack/webpack-dev", "test": "npm run test:chrome",