Skip to content

Commit

Permalink
Merge pull request #834 from kaleido-io/backport-docs
Browse files Browse the repository at this point in the history
Backport docs generation and versioning code for 1.0 stream
  • Loading branch information
peterbroadhurst authored May 26, 2022
2 parents 6d5ce1b + 7a12cbf commit 971ff47
Show file tree
Hide file tree
Showing 187 changed files with 10,264 additions and 995 deletions.
121 changes: 121 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Docs Site

on:
push:
branches:
- main
pull_request:
release:
types: [released]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:

# This is a regex from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
# It is used in this GitHub action in a couple places to find semver named directories (with a 'v' on the front)
- name: Set SEMVER_REGEX
run: echo "SEMVER_REGEX='^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'" >> $GITHUB_ENV

- name: Checkout the current commit
uses: actions/checkout@v3
with:
fetch-depth: 0

# If this is a new release, get the previous versions of the docs to build the full list of versions
- name: Checkout the gh-pages branch
if: github.event_name == 'release'
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'

- name: Install bundler
run: gem install bundler:1.17.2

# If this was a merge to main, set the version to "head"
- name: Set version env var to 'head'
if: github.event_name == 'push'
run: echo "DOCS_VERSION=head" >> $GITHUB_ENV

# If this was a release, set the version number
- name: Set version env var
if: github.event_name == 'release'
run: echo "DOCS_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Set version in _config.yml
run: |
echo "version: ${{ env.DOCS_VERSION }}" >> ./docs/_config.yml
# Only need to build the full list of versions every time there is a new release
# This uses a regex to determine which existing directories are "versions" and should be listed in the version.json file.
# The output of this command is a version.json file containing a JSON array of all semver released versions of the docs, plus "latest" and "head"
- name: Update version.json list
if: github.event_name == 'release'
run: ls ./gh-pages | grep -E ${{ env.SEMVER_REGEX }} | sed 's/^/"/;s/$/"/' | tr '\n' ',' | sed 's/.$//' | sed 's/^/[/;s/$/]/' | jq '. += ["${{ env.DOCS_VERSION }}"] | sort_by(.) | reverse | . += ["latest", "head"]' > ./docs/assets/js/versions.json

- name: Install dependencies
working-directory: docs
run: bundle install

- name: Build doc site version
working-directory: docs
run: bundle exec jekyll build --baseurl /firefly/${{ env.DOCS_VERSION }}

- name: Check the docs for broken links (root)
if: github.event_name == 'pull_request'
working-directory: docs
run: bundle exec htmlproofer --allow-hash-href --assume-extension ./_site --url-swap '^/firefly/:/' --url-ignore /127.0.0.1/,/localhost/

- name: Check the docs for broken links (version)
if: github.event_name != 'pull_request'
working-directory: docs
run: bundle exec htmlproofer --allow-hash-href --assume-extension ./_site --url-swap '^/firefly/${{ env.DOCS_VERSION }}/:/' --url-ignore /127.0.0.1/,/localhost/

- name: Deploy docs (version)
if: github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./docs/_site
destination_dir: ./${{ env.DOCS_VERSION }}

## FINAL STEPS TO COMPLETE IF THIS WAS A NEW RELEASE ##

- name: Copy new version into version directory
if: github.event_name == 'release'
working-directory: docs
run: mv _site ${{ env.DOCS_VERSION }}

# This uses a regex from to determine which existing directories are "versions" and should be copied over
- name: Copy existing versions into working directory
if: github.event_name == 'release'
run: ls ./gh-pages | grep -E ${{ env.SEMVER_REGEX }} | xargs -I '{}' mv './gh-pages/{}' ./docs

- name: Copy existing 'head' directory into working directory
if: github.event_name == 'release'
run: mv ./gh-pages/head ./docs

- name: Build doc site (latest)
if: github.event_name == 'release'
working-directory: docs
run: bundle exec jekyll build --baseurl /firefly

- name: Deploy docs (latest)
if: github.event_name == 'release'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./docs/_site

15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,24 @@ ${MOCKERY}:
$(VGO) install github.com/vektra/mockery/cmd/mockery@latest
${LINT}:
$(VGO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
ffcommon:
$(eval WSCLIENT_PATH := $(shell $(VGO) list -f '{{.Dir}}' github.com/hyperledger/firefly-common/pkg/wsclient))


define makemock
mocks: mocks-$(strip $(1))-$(strip $(2))
mocks-$(strip $(1))-$(strip $(2)): ${MOCKERY}
mocks-$(strip $(1))-$(strip $(2)): ${MOCKERY} ffcommon
${MOCKERY} --case underscore --dir $(1) --name $(2) --outpkg $(3) --output mocks/$(strip $(3))
endef

$(eval $(call makemock, $$(WSCLIENT_PATH), WSClient, wsmocks))
$(eval $(call makemock, pkg/blockchain, Plugin, blockchainmocks))
$(eval $(call makemock, pkg/blockchain, Callbacks, blockchainmocks))
$(eval $(call makemock, pkg/database, Plugin, databasemocks))
$(eval $(call makemock, pkg/database, Callbacks, databasemocks))
$(eval $(call makemock, pkg/sharedstorage, Plugin, sharedstoragemocks))
$(eval $(call makemock, pkg/sharedstorage, Callbacks, sharedstoragemocks))
$(eval $(call makemock, pkg/events, Plugin, eventsmocks))
$(eval $(call makemock, pkg/events, Plugin, eventsmocks))
$(eval $(call makemock, pkg/events, Callbacks, eventsmocks))
$(eval $(call makemock, pkg/identity, Plugin, identitymocks))
$(eval $(call makemock, pkg/identity, Callbacks, identitymocks))
Expand All @@ -48,8 +50,6 @@ $(eval $(call makemock, pkg/dataexchange, DXEvent, dataexcha
$(eval $(call makemock, pkg/dataexchange, Callbacks, dataexchangemocks))
$(eval $(call makemock, pkg/tokens, Plugin, tokenmocks))
$(eval $(call makemock, pkg/tokens, Callbacks, tokenmocks))
$(eval $(call makemock, pkg/wsclient, WSClient, wsmocks))
$(eval $(call makemock, pkg/httpserver, GoHTTPServer, httpservermocks))
$(eval $(call makemock, internal/txcommon, Helper, txcommonmocks))
$(eval $(call makemock, internal/identity, Manager, identitymanagermocks))
$(eval $(call makemock, internal/batchpin, Submitter, batchpinmocks))
Expand All @@ -63,8 +63,9 @@ $(eval $(call makemock, internal/broadcast, Manager, broadcast
$(eval $(call makemock, internal/privatemessaging, Manager, privatemessagingmocks))
$(eval $(call makemock, internal/shareddownload, Manager, shareddownloadmocks))
$(eval $(call makemock, internal/shareddownload, Callbacks, shareddownloadmocks))
$(eval $(call makemock, internal/definitions, DefinitionHandlers, definitionsmocks))
$(eval $(call makemock, internal/definitions, DefinitionHandler, definitionsmocks))
$(eval $(call makemock, internal/events, EventManager, eventmocks))
$(eval $(call makemock, internal/namespace, Manager, namespacemocks))
$(eval $(call makemock, internal/networkmap, Manager, networkmapmocks))
$(eval $(call makemock, internal/assets, Manager, assetmocks))
$(eval $(call makemock, internal/contracts, Manager, contractmocks))
Expand Down Expand Up @@ -93,8 +94,10 @@ clean:
deps:
$(VGO) get
reference:
$(VGO) test ./internal/apiserver ./docs -timeout=10s -tags reference
$(VGO) test ./internal/apiserver ./internal/reference ./docs -timeout=10s -tags reference
manifest:
./manifestgen.sh
docker:
./docker_build.sh $(DOCKER_ARGS)
docs: .ALWAYS
cd docs && bundle install && bundle exec jekyll build && bundle exec htmlproofer --allow-hash-href --assume-extension ./_site --url-swap '^/firefly/:/' --url-ignore /127.0.0.1/,/localhost/
2 changes: 1 addition & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vendor
/vendor
_site
.sass-cache
7 changes: 6 additions & 1 deletion docs/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ source "https://rubygems.org"

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem "github-pages", group: :jekyll_plugins
group :jekyll_plugins do
gem "github-pages"
gem "jekyll-multiple-languages-plugin"
gem "html-proofer"
gem "webrick"
end
39 changes: 27 additions & 12 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (6.0.4.7)
activesupport (6.0.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
Expand Down Expand Up @@ -51,9 +51,9 @@ GEM
ffi (1.15.5)
forwardable-extended (2.6.0)
gemoji (3.0.1)
github-pages (225)
github-pages (226)
github-pages-health-check (= 1.17.9)
jekyll (= 3.9.0)
jekyll (= 3.9.2)
jekyll-avatar (= 0.7.0)
jekyll-coffeescript (= 1.1.1)
jekyll-commonmark-ghpages (= 0.2.0)
Expand Down Expand Up @@ -88,12 +88,12 @@ GEM
jekyll-theme-time-machine (= 0.2.0)
jekyll-titles-from-headings (= 0.5.3)
jemoji (= 0.12.0)
kramdown (= 2.3.1)
kramdown (= 2.3.2)
kramdown-parser-gfm (= 1.1.0)
liquid (= 4.0.3)
mercenary (~> 0.3)
minima (= 2.5.1)
nokogiri (>= 1.12.5, < 2.0)
nokogiri (>= 1.13.4, < 2.0)
rouge (= 3.26.0)
terminal-table (~> 1.4)
github-pages-health-check (1.17.9)
Expand All @@ -105,10 +105,18 @@ GEM
html-pipeline (2.14.1)
activesupport (>= 2)
nokogiri (>= 1.4)
html-proofer (3.19.4)
addressable (~> 2.3)
mercenary (~> 0.3)
nokogiri (~> 1.13)
parallel (~> 1.10)
rainbow (~> 3.0)
typhoeus (~> 1.3)
yell (~> 2.0)
http_parser.rb (0.8.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
jekyll (3.9.0)
jekyll (3.9.2)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
Expand Down Expand Up @@ -147,6 +155,8 @@ GEM
jekyll-mentions (1.6.0)
html-pipeline (~> 2.3)
jekyll (>= 3.7, < 5.0)
jekyll-multiple-languages-plugin (1.8.0)
jekyll (>= 2.0, < 5.0)
jekyll-optional-front-matter (0.3.2)
jekyll (>= 3.0, < 5.0)
jekyll-paginate (1.1.0)
Expand Down Expand Up @@ -216,7 +226,7 @@ GEM
gemoji (~> 3.0)
html-pipeline (~> 2.2)
jekyll (>= 3.0, < 5.0)
kramdown (2.3.1)
kramdown (2.3.2)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
Expand All @@ -225,23 +235,23 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.3.6)
mini_portile2 (2.8.0)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.15.0)
multipart-post (2.1.1)
nokogiri (1.13.4)
mini_portile2 (~> 2.8.0)
nokogiri (1.13.6-arm64-darwin)
racc (~> 1.4)
octokit (4.22.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
parallel (1.22.1)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.7)
racc (1.6.0)
rainbow (3.1.1)
rb-fsevent (0.11.1)
rb-inotify (0.10.1)
ffi (~> 1.0)
Expand Down Expand Up @@ -271,13 +281,18 @@ GEM
unf_ext
unf_ext (0.0.8.1)
unicode-display_width (1.8.0)
webrick (1.7.0)
yell (2.2.2)
zeitwerk (2.5.4)

PLATFORMS
ruby
arm64-darwin-21

DEPENDENCIES
github-pages
html-proofer
jekyll-multiple-languages-plugin
webrick

BUNDLED WITH
1.17.2
2.3.14
11 changes: 3 additions & 8 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
repository: hyperledger/firefly
remote_theme: pmarsceill/just-the-docs
logo: "images/hyperledger-firefly_color.svg"
title: Hyperledger FireFly Docs
baseurl: /firefly
Expand All @@ -10,11 +9,7 @@ aux_links:
- "https://wiki.hyperledger.org/display/FIR"
"Discord":
- "https://discord.gg/hyperledger"
"Mailing List":
- "https://lists.hyperledger.org/g/firefly"
"Calendar":
- "https://lists.hyperledger.org/g/firefly/calendar"

remote_theme: pmarsceill/just-the-docs
color_scheme: firefly
plugins:
- jekyll-remote-theme # add this line to the plugins list if you already have one
- jekyll-multiple-languages-plugin
languages: ["en"]
27 changes: 27 additions & 0 deletions docs/_i18n/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
langs:
en: English
es: Español
site:
title: Hyperledger FireFly Docs
pages:
home: Home
advanced_cli_usage: Advanced CLI Usage
api_spec: API Spec
architecture: Architecture
api_post_syntax: API Post Syntax
api_query_syntax: API Query Syntax
blockchain_protocols: Blockchain protocols
broadcast_shared_data: Broadcast / shared data
broadcast_data: Broadcast data
code_hierarchy: FireFly Code Hierarchy
code_overview: FireFly Code Overview
code_repositories: Code Repositories
configuration_reference: Configuration Reference
contributors: Contributors
custom_smart_contracts: Work with custom smart contracts
faqs: FAQs
getting_started: Getting Started
private_data_exchange: Private data exchange
reference: Reference
tutorials: Tutorials
understanding_firefly: Understanding FireFly
13 changes: 13 additions & 0 deletions docs/_i18n/en/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Hyperledger FireFly

![Hyperledger FireFly](./images/hyperledger_firefly_social.png)

Hyperledger FireFly is the first open source Supernode: a complete stack for enterprises to build and scale secure Web3 applications.

The FireFly API for digital assets, data flows, and blockchain transactions makes it radically faster to build production-ready apps on popular chains and protocols.

- [Understanding FireFly](./overview/)
- [Reference](./reference/)
- [Architecture](./architecture/)
- [Contributors](./contributors/)
- [API Spec](./swagger/swagger.html)
10 changes: 10 additions & 0 deletions docs/_i18n/es.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pages:
home: Página principal
architecture: Arquitectura
api_spec: API Especificación
contributors: Colaboradores
faqs: Preguntas más frecuentes
getting_started: Empezando
reference: Referencia
tutorials: Tutoriales
understanding_firefly: Comprender FireFly
Loading

0 comments on commit 971ff47

Please sign in to comment.