-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmarks and docs. Reorganize jobs,less code
- Loading branch information
Showing
8 changed files
with
280 additions
and
232 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: Benchmark | ||
on: | ||
issue_comment: | ||
types: [created] | ||
jobs: | ||
benchmark: | ||
permissions: | ||
pull-requests: write | ||
id-token: write | ||
name: benchmark | ||
runs-on: ubuntu-latest-8-cores | ||
if: ${{ startsWith(github.event.comment.body, '/benchmark ') && github.event.issue.pull_request && contains(github.event.comment.author_association, 'CONTRIBUTOR') }} | ||
env: | ||
RUST_TOOLCHAIN: "1.66.0" | ||
RUSTC_WRAPPER: "sccache" | ||
steps: | ||
- uses: actions/github-script@v6 | ||
name: Parse Runtime From Comment | ||
id: parse-runtime | ||
with: | ||
result-encoding: string | ||
script: | | ||
console.log("Comment body", context.payload.comment.body) | ||
const [, , runtime] = context.payload.comment.body.split(/\W+/) | ||
if (!['centrifuge', 'altair'].includes(runtime)) throw new Error('Unsupported Runtime: ${runtime}') | ||
return `${runtime}` | ||
- uses: actions/github-script@v6 | ||
name: Acknowledge Run Comment | ||
id: ack-run-comment | ||
with: | ||
script: | | ||
const comment = await github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: `:clock1: Running Benchmarks for \`${{steps.parse-runtime.outputs.result}}\` :clock1:` | ||
}) | ||
return comment.data.id | ||
- name: Get PR Hash | ||
id: get_pr_hash | ||
uses: actions/github-script@v6 | ||
with: | ||
result-encoding: string | ||
script: | | ||
const number = context.payload.issue.number; | ||
const pr = await github.rest.pulls.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: number | ||
}); | ||
return pr.data.head.sha | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ steps.get_pr_hash.outputs.result }} | ||
|
||
- name: Prep build on Ubuntu | ||
uses: ./.github/actions/prep-ubuntu | ||
with: | ||
RUST_TOOLCHAIN: ${{ matrix.rust_version }} | ||
|
||
- name: SCcache setup | ||
uses: ./.github/actions/sccache-gcloud | ||
with: | ||
GWIP: ${{ secrets.GWIP_SCCACHE }} | ||
GSA: ${{ secrets.GSA_SCCACHE }} | ||
|
||
- name: Run Benchmark ${{steps.parse-runtime.outputs.result}} | ||
run: ./scripts/runtime_benchmarks.sh ${{steps.parse-runtime.outputs.result}} | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{steps.parse-runtime.outputs.result}}-weights | ||
path: runtime/${{steps.parse-runtime.outputs.result}}/src/weights/ | ||
|
||
- uses: actions/github-script@v6 | ||
name: Notify Benchmark finished | ||
with: | ||
script: | | ||
const id = `${{steps.ack-run-comment.outputs.result}}` | ||
await github.rest.issues.updateComment({ | ||
comment_id: id, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: ` | ||
:white_check_mark: Uploaded benchmarks for: \`${{steps.parse-runtime.outputs.result}}\` :white_check_mark: | ||
Find the artifact here: https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId} | ||
` | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,64 +2,29 @@ on: | |
push: | ||
branches: [main, 'release-v**'] | ||
pull_request: | ||
name: Build and publish WASMs | ||
name: Build&Publish WASM | ||
concurrency: | ||
group: 'build-wasm-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | ||
cancel-in-progress: true | ||
jobs: | ||
build-node: | ||
name: ci-build-node | ||
runs-on: ubuntu-latest-4-cores | ||
env: | ||
RUST_TOOLCHAIN: "nightly-2022-11-14" | ||
# RUSTFLAGS: " -W unused-extern-crates" | ||
PACKAGE: "altair-runtime" | ||
SCCACHE_GHA_ENABLED: "true" | ||
# RUSTC_WRAPPER: "sccache" | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #3.5.2 | ||
|
||
- name: Prep build on Ubuntu | ||
uses: ./.github/actions/prep-ubuntu | ||
with: | ||
RUST_TOOLCHAIN: ${{ env. RUST_TOOLCHAIN }} | ||
|
||
# TEST 1: run sccache vanilla using the developer's action | ||
- name: Setup sccache | ||
uses: mozilla-actions/[email protected] | ||
|
||
- name: Reset cache (main branch only) | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
run: echo "SCCACHE_RECACHE=true" >> $GITHUB_ENV | ||
|
||
- name: Check cargo build release | ||
run: cargo build --release "$@" | ||
|
||
- name: Run sccache stat for check | ||
shell: bash | ||
run: ${SCCACHE_PATH} --show-stats | ||
|
||
build-runtime-wasms: | ||
strategy: | ||
matrix: | ||
# To test until I get one right | ||
# target: [build-runtime, build-runtime-fast, build-runtime-testnet] | ||
# package: [centrifuge-runtime, altair-runtime] | ||
target: [build-runtime-fast] | ||
target: [build-runtime-fast, build-runtime-testnet] | ||
package: [altair-runtime] | ||
rust_version: ["1.66.0"] | ||
exclude: | ||
- target: "build-runtime-testnet" | ||
package: "centrifuge-runtime" | ||
name: ${{ matrix.target }}-${{ matrix.package }} | ||
runs-on: ubuntu-latest-4-cores | ||
env: | ||
# Cannot make sccache work with the srtool container | ||
# env: | ||
# SCCACHE_GHA_ENABLED: "true" | ||
RUSTC_WRAPPER: "sccache" | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' # needed for gcloud login | ||
# RUSTC_WRAPPER: "sccache" | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #3.5.2 | ||
|
@@ -68,32 +33,51 @@ jobs: | |
uses: ./.github/actions/prep-ubuntu | ||
with: | ||
RUST_TOOLCHAIN: ${{ matrix.rust_version }} | ||
|
||
# TEST 2: Sccache with Google Buckets | ||
- name: SCcache setup | ||
uses: ./.github/actions/sccache-gcloud | ||
|
||
- uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # 2.6.2 | ||
with: | ||
GWIP: ${{ secrets.GWIP_SCCACHE }} | ||
GSA: ${{ secrets.GSA_SCCACHE }} | ||
prefix-key: build | ||
shared-key: wasm | ||
# save-if: ${{ github.ref == 'refs/heads/master' }} | ||
|
||
# TEST 2: Sccache with Google Buckets | ||
# FAILED: does not work inside the srtool container | ||
# - name: SCcache setup | ||
# uses: ./.github/actions/sccache-gcloud | ||
# with: | ||
# GWIP: ${{ secrets.GWIP_SCCACHE }} | ||
# GSA: ${{ secrets.GSA_SCCACHE }} | ||
|
||
- name: Setup build options | ||
id: buildopt | ||
run: | | ||
if ${{ matrix.target == 'build-runtime-testnet'}} ; then | ||
echo "BUILD_OPTS="--features=testnet-runtime"" >> GITHUB_ENV | ||
elif ${{ matrix.target == 'build-runtime-fast'}} ; then | ||
echo "BUILD_OPTS="--features=fast-runtime"" >> GITHUB_ENV | ||
fi | ||
- name: Run Docker SRTool | ||
uses: addnab/docker-run-action@v3 | ||
env: | ||
RUSTC_VERSION: ${{ matrix.rust_version }} | ||
BUILD_OPTS: ${{ env.BUILD_OPTS }} | ||
with: | ||
image: paritytech/srtool:${{ matrix.rust_version }} | ||
options: --user root -v ${{ env.SCCACHE_PATH }}:/usr/local/bin/sccache -v ${{ github.workspace }}/.cargo:/cargo-home -v ${{ github.workspace }}:/build -e PACKAGE=${{ matrix.package }} | ||
options: --user root -v /home/runner/.cargo:/cargo-home -v ${{ github.workspace }}:/build -e PACKAGE=${{ matrix.package }} | ||
run: | | ||
# apt-get update && apt-get install --yes libpq-dev wget | ||
# wget https://github.com/mozilla/sccache/releases/download/v0.5.4/sccache-dist-v0.5.4-x86_64-unknown-linux-musl.tar.gz \ | ||
# && tar xzf sccache-dist-v0.5.4-x86_64-unknown-linux-musl.tar.gz \ | ||
# && mv sccache-v0.2.15-x86_64-unknown-linux-musl/sccache /usr/local/bin/sccache \ | ||
# && chmod +x /usr/local/bin/sccache | ||
echo "BUILD_OPT=${BUILD_OPT}" | ||
echo "PACKAGE=${PACKAGE}" | ||
echo "---- List Cache Folder ----" | ||
ls -la /cargo-home/ | ||
du -sh /cargo-home/* | ||
echo "---- Rust Versions ----" | ||
rustc --version | ||
rustup --version | ||
cargo --version | ||
echo "---- RUNNING BUILD ----" | ||
/srtool/build | ||
- name: Run sccache stat for check | ||
shell: bash | ||
run: ${SCCACHE_PATH} --show-stats | ||
|
||
|
||
# - if: ${{ matrix.target }} != "build-node" | ||
# name: Upload WASM to GHA | ||
# uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #@3.1.2 | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Rustdoc | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
jobs: | ||
docs: | ||
permissions: | ||
contents: write | ||
id-token: write | ||
runs-on: ubuntu-latest | ||
env: | ||
RUST_TOOLCHAIN: "1.66.0" | ||
RUSTDOCFLAGS: "-D warnings" | ||
RUSTC_WRAPPER: "sccache" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Prep build on Ubuntu | ||
uses: ./.github/actions/prep-ubuntu | ||
with: | ||
RUST_TOOLCHAIN: ${{ matrix.rust_version }} | ||
|
||
- name: SCcache setup | ||
uses: ./.github/actions/sccache-gcloud | ||
with: | ||
GWIP: ${{ secrets.GWIP_SCCACHE }} | ||
GSA: ${{ secrets.GSA_SCCACHE }} | ||
|
||
- name: Build documentation | ||
id: build_docs | ||
run: cargo doc --all --no-deps | ||
|
||
|
||
- name: Build Documentation failed | ||
if: always() && steps.build_docs.outcome == 'failure' | ||
run: echo ":::error::cargo doc --all --no-deps failed" | ||
# Job will stop here and the check will be red if Build documentation failed | ||
|
||
- name: Create Index file | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
echo "<meta http-equiv=\"refresh\" content=\"0; url=centrifuge_chain/index.html\">" \ > ./target/doc/index.html | ||
- name: Deploy Docs | ||
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # 3.9.3 | ||
if: github.ref == 'refs/heads/main' | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_branch: gh-pages | ||
publish_dir: ./target/doc | ||
cname: reference.centrifuge.io | ||
force_orphan: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
on: | ||
push: | ||
branches: [main, 'release-v**'] | ||
pull_request: | ||
paths: | ||
- 'src/' | ||
- '.github/workflows/tests.yml' | ||
name: Sanity checks | ||
concurrency: | ||
group: 'tests-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | ||
cancel-in-progress: true | ||
permissions: | ||
id-token: write | ||
contents: read | ||
jobs: | ||
lint-test-build: | ||
name: ${{ matrix.target }} | ||
runs-on: ubuntu-latest-4-cores | ||
strategy: | ||
matrix: | ||
target: [tests-general, test-integration, | ||
lint-fmt, lint-clippy, cargo-build, benchmark-check] # ,lint-taplo] | ||
env: | ||
RUST_TOOLCHAIN: "nightly-2022-11-14" | ||
# SCCACHE_GHA_ENABLED: "true" | ||
RUSTC_WRAPPER: "sccache" | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #3.5.2 | ||
|
||
- name: Prep build on Ubuntu | ||
uses: ./.github/actions/prep-ubuntu | ||
with: | ||
RUST_TOOLCHAIN: ${{ env.RUST_TOOLCHAIN }} | ||
|
||
# - name: Swatinem rust cache setup | ||
# uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191 # 2.6.0 | ||
# with: | ||
# prefix-key: cache | ||
# shared-key: cargo-tests | ||
# # cache-on-failure: "true" | ||
# # save-if: ${{ github.ref == 'refs/heads/master' }} | ||
|
||
- name: SCcache setup | ||
uses: ./.github/actions/sccache-gcloud | ||
with: | ||
GWIP: ${{ secrets.GWIP_SCCACHE }} | ||
GSA: ${{ secrets.GSA_SCCACHE }} | ||
|
||
- name: Runing cargo ${{ matrix.target }} | ||
run: ./ci/run-check ${{ matrix.target }} | ||
|
||
|
||
# - name: Run tests | ||
# run: ./ci/script.sh | ||
# env: | ||
# TARGET: ${{ matrix.target }} |
Oops, something went wrong.