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

Implement mithril client wasm in explorer #1426

Merged
merged 12 commits into from
Jan 12, 2024
Merged
2 changes: 1 addition & 1 deletion .github/workflows/actions/publish-npm-package/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ runs:
echo "Build '@${{ inputs.scope }}/${{ inputs.package }}' package"
cp ./LICENSE ./mithril-client-wasm/
cp -f ./mithril-client-wasm/npm/README.md ./mithril-client-wasm/
wasm-pack build ${{ inputs.package }} --release --target bundler --out-dir ./pkg --scope ${{ inputs.scope }} --out-name index
wasm-pack build ${{ inputs.package }} --release --target web --out-dir ./pkg --scope ${{ inputs.scope }} --out-name index

- name: List package
shell: bash
Expand Down
186 changes: 185 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
shell: bash
run: |
cp LICENSE ./mithril-client-wasm/
wasm-pack build mithril-client-wasm --release --target bundler --out-dir ./pkg --scope mithril-dev --out-name index
wasm-pack build mithril-client-wasm --release --target web --out-dir ./pkg --scope mithril-dev --out-name index

- name: Prepare 'mithril-client-wasm' package
shell: bash
Expand Down Expand Up @@ -635,3 +635,187 @@ jobs:
loki_ingest_username: ${{ secrets.LOKI_INGEST_USERNAME }}
loki_ingest_password: ${{ secrets.LOKI_INGEST_PASSWORD }}

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 \
--all-features --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: 18
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
needs: build-test-wasm
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Download built artifacts
uses: actions/download-artifact@v3
with:
name: mithril-distribution-wasm
path: mithril-client-wasm

- name: Unpack 'mithril-client-wasm' package
working-directory: mithril-client-wasm
run:
tar -xvzf pkg/*.tgz -C pkg/ && mv pkg/package/* pkg/

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
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
186 changes: 0 additions & 186 deletions .github/workflows/docs.yml

This file was deleted.

Loading