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
27 changes: 0 additions & 27 deletions .circleci/conditional_upload.sh

This file was deleted.

267 changes: 223 additions & 44 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,226 @@
version: 2

# Adapted from https://github.com/circleci/circleci-docs/blob/master/.circleci/config.yml
# I'd love to find docs on this syntax.
references:
js_deps_paths: &js_deps_paths
- node_modules/
- packages/patternfly-3/patternfly-react-extensions/node_modules/
- packages/patternfly-3/patternfly-react-wooden-tree/node_modules/
- packages/patternfly-3/patternfly-react/node_modules/
- packages/patternfly-3/react-console/node_modules/
- packages/patternfly-4/react-charts/node_modules/
- packages/patternfly-4/react-core/node_modules/
- packages/patternfly-4/react-docs/node_modules/
- packages/patternfly-4/react-docs/plugins/gatsby-transformer-react-docgen-typescript/node_modules/
- packages/patternfly-4/react-inline-edit-extension/node_modules/
- packages/patternfly-4/react-integration/demo-app-ts/node_modules/
- packages/patternfly-4/react-integration/node_modules/
- packages/patternfly-4/react-styled-system/node_modules/
- packages/patternfly-4/react-styles/node_modules/
- packages/patternfly-4/react-table/node_modules/
- packages/patternfly-4/react-tokens/node_modules/
- packages/patternfly-4/react-topology/node_modules/
- packages/patternfly-4/react-virtualized-extension/node_modules/
- packages/react-codemods/node_modules/
- packages/react-icons/node_modules/
build_cache_paths: &build_cache_paths
- .cache/
- packages/patternfly-3/patternfly-react-extensions/dist/
- packages/patternfly-3/patternfly-react-wooden-tree/dist/
- packages/patternfly-3/patternfly-react/dist/
- packages/patternfly-3/react-console/dist/
- packages/patternfly-4/react-charts/dist/
- packages/patternfly-4/react-core/dist/
- packages/patternfly-4/react-inline-edit-extension/dist/
- packages/patternfly-4/react-styled-system/dist/
- packages/patternfly-4/react-styles/css/
- packages/patternfly-4/react-styles/dist/
- packages/patternfly-4/react-table/dist/
- packages/patternfly-4/react-tokens/dist/
- packages/patternfly-4/react-topology/dist/
- packages/patternfly-4/react-virtualized-extension/dist/
- packages/react-icons/dist/
js_deps_cache_key: &js_deps_cache_key
js-deps-v{{.Environment.CACHE_VERSION}}-{{checksum "yarn.lock"}}
build_cache_key: &build_cache_key
build-cache-v{{.Environment.CACHE_VERSION}}-{{checksum "yarn.lock"}}
attach_workspace: &attach_workspace
attach_workspace:
at: ~/project

workflows:
version: 2
build_test_deploy:
jobs:
- build
- build_pf4_docs:
requires:
- build
- build_pf3_docs:
requires:
- build
- test_jest_pf4:
requires:
- build
- test_jest_other:
requires:
- build
- build_integration:
requires:
- build
- lint:
requires:
- build
- upload_docs:
requires:
- build_pf3_docs
- build_pf4_docs
- deploy_prerelease:
requires:
- test_jest_pf4
- test_jest_other
- build_pf3_docs
- build_pf4_docs
filters:
branches:
only: master
jobs:
build:
branches:
ignore:
- master
docker:
- image: circleci/node:8.15
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
- run:
name: Conditional install
command: if [ ! -d node_modules ]; then yarn install --frozen-lockfile; fi
- save_cache:
paths:
- node_modules
- packages/react-icons/node_modules
- packages/patternfly-4/react-core/node_modules
- packages/patternfly-4/react-docs/node_modules
- packages/patternfly-4/react-charts/node_modules
- packages/patternfly-4/react-styles/node_modules
- packages/patternfly-3/patternfly-react/node_modules
- .cache # Incremental builds
key: v{{ .Environment.CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
- run:
name: Build Dist
command: yarn build
- run:
name: (PF3) Build Storybook
command: |
yarn build:storybook &&
cp -r .out .public/patternfly-3
- run:
name: (PF4) Build Docs
command: |
yarn build:docs &&
cp -r packages/patternfly-4/react-docs/public .public/patternfly-4 &&
cp -r .public/patternfly-4/assets .public/assets &&
cp .public/patternfly-4/favicon* .public
- run:
name: Deploy Docs
command: if [ -n "$CIRCLE_PULL_REQUEST" ]; then .circleci/upload_preview.sh; fi
docker:
- image: circleci/node:8.15
steps:
- checkout
- persist_to_workspace:
root: ~/project
paths:
- "*"
- restore_cache:
keys:
- *js_deps_cache_key
- run:
name: Conditional install
command: if [ ! -d node_modules ]; then yarn install --frozen-lockfile; fi
- save_cache:
paths: *js_deps_paths
key: *js_deps_cache_key
- restore_cache:
keys:
- *build_cache_key
- run:
name: Build Dist
command: yarn build
- save_cache:
paths: *build_cache_paths
key: *build_cache_key
- persist_to_workspace:
root: ~/project
paths: *build_cache_paths
test_jest_pf4:
docker:
- image: circleci/node:8.15
steps:
- *attach_workspace
- restore_cache:
keys:
- *js_deps_cache_key
- run:
name: PF4 Jest Tests
command: yarn test:pf4 --maxWorkers=2
test_jest_other:
docker:
- image: circleci/node:8.15
steps:
- *attach_workspace
- restore_cache:
keys:
- *js_deps_cache_key
- run:
name: PF3 Jest Tests
command: yarn test:pf3 --maxWorkers=2
- run:
name: Other Tests
command: yarn test:misc --maxWorkers=2
build_integration:
docker:
- image: circleci/node:8.15
steps:
- *attach_workspace
- restore_cache:
keys:
- *js_deps_cache_key
- run:
name: Build Cypress Integration Tests
command: yarn build:integration
lint:
docker:
- image: circleci/node:8.15
steps:
- *attach_workspace
- restore_cache:
keys:
- *js_deps_cache_key
- run:
name: TSLint
command: yarn lint:ts
- run:
name: ESLint
command: yarn lint:js
- run:
name: "@patternfly/patternfly Versions Match"
command: yarn lint:versions
- run:
name: StyleLint
command: yarn lint:style
build_pf3_docs:
docker:
- image: circleci/node:8.15
steps:
- *attach_workspace
- restore_cache:
keys:
- *js_deps_cache_key
- run:
name: Build PF3 Storybook Static Site
command: yarn build:storybook
- persist_to_workspace:
root: ~/project
paths:
- .out/
build_pf4_docs:
docker:
- image: circleci/node:8.15
steps:
- *attach_workspace
- restore_cache:
keys:
- *js_deps_cache_key
- run:
name: Build PF4 Gatsby Static Site
command: yarn build:docs
- persist_to_workspace:
root: ~/project
paths:
- packages/patternfly-4/react-docs/public/
upload_docs:
docker:
- image: circleci/node:8.15
steps:
- *attach_workspace
- run:
name: Build docs Folder
command: .circleci/copy-docs.sh
- run:
name: Upload docs to surge.sh
command: .circleci/upload-docs.sh
deploy_prerelease:
docker:
- image: circleci/node:8.15
steps:
- *attach_workspace
- run:
name: Avoid hosts unknown for github
command: mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
- run:
name: Deploy to NPM and Github
command: .circleci/release.sh
10 changes: 10 additions & 0 deletions .circleci/copy-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# Build the docs/ folder from pf3 and pf4 docs
mkdir -p docs
cp -r .out docs/patternfly-3
cp -r packages/patternfly-4/react-docs/public docs/patternfly-4
cp .circleci/index.html docs/index.html
# These need to be at the root for CSS variables
cp -r docs/patternfly-4/assets docs/assets
# Use newer favicon
cp docs/patternfly-4/favicon* docs
File renamed without changes.
33 changes: 5 additions & 28 deletions .circleci/release.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,16 @@
#!/bin/bash
# Note: do not do set -x or the passwords will leak!
set -e

GIT_USERNAME="patternfly-build"
REPO="github.com:${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git"
echo "Preparing release environment..."
git config --global user.email "patternfly-build@redhat.com"
git config --global user.name "patternfly-build"
git config --global user.name ${GIT_USERNAME}
git config credential.helper store

echo "https://${GH_USERNAME}:${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" > ~/.git-credentials
echo "https://${GIT_USERNAME}:${GH_TOKEN}@${REPO}" > ~/.git-credentials
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc

echo "Doing a release..."
# Lerna is complicated. Commands: https://github.com/lerna/lerna/tree/master/commands
git checkout $TRAVIS_BRANCH # Lerna can't have a detached HEAD
git rev-parse HEAD

# Identify packages that have been updated since the previous tagged release
# Update their versions and changelogs
npx lerna version --conventional-commits --no-git-tag-version --no-commit-hooks --no-push --yes

# Amend the commit to avoid lerna ERR! EUNCOMMIT
git add **/package.json **/CHANGELOG.md
git commit --amend --no-edit --no-verify

# Check each package.json and determine if any package version is not present in the registry;
# any versions not present in the registry will be published
if npx lerna publish from-package --no-git-tag-version --no-push --yes ; then
# Undo that last amended commit locally, because we don't actually want to push it
git reset --hard $TRAVIS_COMMIT
# Now only if it publishes should we also push this commit to Github and do a Github release
if ! npx lerna version --conventional-commits --github-release --no-commit-hooks --yes ; then
echo "Something went wrong committing or making a Github release."
exit 0 # Publishing to the registry is what matters...
fi
else # Failed to publish to npm
echo "Failed to publish to npm :("
exit 1
fi
npx lerna publish --conventional-commits --create-release=github --yes
31 changes: 31 additions & 0 deletions .circleci/upload-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
USERNAME=${CIRCLE_PROJECT_USERNAME}
REPONAME=${CIRCLE_PROJECT_REPONAME}

if [ -n "${CIRCLE_PULL_REQUEST}" ] # If build is a PR
then
# Split on "/" to get last part of URL, ref: http://stackoverflow.com/a/5257398/689223
URL_SPLIT=(${CIRCLE_PULL_REQUEST//\// })
PR_NUM=$(printf %s\\n "${URL_SPLIT[@]:(-1)}")
# Domain names follow the RFC1123 spec [a-Z] [0-9] [-] limited to 253 characters
# https://en.wikipedia.org/wiki/Domain_Name_System#Domain_name_syntax
# So, just replace "/" or "." with "-"
DEPLOY_SUBDOMAIN=`echo "${REPONAME}-pr-$PR_NUM" | tr '[\/|\.]' '-' | cut -c1-253`
ALREADY_DEPLOYED=`npx surge list | grep ${DEPLOY_SUBDOMAIN}`
else
DEPLOY_SUBDOMAIN=${REPONAME}
fi

DEPLOY_DOMAIN="https://${DEPLOY_SUBDOMAIN}.surge.sh"
npx surge --project docs --domain $DEPLOY_DOMAIN;

if [ -n "${CIRCLE_PULL_REQUEST}" ] && [ -z "${ALREADY_DEPLOYED}" ] # Leave a Github comment
then
# Use Issues api instead of PR api because
# PR api requires comments be made on specific files of specific commits
GITHUB_PR_COMMENTS="https://api.github.com/repos/${USERNAME}/${REPONAME}/issues/${PR_NUM}/comments"
echo "Adding github PR comment ${GITHUB_PR_COMMENTS}"
curl -H "Authorization: token ${GH_PR_TOKEN}" --request POST ${GITHUB_PR_COMMENTS} --data '{"body":"PatternFly-React preview: '${DEPLOY_DOMAIN}'"}'
else
echo "Already deployed ${DEPLOY_DOMAIN}"
fi
Loading