diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..3a58d2bc5 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,172 @@ +version: 2 + +references: + + # + # Workspace + # + container_config_node8: &container_config_node8 + working_directory: ~/project/build + docker: + - image: circleci/node:8 + + workspace_root: &workspace_root + ~/project + + attach_workspace: &attach_workspace + attach_workspace: + at: *workspace_root + + # + # Cache keys + # + cache_keys_root: &cache_keys_root + keys: + - cache-root-v1-{{ checksum "./package.json" }} + - cache-root-v1- + + cache_keys_docs: &cache_keys_docs + keys: + - cache-docs-v1-{{ checksum "./tools/x-docs/package.json" }} + - cache-docs-v1- + + cache_keys_workbench: &cache_keys_workbench + keys: + - cache-workbench-v1-{{ checksum "./tools/x-workbench/package.json" }} + - cache-workbench-v1- + + # + # Cache creation + # + create_cache_root: &create_cache_root + save_cache: + key: cache-root-v1-{{ checksum "./package.json" }} + paths: + - ./node_modules/ + + create_cache_docs: &create_cache_docs + save_cache: + key: cache-docs-v1-{{ checksum "./tools/x-docs/package.json" }} + paths: + - ./tools/x-docs/node_modules/ + + create_cache_workbench: &create_cache_workbench + save_cache: + key: cache-workbench-v1-{{ checksum "./tools/x-workbench/package.json" }} + paths: + - ./tools/x-workbench/node_modules/ + + # + # Cache restoration + # + restore_cache_root: &restore_cache_root + restore_cache: + <<: *cache_keys_root + + restore_cache_docs: &restore_cache_docs + restore_cache: + <<: *cache_keys_docs + + restore_cache_workbench: &restore_cache_workbench + restore_cache: + <<: *cache_keys_workbench + + # + # Filters + # + filters_branch_build: &filters_branch_build + branches: + ignore: + - gh-pages + tags: + ignore: /.*/ + + filters_release_build: &filters_release_build + tags: + only: + - /^v\d+\.\d+\.\d+(?:-(?:\w+\.)?\d+)?$/ + branches: + ignore: /.*/ + +jobs: + + build: + <<: *container_config_node8 + steps: + - checkout + - run: + name: Checkout next-ci-shared-helpers + command: git clone --depth 1 git@github.com:Financial-Times/next-ci-shared-helpers.git .circleci/shared-helpers + - *restore_cache_root + - *restore_cache_docs + - *restore_cache_workbench + - run: + name: Install project dependencies + command: make install + - run: + name: Run the project build task + command: make build + - *create_cache_root + - *create_cache_docs + - *create_cache_workbench + - persist_to_workspace: + root: *workspace_root + paths: + - build + + test: + <<: *container_config_node8 + steps: + - *attach_workspace + - run: + name: Run tests + command: make test + + publish: + <<: *container_config_node8 + steps: + - *attach_workspace + - run: + name: shared-helper / npm-store-auth-token + command: .circleci/shared-helpers/helper-npm-store-auth-token + - run: + name: NPM publish + command: npx athloi version ${CIRCLE_TAG} && npx athloi publish -- --access=public + - run: + name: Publish GitHub Pages + command: ./private/scripts/gh-pages + +workflows: + + version: 2 + + build-test: + jobs: + - build: + filters: + <<: *filters_branch_build + - test: + filters: + <<: *filters_branch_build + requires: + - build + + build-test-publish: + jobs: + - build: + filters: + <<: *filters_release_build + - test: + filters: + <<: *filters_release_build + requires: + - build + - publish: + filters: + <<: *filters_release_build + requires: + - test + +notify: + webhooks: + - url: https://ft-next-webhooks.herokuapp.com/circleci2-workflow diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fbbc44ba0..000000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: node_js -node_js: -- stable - -env: - global: - - secure: gvZRVZCR4omwAzHzwyb9b9qU8Iav1vDS0QowibTudABF+FT4kLTL6rb7ucjV+q0AKFzu1TJJp+qrgu0dmLrmI8N7y6dLoSmKbq8TkdxYJVCpXtOw4VngRCiknIDISmrYHPwgzrSGi4625McTHwXtoFDln/ftk568F2l7f0H7SMRb/jEjBTGgVvKC+a0blOLGOmyTBUENhPO5NU2kXRayjqgWTbo60uO8WP6UH9haGC2PpVEA4lrgJmWx3bcFTIEYbcKV7ZDLHPTnC1RXR/fEdAAnZM8//oe+3SdUjhHAxPGyvtBZY1nGk0rcLn1uzh879tVPv8fz9cB5lWjDeI7mTJQ8ZRCosAhZWSRxIPnGHCi0iDOU+zZJqPsmHAUYM5mShepCcDfSF2FuCA4I8NILHsU1PoHZ4eHvvhx3xWjeYa4KMjZXcVeuJWfqCRoluTrndjgi16pkTvDOKyPnA1uO2tgVZz7TE7lvNxU0YvxPvO+TxxGuX1N9uv6gur9zvk06TAVvoRMwNxY6iV1pbLchQwGu7S7UPbLG95WV9dwmlH6wXz+I281CHaEL2SzD0D8inznKTLq5ztxOww7XZtyNP1m7fxM+eD69PqHsuEW1/DFNgS5BHyVWFGV0p7qberFi0+aGKYNk494ZtyjntSrZ8Yj0CDU9BFzuiU/vWFQ/QbQ= - - secure: hZD/5Y56O7FHgXwcon2BSO8PchWDIMtUTPkoYCiaw30ny+5CnywGIMUZPX1CgKHaYsj6pTCrko2BlgrfvndeH2FStSTpaJWXSeQ+ahzQig1AnsOX4CTuSmQjx9MDiT04Af1skxqUoPxhLc4zQQFqUG7vpHsclq2zclv3nWe/ZM8BATjEn9PZHCmgdFUV4stbGrp/UZJyvZKKwCrc5AI3DFYFfWRYvw147zrhiJjcKLiIOLDgpHmboUlw9qe9JXBruy1NRmaDUgg7PnbZAzY9AkTwDnXpbMhWESnWlpnj5lia3tp6LAVBmzMMSITPxxuJVIZRp6YWVSz36306fSUMjorTUdQL/f4Pe9yBeJVP4C7eUtwxp9cREuG0biDw8f3cV5JeCSMD8YYS495Ja3Sc0kIot1YIeZFT8yE/GVb12pwwiHO0AQX1DFT+ZT1nIHDQzUw1uq2MnOjEG0vGdTLj2EupppUG0f6LJPhuVXzusoFIiDdn2LeijrbOk+FwizF4EoveE31OCdrteNRUzOE9eihpyBd2Y4NZcD1aGlTFKsFHps9hLLipQcKwCCxjYn+zKsqBggHeProxptqveJZMuLMVMXLgV9X9WVXb0rKM73BWeNdVr8pYZA08owbiFOM2PvYIHODuVUwkW61p/mrKwl4se9cG2s07mLpE9CatlXE= - -before_install: -- echo "//registry.npmjs.org/:_authToken=\${NPM_AUTH_TOKEN}" > ~/.npmrc -- npm install -g npm@5.6 - -deploy: -- provider: pages - skip-cleanup: true - github-token: "$GITHUB_TOKEN" - local-dir: tools/x-docs/public - committer-from-gh: true - verbose: true - on: - branch: master -- provider: script - skip-cleanup: true - script: npx athloi version $TRAVIS_TAG && npx athloi publish -- --access=public - on: - tags: true - -notifications: - slack: - on_success: change - on_failure: change - secure: qD5ZeGfR9+l5AX48DXBgrRWjlXObzNPdbwOVZxEwRC2HlwC59uTePuVKt36M83vZaiIIzP3WSQ7ej0aNi62Hgp+R2hCU/gLuDueGnY1dh5TxIYoVhqTaxJKxF8NFjUM+e8xYsttAGipMA/vYXDowfrUgxprdlQVf7W1UQsIaKE3D9Gza6f2fOHG+wEQRkQ4jbvKlqkL7bbKDJ6afMU6qzgfd2hLAdShFHJJU404hUyLHnXWcecIpchTwiEv8teOs1KE2VcKFyLSOSN6sLtv06bSqB56f7uF3WTHtbKBmXg8SDFLH4QsNsqabcIqVP7UouDLU3/WUQ15oB3SwqxJDYhWDDJ2H+4TftvIYTY4yLEOl23LycVNeEj4oxOxgo8UTw00jQQWsA3MBed6rzhJ2sENdXKc6s9dkpvvyr3uSwzwhgJoTpLPF5FMygNNZPvYXjGQ/tqu3RqKE9CHDhdq5+lxp+e8xouPKy2rH1j2c820b10DVhEH2aU2eZZdnnZglVVmdSJzX4F1a/KGNFwlqP7ChoQz1eN4IkZOXBJd31OPPORFs1Ztw4QHWmF789shpYDuWpEELAfY4ehwLbhjpC1al2zbqkWQ+2qTH8JUKKRjuxPy7335Q3/Gg5TVcx3F1W2Gip9z7JbnQT7zy3GzYKwR3V8oo6SXcdwC43cBMFJU= diff --git a/makefile b/makefile index 64afcbd79..7ff129d98 100644 --- a/makefile +++ b/makefile @@ -7,7 +7,7 @@ clean: @git clean -fxdi install: - npm install + npm install --no-package-lock build: npm run build diff --git a/monorepo.json b/monorepo.json index 94d494f5f..77b619316 100644 --- a/monorepo.json +++ b/monorepo.json @@ -3,6 +3,5 @@ "components/*", "packages/*", "tools/*" - ], - "version": "1.0.0-1" + ] } diff --git a/package.json b/package.json index 93d936700..1f14d37eb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "scripts": { - "postinstall": "athloi exec npm i", + "postinstall": "athloi exec npm i -- --no-package-lock", "clean": "git clean -fxdi", "build": "athloi run build", "jest": "jest -c jest.config.js", diff --git a/private/scripts/gh-pages b/private/scripts/gh-pages new file mode 100755 index 000000000..fc3690a77 --- /dev/null +++ b/private/scripts/gh-pages @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +TARGET_DIR=tools/x-docs/public/* +TARGET_BRANCH=gh-pages +TEMP_DIR=tmp + +# Set error handling +set -eu -o pipefail + +# Set GitHub user information (the email must match the SSH key provided to Circle) +git config --global user.email $GITHUB_EMAIL +git config --global user.name $GITHUB_NAME + +# HACK: Add GitHub to known hosts to avoid an interactive prompt when cloning over SSH +ssh-keyscan -H github.com >> ~/.ssh/known_hosts + +# Clone only the branch we need so we don't download all of the project history +git clone $CIRCLE_REPOSITORY_URL $TEMP_DIR --single-branch --branch $TARGET_BRANCH + +# Remove all of the files, -q prevents logging every filename +cd $TEMP_DIR +git rm -rq . +cd .. + +# Copy contents of target directory to the deployment directory +cp -r $TARGET_DIR $TEMP_DIR + +# Copy CI config (which should instruct Circle to ignore this branch) +cp -r .circleci $TEMP_DIR + +# Stage and commit all of the files, silencing the list output +git add -A &> /dev/null +git commit -m "Automated deployment to GitHub Pages: ${CIRCLE_SHA1}" --allow-empty + +# Push to the target branch, staying quiet unless something goes wrong +git push -q origin $TARGET_BRANCH diff --git a/readme.md b/readme.md index f97b4b6cd..5bc131ec6 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,8 @@