Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 32 additions & 116 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,27 @@ version: 2
references:
js_deps_paths: &js_deps_paths
- node_modules/
- packages/patternfly-3/node_modules/
- packages/patternfly-4/node_modules/
- packages/patternfly-4/gatsby-theme-patternfly-org/node_modules/
- packages/patternfly-4/node_modules/
- packages/patternfly-4/patternfly-react/packages/react-docs/node_modules/
v3_js_deps_paths: &v3_js_deps_paths
- packages/patternfly-3/node_modules
v3_ruby_deps_paths: &v3_ruby_deps_paths
- packages/patternfly-3/.bundle
react_build_cache_paths: &react_build_cache_paths
- packages/patternfly-4/patternfly-react/packages/react-docs/.cache
- packages/patternfly-4/patternfly-react/packages/react-docs/public
org_build_cache_paths: &org_build_cache_paths
- packages/patternfly-3/vendor
v4_build_cache_paths: &v4_build_cache_paths
- packages/patternfly-4/.cache
- packages/patternfly-4/public
# Excluded: react-docs/plugins
js_deps_cache_key: &js_deps_cache_key
js-deps-v{{.Environment.CACHE_VERSION}}-{{checksum "yarn.lock"}}
js_deps_cache_key_check: &js_deps_cache_key_check
js-deps-v{{.Environment.CACHE_VERSION}}-{{checksum "yarn.lock"}}-check
v3_js_deps_cache_key: &v3_js_deps_cache_key
v3-js-deps-v{{.Environment.CACHE_VERSION}}-{{checksum "packages/patternfly-3/yarn.lock"}}
js_deps_cache_check_key: &js_deps_cache_check_key
js-deps-checkfile-v{{.Environment.CACHE_VERSION}}-{{checksum "yarn.lock"}}
v3_ruby_deps_cache_key: &v3_ruby_deps_cache_key
v3-ruby-deps-v{{.Environment.CACHE_VERSION}}-{{checksum "packages/patternfly-3/Gemfile.lock"}}
react_build_cache_key: &react_build_cache_key
react-build-v{{.Environment.CACHE_VERSION}}-{{checksum "yarn.lock"}}
org_build_cache_key: &org_build_cache_key
v4_build_cache_key: &v4_build_cache_key
org-build-v{{.Environment.CACHE_VERSION}}-{{checksum "yarn.lock"}}
attach_workspace: &attach_workspace
attach_workspace:
at: ~/project
install_node: &install_node
run:
name: Install node@10 (need right version for `yarn`)
name: Install node@12 (need right version for `yarn`)
command: |
set +e
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
Expand All @@ -53,32 +41,21 @@ references:
run:
name: Install yarn
command: curl -o- -L https://yarnpkg.com/install.sh | bash

workflows:
version: 2
install_build_deploy:
jobs:
- install
- build_react:
requires:
- install
- build_org:
- build_v4:
requires:
- install
- build_v3:
requires:
- install
- upload_previews:
requires:
- build_react
- build_org
- build_v3
# - test_org_a11y:
# requires:
# - build_org
- deploy:
requires:
- build_react
- build_org
- build_v4
- build_v3
filters:
branches:
Expand All @@ -89,61 +66,26 @@ jobs:
- image: circleci/node:12
steps:
- checkout
- run:
name: Pull Submodules
command: |
git submodule init
git submodule update
- persist_to_workspace:
root: ~/project
paths:
- "*"
- restore_cache:
keys:
- *js_deps_cache_key_check
- *js_deps_cache_check_key
- run:
name: Conditional install
command: if [ ! -f cached ]; then yarn install --frozen-lockfile && touch cached; fi
command: if [ ! -f cachefile ]; then yarn install --frozen-lockfile && touch cachefile; fi
- save_cache:
paths: cached
key: *js_deps_cache_key_check
paths: cachefile
key: *js_deps_cache_check_key
- save_cache:
paths: *js_deps_paths
key: *js_deps_cache_key
build_react:
machine:
image: circleci/classic:latest
steps:
- *attach_workspace
- restore_cache:
keys:
- *js_deps_cache_key
- restore_cache:
keys:
- *react_build_cache_key
- run:
name: Invalidate Environment Variable Cache
command: rm -f packages/patternfly-4/patternfly-react/packages/react-docs/.cache/redux.state
- *install_node
- *install_yarn
- run:
name: Build patternfly-react docs
command: ~/.yarn/bin/yarn build:react
- save_cache:
paths: *react_build_cache_paths
key: *react_build_cache_key
- persist_to_workspace:
root: ~/project
paths:
- build
build_v3:
docker:
- image: circleci/ruby:latest-node
steps:
- *attach_workspace
- checkout
- restore_cache:
keys:
- *v3_js_deps_cache_key
- *js_deps_cache_key
- restore_cache:
keys:
- *v3_ruby_deps_cache_key
Expand All @@ -152,81 +94,55 @@ jobs:
command: |
cd packages/patternfly-3
bundle install
yarn install
- save_cache:
paths: *v3_ruby_deps_paths
key: *v3_ruby_deps_cache_key
- save_cache:
paths: *v3_js_deps_paths
key: *v3_js_deps_cache_key
- run:
name: Build v3 docs
command: yarn build:org:v3
command: yarn build:v3
- run:
name: Upload docs to surge.sh
command: node .circleci/upload-preview.js build/patternfly-org v3
- persist_to_workspace:
root: ~/project
paths:
- build
build_org:
build_v4:
machine:
image: circleci/classic:latest
steps:
- *attach_workspace
- checkout
- restore_cache:
keys:
- *js_deps_cache_key
- restore_cache:
keys:
- *org_build_cache_key
- *v4_build_cache_key
- run:
name: Invalidate Environment Variable Cache
command: rm -f packages/patternfly-4/.cache/redux.state
- *install_node
- *install_yarn
- run:
name: Build patternfly.org docs
command: ~/.yarn/bin/yarn build:org:prefix
command: ~/.yarn/bin/yarn build:v4
- save_cache:
paths: *org_build_cache_paths
key: *org_build_cache_key
paths: *v4_build_cache_paths
key: *v4_build_cache_key
- run:
name: Upload docs to surge.sh
command: node .circleci/upload-preview.js build/patternfly-org v4
- persist_to_workspace:
root: ~/project
paths:
- build
upload_previews:
docker:
- image: circleci/node:12
steps:
- *attach_workspace
- run:
name: Write redirects
command: node scripts/writeV3Redirects.js --skip-v3
- run:
name: Move v3 (for size)
command: mkdir build/patternfly-org-3 && mv build/patternfly-org/v3 build/patternfly-org-3/v3
- run:
name: Check size of docs
command: du -sh build/* build/patternfly-org/*
- run:
name: Upload docs
command: .circleci/upload-preview.sh
test_org_a11y:
docker:
- image: circleci/node:12-browsers
steps:
- *attach_workspace
- restore_cache:
keys:
- *js_deps_cache_key
- run:
name: Test a11y
command: yarn test:org || true
- store_artifacts:
path: packages/patternfly-4/coverage/
deploy:
docker:
- image: circleci/node:12
steps:
- *attach_workspace
- checkout
- attach_workspace:
at: ~/project
- restore_cache:
keys:
- *js_deps_cache_key
Expand Down
82 changes: 82 additions & 0 deletions .circleci/upload-preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
const path = require('path');
const { Octokit } = require("@octokit/rest")
const octokit = new Octokit({ auth: process.env.GH_PR_TOKEN });
const surge = require('surge');
const publishFn = surge().publish();

const owner = process.env.CIRCLE_PROJECT_USERNAME; // patternfly
const repo = process.env.CIRCLE_PROJECT_REPONAME;
const prnum = process.env.CIRCLE_PR_NUMBER;
const prbranch = process.env.CIRCLE_BRANCH;

const uploadFolder = process.argv[2];
const uploadName = process.argv[3] || uploadFolder;
if (!uploadFolder) {
console.log('Usage: upload-preview uploadFolder');
process.exit(1);
}

const uploadFolderName = path.basename(uploadFolder);
let uploadURL = `${repo}${prnum ? `-pr-${prnum || prbranch}` : ''}`.replace(/[\/|\.]/g, '-');

uploadURL += `-${uploadName}`;
uploadURL += '.surge.sh';

publishFn({
project: uploadFolder,
p: uploadFolder,
domain: uploadURL,
d: uploadURL,
e: 'https://surge.surge.sh',
endpoint: 'https://surge.surge.sh'
});

function tryAddComment(comment, commentBody) {
if (!commentBody.includes(comment)) {
return comment;
}
return '';
}

if (prnum) {
octokit.issues.listComments({
owner,
repo,
issue_number: prnum
})
.then(res => res.data)
.then(comments => {
let commentBody = '';
const existingComment = comments.find(comment => comment.user.login === 'patternfly-build');
if (existingComment) {
commentBody += existingComment.body.trim();
commentBody += '\n';
}

if (uploadName === '-v3') {
commentBody += tryAddComment(`PF3 preview: https://${uploadURL}/v3`, commentBody);
}
else if (uploadName === '-v4') {
commentBody += tryAddComment(`PF4 preview: https://${uploadURL}/v4`, commentBody);
}
else if (uploadFolderName === 'coverage') {
commentBody += tryAddComment(`A11y report: https://${uploadURL}`, commentBody);
}

if (existingComment) {
octokit.issues.updateComment({
owner,
repo,
comment_id: existingComment.id,
body: commentBody
}).then(() => console.log('Updated comment!'));
} else {
octokit.issues.createComment({
owner,
repo,
issue_number: prnum,
body: commentBody
}).then(() => console.log('Created comment!'));
}
});
}
39 changes: 0 additions & 39 deletions .circleci/upload-preview.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

Loading