Skip to content

Commit

Permalink
Merge pull request #107 from Financial-Times/matth/circle
Browse files Browse the repository at this point in the history
Switch to circle CI
  • Loading branch information
i-like-robots authored Jul 25, 2018
2 parents c68576a + 54aea06 commit 76d53ee
Show file tree
Hide file tree
Showing 16 changed files with 241 additions and 103 deletions.
172 changes: 172 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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 [email protected]: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
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ clean:
@git clean -fxdi

install:
npm install
npm install --no-package-lock

build:
npm run build
Expand Down
3 changes: 1 addition & 2 deletions monorepo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"components/*",
"packages/*",
"tools/*"
],
"version": "1.0.0-1"
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
36 changes: 36 additions & 0 deletions private/scripts/gh-pages
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<h1 align="center">
<img src="https://user-images.githubusercontent.com/271645/38416861-1e6c6202-398e-11e8-907c-8c199a03988a.png" width="200" alt="x-dash"><br>
x-dash
<a href="https://travis-ci.org/Financial-Times/x-dash">
<img alt="Build Status" src="https://travis-ci.org/Financial-Times/x-dash.svg?branch=master">
<a href="https://circleci.com/gh/Financial-Times/x-dash/tree/master">
<img alt="Build Status" src="https://circleci.com/gh/Financial-Times/x-dash/tree/master.svg?style=svg">
</a>
</h1>

Expand Down
5 changes: 1 addition & 4 deletions secret-squirrel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ 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: []
},
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
Expand Down
1 change: 0 additions & 1 deletion tools/x-docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.cache
bower_components
/public
travis_deploy_key
34 changes: 17 additions & 17 deletions tools/x-docs/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
// }
// }
// }
// }
]
};
5 changes: 2 additions & 3 deletions tools/x-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 3 additions & 10 deletions tools/x-docs/plugins/gatsby-plugin-packages/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 76d53ee

Please sign in to comment.