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 @@

x-dash
x-dash - - Build Status + + Build Status

diff --git a/secret-squirrel.js b/secret-squirrel.js index 3af14cd0d..8a89b4f7d 100644 --- a/secret-squirrel.js +++ b/secret-squirrel.js @@ -9,6 +9,7 @@ module.exports = { 'tools/x-docs/public-prod/x-dash', '__tests__/__snapshots__/snapshots.test.js.snap', 'private/logos/Logo.pxm', + 'private/scripts/gh-pages', 'tools/x-workbench/static/components', ], allowOverrides: [] @@ -16,10 +17,6 @@ module.exports = { strings: { deny: [], denyOverrides: [ - 'aGKYNk494ZtyjntSrZ8Yj0CDU9BFzuiU', // .travis.yml:7 - '3SdUjhHAxPGyvtBZY1nGk0rcLn1uzh879tVPv8fz9cB5lWjDeI7mTJQ8ZRCosAhZWSRxIPnGHCi0iDOU', // .travis.yml:7 - 'R2hCU/gLuDueGnY1dh5TxIYoVhqTaxJKxF8NFjUM', // .travis.yml:30 - '2qTH8JUKKRjuxPy7335Q3', // .travis.yml:30 '7b55beac-38e7-11e8-9529-6286f384b7ce', // components/x-teaser/README.md:31 '0e89d872-5711-457b-80b1-4ca0d8afea46', // __tests__/__snapshots__/snapshots.test.js.snap:339|377|782|820|1225|1263|1663|1701|2091|2129|2534|2572|2977|3015|3415|3453|3858|3896|4301|4339, components/x-teaser/stories/video.js:11 'a25832ea-0053-11e8-9650-9c0ad2d7c5b5', // components/x-teaser/stories/article.js:28, components/x-teaser/stories/top-story.js:28 diff --git a/tools/x-docs/.gitignore b/tools/x-docs/.gitignore index f07d488f8..965345162 100644 --- a/tools/x-docs/.gitignore +++ b/tools/x-docs/.gitignore @@ -1,4 +1,3 @@ .cache bower_components /public -travis_deploy_key diff --git a/tools/x-docs/gatsby-config.js b/tools/x-docs/gatsby-config.js index 56cdf4f7e..35a039514 100644 --- a/tools/x-docs/gatsby-config.js +++ b/tools/x-docs/gatsby-config.js @@ -29,22 +29,22 @@ module.exports = { }, }, 'gatsby-plugin-doc-pages', - { - resolve: '@andrew-codes/gatsby-plugin-elasticlunr-search', - options: { - fields: [ - 'title', - 'plainText', - ], - resolvers: { - MarkdownRemark: { - title: node => node.frontmatter.title, - plainText: node => node.plainText, - href: node => node.frontmatter.path, - breadcrumbs: node => node.frontmatter.breadcrumbs, - } - } - } - } + // { + // resolve: '@andrew-codes/gatsby-plugin-elasticlunr-search', + // options: { + // fields: [ + // 'title', + // 'plainText', + // ], + // resolvers: { + // MarkdownRemark: { + // title: node => node.frontmatter.title, + // plainText: node => node.plainText, + // href: node => node.frontmatter.path, + // breadcrumbs: node => node.frontmatter.breadcrumbs, + // } + // } + // } + // } ] }; diff --git a/tools/x-docs/package.json b/tools/x-docs/package.json index 6d3045a94..1c39b72df 100644 --- a/tools/x-docs/package.json +++ b/tools/x-docs/package.json @@ -42,15 +42,14 @@ "rehype-react": "^3.0.2", "remove-markdown": "^0.2.2", "title-case": "^2.1.1", - "unist-util-visit": "^1.3.0", - "webpack-stats-plugin": "^0.2.1" + "unist-util-visit": "^1.3.0" }, "keywords": [ "gatsby" ], "license": "MIT", "scripts": { - "build": "gatsby build --prefix-paths", + "build": "gatsby build --prefix-paths --verbose", "postbuild": "find public -name '*.html'", "start": "nodemon -x 'gatsby develop -H local.ft.com' -w \"gatsby-*.js\" -w plugins", "prestart-prod": "npm run build", diff --git a/tools/x-docs/plugins/gatsby-plugin-packages/gatsby-node.js b/tools/x-docs/plugins/gatsby-plugin-packages/gatsby-node.js index 468460d0a..7850583aa 100644 --- a/tools/x-docs/plugins/gatsby-plugin-packages/gatsby-node.js +++ b/tools/x-docs/plugins/gatsby-plugin-packages/gatsby-node.js @@ -8,26 +8,19 @@ const paramCase = require('param-case'); // ensure we get the same 'JSON' type as remark, which, there has to be a better way const GraphQlJson = require('gatsby-transformer-remark/node_modules/graphql-type-json'); const glob = require('glob-promise'); -const {StatsWriterPlugin} = require('webpack-stats-plugin'); const repoBase = path.dirname(findUp.sync('monorepo.json')); -exports.modifyWebpackConfig = function({config, stage}) { +exports.modifyWebpackConfig = function({ config }) { config.merge({ plugins: [ - xEngine(), - new StatsWriterPlugin({ - filename: `stats-${stage}.json`, - fields: false, - }), + xEngine() ], resolve: { alias: { '@financial-times/x-engine': '@financial-times/x-engine/src/client', }, - }, - stats: 'verbose', - profile: true, + } }); return config; diff --git a/tools/x-docs/scripts/deploy.sh b/tools/x-docs/scripts/deploy.sh deleted file mode 100644 index 696653131..000000000 --- a/tools/x-docs/scripts/deploy.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# adapted from https://gist.github.com/domenic/ec8b0fc8ab45f39403dd -set -e - -# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc -ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key" -ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv" -ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR} -ENCRYPTED_IV=${!ENCRYPTED_IV_VAR} -openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in travis_deploy_key.enc -out travis_deploy_key -d -chmod 600 travis_deploy_key -eval `ssh-agent -s` -ssh-add travis_deploy_key - -# do the actual deploy -gh-pages -d public diff --git a/tools/x-docs/src/components/header/index.js b/tools/x-docs/src/components/header/index.js index 9c8c21f4c..9116595b6 100644 --- a/tools/x-docs/src/components/header/index.js +++ b/tools/x-docs/src/components/header/index.js @@ -2,18 +2,18 @@ import React from 'react' import Link from 'gatsby-link' import c from 'classnames'; import XLogo from '@financial-times/x-logo'; -import Search from '../search'; +// import Search from '../search'; import map from 'lodash.map'; import styles from './header.module.scss'; import {splashBackground} from '../../styles/splash/splash.module.scss'; -const Header = ({splash, searchIndex, tree}) =>
- + {/* */}
diff --git a/tools/x-docs/src/layouts/index.js b/tools/x-docs/src/layouts/index.js index b92d580c2..ab387dce9 100644 --- a/tools/x-docs/src/layouts/index.js +++ b/tools/x-docs/src/layouts/index.js @@ -11,7 +11,7 @@ import styles from './wrapper.module.scss'; const TemplateWrapper = ({children, data, ...props}) => {({sidebarTree, headerTree}) =>
-
+
@@ -42,9 +42,5 @@ export const query = graphql` } } } - - siteSearchIndex { - index - } } `; diff --git a/tools/x-docs/src/layouts/splash.js b/tools/x-docs/src/layouts/splash.js index f9fbe20d6..f4cc8ad49 100644 --- a/tools/x-docs/src/layouts/splash.js +++ b/tools/x-docs/src/layouts/splash.js @@ -16,7 +16,7 @@ const TemplateWrapper = ({children, data, ...props}) => -
+
{children()} @@ -39,9 +39,5 @@ export const query = graphql` } } } - - siteSearchIndex { - index - } } `;