Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(puml): add svg render git commit hooks #278

Merged
merged 34 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b2da0b5
Add initial hackathon reference docs
lewisdaly Mar 19, 2020
0f19f04
Merge branch 'master' of github.com:mojaloop/documentation
lewisdaly Jun 10, 2020
4d6dc92
Merge branch 'master' of github.com:vessels-tech/documentation
lewisdaly Jul 9, 2020
b8e0e6a
Merge branch 'master' of github.com:mojaloop/documentation
lewisdaly Jul 17, 2020
0bb0579
Merge branch 'master' of github.com:mojaloop/documentation
lewisdaly Aug 3, 2020
a1c77db
Merge branch 'master' of github.com:mojaloop/documentation
lewisdaly Sep 7, 2020
8942674
Merge branch 'master' of github.com:mojaloop/documentation
lewisdaly Nov 20, 2020
224134e
feat(svg): add svg rendering scripts and notes
lewisdaly Nov 20, 2020
4eaa89e
feat(svg): add circleci config for `test-svg` step
lewisdaly Nov 20, 2020
a9dd433
chore(scripts): cleanup
lewisdaly Nov 20, 2020
dfe323e
chore(scripts): fix ci/cd
lewisdaly Nov 20, 2020
db51dea
chore(scripts): fix ci/cd
lewisdaly Nov 20, 2020
eefdcfa
chore(scripts): fix ci/cd
lewisdaly Nov 20, 2020
6c2ebab
feat(ci/cd): fix missing openjdk11 dep
lewisdaly Nov 20, 2020
634e319
feat(ci/cd): fix ci/cd
lewisdaly Nov 20, 2020
95fd526
feat(ci/cd): fix bad reference to ./docs
lewisdaly Nov 20, 2020
109100a
feat(ci/cd): fix cache issues
lewisdaly Nov 20, 2020
ae67532
feat(ci/cd): fix cache issues
lewisdaly Nov 20, 2020
5b0cddd
feat(ci/cd): work on test-svg false negative
lewisdaly Nov 20, 2020
497b443
feat(svg): add rendered svgs
lewisdaly Nov 20, 2020
e780cf5
feat(svg): remove node_modules from find list
lewisdaly Nov 20, 2020
b197bdd
fix(package): add back missing npm scripts
lewisdaly Nov 24, 2020
013ef36
Update stale link for mojaloop docs (#281)
JishnuM Nov 27, 2020
3f40aba
Updated mojaloop helm repo from http to https (#280)
mdebarros Nov 30, 2020
ea3eb7f
Create personas.md (#282)
kjw000 Dec 2, 2020
7448649
Update personas.md (#283)
kjw000 Dec 3, 2020
2f4edf5
feat(puml): switch to npx to run puml command
lewisdaly Dec 7, 2020
00608a4
feat(puml): change from local puml rendering to
lewisdaly Dec 7, 2020
423d031
fix(ci/cd): broken build step
lewisdaly Dec 8, 2020
6d8a20c
fix(ci/cd): broken build step
lewisdaly Dec 8, 2020
906c7c6
fix(ci/cd): broken build step
lewisdaly Dec 8, 2020
110c0e1
Merge branch 'master' into feat/svg-render-hooks
lewisdaly Dec 8, 2020
f61788e
chore(docs): remove debug notes
lewisdaly Dec 9, 2020
6d629e1
Merge branch 'feat/svg-render-hooks' of github.com:vessels-tech/docum…
lewisdaly Dec 9, 2020
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
114 changes: 86 additions & 28 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
# CircleCI v2 Config
version: 2
# CircleCI v2.1 Config
version: 2.1

defaults_working_directory: &defaults_working_directory
working_directory: /home/circleci/project

defaults_docker_node: &defaults_docker_node
docker:
- image: node:10.15-alpine
##
# orbs
#
# Orbs used in this pipeline
##
orbs:
slack: circleci/slack@3.4.2

##
# defaults
#
# YAML defaults templates, in alphabetical order
##
defaults_Dependencies: &defaults_Dependencies
name: Install default dependencies
command: |
apk --no-cache add git
apk --no-cache add ca-certificates
apk --no-cache add curl
apk --no-cache add openssh-client
# for node 10.15-alpine, need to install from edge repo
apk --no-cache add openjdk11 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
apk --no-cache add graphviz
apk add --no-cache -t build-dependencies make gcc g++ python libtool autoconf automake
npm config set unsafe-perm true
npm install -g gitbook-cli

defaults_Environment: &defaults_environment
name: Set default environment
command: |
echo "Nothing to do here right now...move along!"

defaults_slack_announcement: &defaults_slack_announcement
name: Slack announcement for tag releases
Expand Down Expand Up @@ -75,40 +80,53 @@ defaults_publish_to_gh_pages: &defaults_publish_to_gh_pages

echo "Publishing $GITHUB_TAG release to $GITBOOK_TARGET_BRANCH on github..."
git push -q $GITHUB_PROJECT_USERNAME $GITBOOK_TARGET_BRANCH &> git.log
##
# Executors
#
# CircleCI Executors
##
executors:
default-docker:
working_directory: /home/circleci/project
docker:
- image: node:10.15-alpine

default-machine:
machine:
image: ubuntu-1604:201903-01

##
# Jobs
#
# A map of CircleCI jobs
##
jobs:
setup:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- checkout
- run:
<<: *defaults_Dependencies
- run:
<<: *defaults_environment
- run:
name: Access npm folder as root
command: cd $(npm root -g)/npm
- run:
name: Update NPM install
command: npm install
command: npm ci
- run:
name: Delete build dependencies
command: apk del build-dependencies
- save_cache:
key: dependency-cache-{{ .Revision }}
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- node_modules

build:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- checkout
- run:
<<: *defaults_Dependencies
- run:
<<: *defaults_environment
- run:
name: Installing build dependencies
command: |
Expand All @@ -123,25 +141,49 @@ jobs:
curl -L https://sourceforge.net/projects/plantuml/files/plantuml.${PLANTUML_VERSION}.jar/download -o plantuml.jar
- restore_cache:
keys:
- dependency-cache-{{ .Revision }}
- dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: Build Gitbooks
command: |
npm run gitbook:build
- save_cache:
key: build-cache-{{ .Revision }}
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- _book

test-svg:
executor: default-machine
steps:
- checkout
- run:
name: Set up NVM
command: |
echo ${NVM_DIR}
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install v10.15.3
nvm alias default v10.15.3
node --version
npm ci
- run:
name: Check if plantuml has been updated correctly
command: |
set +o pipefail
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
npm run build:plantuml:all
FILE_COUNT=$(git diff --name-only | grep .svg | wc -l)
if [ ${FILE_COUNT} -ne "0" ]; then
echo "${FILE_COUNT} plantuml files are out of sync. Please run npm run build:plantuml and try again.";
exit 1;
else
echo 'Plantuml files are up to date';
fi

deploy:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- checkout
- run:
<<: *defaults_Dependencies
- run:
<<: *defaults_environment
- run:
name: setup environment vars
command: |
Expand All @@ -162,6 +204,11 @@ jobs:
- run:
<<: *defaults_slack_announcement

##
# Workflows
#
# CircleCI Workflow config
##
workflows:
version: 2
build_and_test:
Expand All @@ -176,6 +223,17 @@ workflows:
- /feature.*/
- /bugfix.*/
- gh-pages
- test-svg:
context: org-global
requires:
- setup
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- build:
context: org-global
requires:
Expand Down
51 changes: 51 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Documentation Notes

Helpers and notes for building and working on these docs.


## Building `.svg`s from plantuml sources

We use a git commit hook to automatically rebuild `.svg` files from plantuml
sources. The magic of git hooks means that no extra work is required by you
after creating or editing a `.puml` file

Behind the scenes, this hook spins up a docker container to run the PUML server
and calls `./scripts/_render_svg.js` for each file that has changed. We use the
docker version instead of the public puml server to (1) get around rate limits, and
(2) ensure deterministic SVG output that is git diffable.

### Creating a new PUML

1. Create a new `*.puml/plantuml` file
2. Add the file and generate the `.svg`

```bash
git add . #(or the specific file you are working on)
npm run build:plantuml:diff
```
3. Update your `.md` file to refer to the newly created `.svg` file
4. Git add/commit
### Updating an existing PUML

1. Make changes to an existing `*.puml/plantuml` file
2. `git add` + `git commit`
3. The pre-commit hook rebuilds the changed SVG files, and adds them before the commit

### Building all `.puml` sources manually

You can also force a complete rebuild of all `.puml` and `.plantuml` sources like so:

```bash
npm install
npm run build:plantuml:all
```

### `test-svg` CI/CD Step

This is a ci/cd step that ensures that the `.svg` files have been updated
correctly, just in case something got out of sync on your branch before
merging a pull request.

It runs `npm run build:plantuml:all` to build all of the plantuml sources
and if it detects file changes, it means something went wrong with the
commit hook (or you skipped it with `git commit -n`).
Loading