Merge pull request #1349 from input-output-hk/ensemble/1311-mithril-c… #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Documentations & Explorer | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
types: [opened, reopened, synchronize] | |
concurrency: | |
group: ci-docs-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
cargo-doc: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Install stable toolchain and restore cache | |
uses: ./.github/workflows/actions/toolchain-and-cache | |
with: | |
cache-version: ${{ secrets.CACHE_VERSION }} | |
cargo-tools: clippy-sarif sarif-fmt | |
- name: Generate cargo doc | |
run: | | |
cargo doc --no-deps -p mithril-stm -p mithril-common -p mithril-aggregator \ | |
-p mithril-signer -p mithril-client -p mithril-client-cli --message-format=json \ | |
| clippy-sarif | tee rust-cargo-doc-results.sarif | sarif-fmt | |
# Update tool sarif metadata from "clippy" to "cargo-doc" (since it's set this way by clippy-sarif) | |
contents=$(cat rust-cargo-doc-results.sarif \ | |
| jq '.runs[].tool.driver.name = "cargo-doc"' \ | |
| jq '.runs[].tool.driver.informationUri = "https://doc.rust-lang.org/cargo/commands/cargo-doc.html"' \ | |
) | |
echo -E "${contents}" > rust-cargo-doc-results.sarif | |
# Make this step fail if any warning has been found | |
if [[ $(cat rust-cargo-doc-results.sarif | jq '.runs[0].results') != "[]" ]]; then | |
false | |
fi | |
- name: Upload cargo-doc results to GitHub | |
if: success() || failure() | |
uses: github/codeql-action/upload-sarif@v2 | |
with: | |
sarif_file: rust-cargo-doc-results.sarif | |
wait-for-processing: true | |
- name: Publish Mithril-rust-doc | |
uses: actions/upload-artifact@v3 | |
with: | |
name: mithril-rust-doc | |
if-no-files-found: error | |
path: | | |
target/doc/ | |
build-docusaurus: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: 'yarn' | |
cache-dependency-path: docs/website/yarn.lock | |
- name: Build Docusaurus site | |
working-directory: docs/website | |
run: | | |
yarn && yarn build | |
- name: Publish Docusaurus build | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docusaurus-build | |
if-no-files-found: error | |
path: | | |
docs/website/build/* | |
build-test-explorer: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: 'yarn' | |
cache-dependency-path: mithril-explorer/yarn.lock | |
- name: Install dependencies | |
working-directory: mithril-explorer | |
run: yarn install --frozen-lockfile | |
- name: Test explorer | |
working-directory: mithril-explorer | |
run: make test | |
- name: Check explorer | |
working-directory: mithril-explorer | |
run: make lint | |
- name: Build Explorer | |
working-directory: mithril-explorer | |
run: make build | |
- name: Publish Explorer build | |
uses: actions/upload-artifact@v3 | |
with: | |
name: explorer-build | |
if-no-files-found: error | |
path: | | |
mithril-explorer/out/* | |
build-open-api-ui: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Build OpenAPI UI | |
uses: Legion2/swagger-ui-action@v1 | |
with: | |
output: out/ | |
spec-file: ./openapi.yaml | |
- name: Publish OpenAPI UI build | |
uses: actions/upload-artifact@v3 | |
with: | |
name: openapi-ui-build | |
if-no-files-found: error | |
path: | | |
out/* | |
publish-docs: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-22.04 | |
needs: | |
- cargo-doc | |
- build-docusaurus | |
- build-test-explorer | |
- build-open-api-ui | |
steps: | |
- name: Download mithril-rust-doc artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: mithril-rust-doc | |
path: ./github-pages/rust-doc | |
- name: Download Docusaurus build | |
uses: actions/download-artifact@v3 | |
with: | |
name: docusaurus-build | |
path: ./github-pages/doc | |
- name: Download Explorer build | |
uses: actions/download-artifact@v3 | |
with: | |
name: explorer-build | |
path: ./github-pages/explorer | |
- name: Download OpenAPI UI build | |
uses: actions/download-artifact@v3 | |
with: | |
name: openapi-ui-build | |
path: ./github-pages/openapi-ui | |
- name: Add CNAME & Redirect | |
run: | | |
echo "mithril.network" > ./github-pages/CNAME | |
echo '<!DOCTYPE html><html><head><meta http-equiv="Refresh" content="0; URL=https://mithril.network/doc"></head></html>' > ./github-pages/index.html | |
- name: Mithril / Publish GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN || github.token }} | |
publish_dir: ./github-pages |