Skip to content

Commit

Permalink
chore: add build profiles to the commands (#4198)
Browse files Browse the repository at this point in the history
* chore: add build profiles to the commands

* chore: lots of benchmarking stuff

* chore: move benchmarking to new job

* chore: try with profile

* fix: matrix

* fix: don't build runtime separately

* fix: name of artifacts

* fix: permissions

* [skip-ci] fix: workflow permissions 🐛

* fix: remove old branch

* [skip-ci] fix: the f* permissions 🤬🐛

* [skip-ci] fix: delete binary 🧹

* Update .cargo/config.toml

* fix: berghain prifile name

---------

Co-authored-by: Assem Hasna <asem.hasna@gmail.com>
  • Loading branch information
tomjohnburton and ahasna authored Nov 10, 2023
1 parent 22e9288 commit cabb2f2
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ cf-clippy = "clippy --all-targets --features runtime-benchmarks,try-runtime,runt
cf-clippy-ci = "clippy --all-targets --features runtime-benchmarks,try-runtime,runtime-integration-tests,slow-tests -- -D warnings"

cf-build = "build --features runtime-benchmarks"
cf-build-ci = "build --features runtime-benchmarks"

cf-build-release = "build --release"
cf-build-production = "build --profile=production"
# Check for feature inconsistencies.
check-sc-features = '''
tree --no-default-features --depth 1 --edges=features,normal
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/_02_retrieve-bins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: dawidd6/action-download-artifact@v2
with:
workflow: release-sisyphos.yml
name: chainflip-node-runtime-ubuntu-${{ matrix.ubuntu_version }}
name: chainflip-node-runtime-production
branch: release/${{ env.MAJOR_MINOR }}
github_token: ${{ secrets.CF_GITHUB_BOT_TOKEN }}
search_artifacts: true
Expand Down Expand Up @@ -66,6 +66,6 @@ jobs:
- name: Re-upload runtime artifacts
uses: actions/upload-artifact@v3
with:
name: chainflip-node-runtime-ubuntu-${{ matrix.ubuntu_version }}
name: chainflip-node-runtime-production
path: |
./state_chain_runtime*.wasm
41 changes: 31 additions & 10 deletions .github/workflows/_100_run_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_dispatch:
inputs:
commit_sha:
description: "Which Commit SHA should we get the binaries from? (Use 'sisyphos' for release branches and 'perseverance' for tags)"
description: "Which Commit SHA should we get the binaries from?"
required: true
type: string
base_branch_name:
Expand All @@ -28,12 +28,22 @@ on:
options:
- 4vCPU-8GB
- 4vCPU-16GB
profile:
description: "Which profile should we use?"
required: false
type: choice
options:
- production
- release

env:
FORCE_COLOR: 1

jobs:
run_benchmarks:
permissions:
contents: write
pull-requests: write
runs-on:
[
self-hosted,
Expand All @@ -45,27 +55,38 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Download binary to benchmark
run: |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 14DFB4CA9296F83A
echo "deb https://${{ secrets.CF_APT_REPO_BASIC_AUTH_USERNAME }}:${{ secrets.CF_APT_REPO_BASIC_AUTH_PASSWORD }}@apt.aws.chainflip.xyz/${{ inputs.commit_sha }}/$(lsb_release -c -s) $(lsb_release -c -s) main" | sudo tee /etc/apt/sources.list.d/chainflip.list
sudo apt update
sudo apt install chainflip-node
- name: Fetch chainflip-node with benchmarks from ${{ inputs.commit_sha }}
uses: dawidd6/action-download-artifact@v2
with:
workflow: ci-benchmarks.yml
workflow_conclusion: completed
name: chainflip-node-ubuntu-20.04-benchmarks-${{ inputs.profile }}
commit: ${{ inputs.commit_sha }}
github_token: ${{ secrets.CF_GITHUB_BOT_TOKEN }}
search_artifacts: true
check_artifacts: true

- name: Update permissions on chainflip-node
run: chmod +x ./chainflip-node

- name: Run benchmarks
run: >
./state-chain/scripts/benchmark-all.sh
--binary /usr/bin/chainflip-node
--binary ./chainflip-node
--steps ${{ github.event.inputs.steps }}
--repetitions ${{ github.event.inputs.repetitions }}
- name: Cleanup
run: >
rm ./chainflip-node
- name: Make a pull request with the changed weight files
uses: peter-evans/create-pull-request@v4
uses: peter-evans/create-pull-request@v5
with:
base: ${{ inputs.base_branch_name }}
title: "[AUTOMATED] Benchmark results"
commit-message: "[AUTOMATED] Benchmarking results."
body: "This pull request was opened automatically. Close it if you think it was opened in error."
branch: auto/benchmark-results
delete-branch: true
token: ${{ secrets.CF_GITHUB_BOT_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/_20_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
- name: Setup sccache
run: ./ci/scripts/install_sccache.sh $SCCACHE_VERSION

- name: Build
- name: Build chainflip binaries
run: |
cargo cf-build-ci --locked --profile=${{ inputs.profile }}
cargo cf-build-${{ inputs.profile }} --locked
sccache --show-stats
- name: Upload binary artifacts
Expand All @@ -50,9 +50,9 @@ jobs:
./target/${{ inputs.profile }}/chainflip-lp-api
./target/${{ inputs.profile }}/chainflip-ingress-egress-tracker
- name: Upload binary artifacts
- name: Upload runtime artifacts
uses: actions/upload-artifact@v3
with:
name: chainflip-node-runtime-ubuntu-${{ matrix.ubuntu_version }}
name: chainflip-node-runtime-${{ inputs.profile }}
path: |
./target/${{ inputs.profile }}/wbuild/state-chain-runtime/state_chain_runtime*.wasm
17 changes: 0 additions & 17 deletions .github/workflows/_40_post_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,3 @@ jobs:
#️⃣ Tagging: <@&939151218708709416>
https://media.giphy.com/media/wHfwCBZzCMhmE/giphy.gif
benchmarks:
runs-on: [hetzner]
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download previously built binaries
uses: actions/download-artifact@v3
with:
name: chainflip-backend-bin-ubuntu-20.04
path: ./target/release

- name: Run benchmarks
run: |
chmod +x ./target/release/chainflip-node
./state-chain/scripts/benchmark-all.sh --binary ./target/release/chainflip-node --steps 2 --repetitions 1
2 changes: 1 addition & 1 deletion .github/workflows/_60_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Download runtime
uses: actions/download-artifact@v3
with:
name: chainflip-node-runtime-ubuntu-22.04
name: chainflip-node-runtime-production
path: assets/runtime

- name: Download public images
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/ci-benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build chainflip-node with benchmarks
on:
push:
branches:
- main
- release/*

jobs:
build:
runs-on: [hetzner]
strategy:
matrix:
ubuntu_version: [20.04]
profile: [release, production]
container:
image: "ghcr.io/${{ github.repository }}/rust-base:nightly-2023-07-31-ubuntu-${{ matrix.ubuntu_version }}-27"
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup sccache
run: ./ci/scripts/install_sccache.sh $SCCACHE_VERSION

- name: Build with benchmarks
run: |
cargo build --profile=${{ matrix.profile }} --locked --features runtime-benchmarks -p chainflip-node
sccache --show-stats
- name: Upload chainflip-node binary artifact with benchmarks
uses: actions/upload-artifact@v3
with:
name: chainflip-node-ubuntu-${{ matrix.ubuntu_version }}-benchmarks-${{ matrix.profile }}
path: |
./target/${{ matrix.profile }}/chainflip-node
benchmarks:
runs-on: [hetzner]
needs: [build]
timeout-minutes: 120
strategy:
matrix:
ubuntu_version: [20.04]
profile: [release, production]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download previously built binaries
uses: actions/download-artifact@v3
with:
name: chainflip-node-ubuntu-${{ matrix.ubuntu_version }}-benchmarks-${{ matrix.profile }}

- name: Run benchmarks
run: |
chmod +x ./chainflip-node
./state-chain/scripts/benchmark-all.sh --binary ./chainflip-node --steps 2 --repetitions 1
4 changes: 2 additions & 2 deletions .github/workflows/release-berghain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: ./.github/workflows/_20_build.yml
secrets: inherit
with:
profile: "release"
profile: "production"
package:
needs: [build]
uses: ./.github/workflows/_25_package.yml
Expand All @@ -33,4 +33,4 @@ jobs:
secrets: inherit
with:
network: "berghain"
version: "${{ github.ref_name }}"
version: "${{ github.ref_name }}"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ You can use either release or debug builds.
From the repo root, run the following:

```shell
cargo cf-build # or cargo cf-build-ci
cargo cf-build # or cargo cf-build-release
./localnet/manage.sh
```

Expand Down

0 comments on commit cabb2f2

Please sign in to comment.