Skip to content

Add example debugging-strategies #1799

Add example debugging-strategies

Add example debugging-strategies #1799

Workflow file for this run

name: continuous-integration
on:
pull_request:
types:
- opened
- reopened
- synchronize
paths-ignore:
- '**/*.md'
- 'CODEOWNERS'
- 'LICENSE'
- 'CODE_OF_CONDUCT.adoc'
- 'FILE_HEADER'
push:
branches:
- master
- v[0-9]+.[0-9]+.* # i.e. v1.0, v2.1rc1
tags:
- v*
paths-ignore:
- '**/*.md'
- 'CODEOWNERS'
- 'LICENSE'
- 'CODE_OF_CONDUCT.adoc'
- 'FILE_HEADER'
env:
# Image can be edited at https://github.com/use-ink/docker-images
IMAGE: useink/ci
CARGO_TARGET_DIR: /ci-cache/${{ github.repository }}/targets/
PURELY_STD_CRATES: ink/codegen metadata engine e2e e2e/macro ink/ir
ALSO_RISCV_CRATES: env storage storage/traits allocator prelude primitives ink ink/macro
# TODO `cargo clippy --all-targets --all-features` for this crate
# currently fails on `stable`, but succeeds on `nightly`. This is due to
# this fix not yet in stable: https://github.com/rust-lang/rust-clippy/issues/8895.
# Remove the following line again as soon as `clippy` on stable succeeds again.
CLIPPY_ALLOWED: clippy::extra_unused_lifetimes
# We plan to fully support RISC-V as a bytecode for contracts soon.
# RISC-V does not have a standard library in contrast to Wasm. Compiling against
# this target also makes sure that we don't pull in `std` by accident (through dependencies).
# RISC-V is a modular architecture. We might switch to a different flavor with more features
# later. For example, `riscv64imc-unknown-none-elf`.
RISCV_TARGET: .github/riscv64emac-unknown-none-polkavm.json
# Clippy doesn't support JSON files for `--target`, hence we use another RISC-V target.
CLIPPY_TARGET: riscv64imac-unknown-none-elf
concurrency:
# Cancel in-progress jobs triggered only on pull_requests
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
### lint
jobs:
set-image:
# GitHub Actions does not allow using 'env' in a container context.
# This workaround sets the container image for each job using the 'set-image' job output.
runs-on: ubuntu-latest
outputs:
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
steps:
- name: Maximize build space
uses: AdityaGarg8/remove-unwanted-software@v5
with:
remove-android: 'true'
remove-dotnet: 'true'
remove-codeql: 'true'
remove-haskell: 'true'
- id: set_image
run: echo "IMAGE=${{ env.IMAGE }}" >> $GITHUB_OUTPUT
spellcheck:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Rust Info
uses: ./.github/rust-info
- name: Check Spelling
run: |
cargo spellcheck check -v --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 -- recursive .
cargo spellcheck check -v --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 -- recursive ./integration-tests/*
fmt:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Rust Info
uses: ./.github/rust-info
- name: Check Formatting
run: |
zepter run check
cargo +nightly fmt --all -- --check
# For the UI tests we need to disable the license check
cargo +nightly fmt --all -- --check ./crates/ink/tests/ui/contract/{pass,fail}/*.rs
cargo +nightly fmt --all -- --check ./crates/ink/tests/ui/trait_def/{pass,fail}/*.rs
- name: Check Examples Formatting
run: |
scripts/for_all_contracts_exec.sh --path integration-tests -- cargo +nightly fmt --manifest-path {} -- --check
# This file is not a part of the cargo project, so it wouldn't be formatted the usual way
rustfmt +nightly --check ./integration-tests/public/psp22-extension/runtime/psp22-extension-example.rs
clippy:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Run Clippy
run: |
df -h ;
rustup toolchain remove nightly-2025-02-20 && rustup toolchain remove stable && rustup toolchain remove 1.85.0;
df -h ;
ALL_CRATES="${PURELY_STD_CRATES} ${ALSO_RISCV_CRATES}"
for crate in ${ALL_CRATES}; do
echo $crate;
cargo +nightly clippy --all-targets --all-features --manifest-path ./crates/${crate}/Cargo.toml \
-- -D warnings -A ${CLIPPY_ALLOWED};
done
clippy-riscv:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Run Clippy for RISC-V Crates
run: |
df -h ;
rustup toolchain remove nightly-2025-02-20 && rustup toolchain remove stable && rustup toolchain remove 1.85.0;
df -h ;
for crate in ${ALSO_RISCV_CRATES}; do
echo $crate;
cargo +nightly clippy --no-default-features --manifest-path ./crates/${crate}/Cargo.toml \
--target ${CLIPPY_TARGET} \
-- -D warnings -A ${CLIPPY_ALLOWED};
done
clippy-examples:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
type: [STD, RISCV]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Run Clippy for Examples
if: ${{ matrix.type == 'STD' }}
run: |
scripts/for_all_contracts_exec.sh --path integration-tests -- cargo clippy --all-targets \
--manifest-path {} -- -D warnings -A $CLIPPY_ALLOWED
- name: Run Clippy for RISC-V Examples
if: ${{ matrix.type == 'RISCV' }}
run: |
scripts/for_all_contracts_exec.sh --path integration-tests -- cargo clippy --no-default-features \
--target ${CLIPPY_TARGET} \
--manifest-path {} -- -D warnings -A $CLIPPY_ALLOWED
check:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
type: [STD, RISCV]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Check
if: ${{ matrix.type == 'STD' }}
run: |
ALL_CRATES="${PURELY_STD_CRATES} ${ALSO_RISCV_CRATES}"
for crate in ${ALL_CRATES}; do
cargo check --all-features --manifest-path ./crates/${crate}/Cargo.toml;
done
- name: Check RISCV
if: ${{ matrix.type == 'RISCV' }}
env:
RUSTC_BOOTSTRAP: 1
run: |
for crate in ${ALSO_RISCV_CRATES}; do
# remove `nightly` once new stable is released, currently there is an ICE in stable
cargo +nightly check --no-default-features --target $RISCV_TARGET -Zbuild-std="core,alloc" \
--manifest-path ./crates/${crate}/Cargo.toml;
done
dylint-checks:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Dylint
env:
# Setting incremental = 0 to reduce compilation artifact size.
# The CI otherwise fails with "no disk space"
CARGO_INCREMENTAL: 0
run: |
cd linting/
# we are using a toolchain file in this directory
# add required components for CI
cargo check --verbose
cargo +nightly fmt --all -- --check
cargo clippy -- -D warnings;
dylint-testing:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Dylint
env:
# Setting incremental = 0 to reduce compilation artifact size.
# The CI otherwise fails with "no disk space"
# todo Remove again at one point. This is a speed trade-off.
CARGO_INCREMENTAL: 0
run: |
cd linting/
cargo test --all-features
### workspace
build-std:
runs-on: ubuntu-latest
needs: [set-image, check]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Build for STD
run: |
ALL_CRATES="${PURELY_STD_CRATES} ${ALSO_RISCV_CRATES}"
for crate in ${ALL_CRATES}; do
cargo build --all-features --release --manifest-path ./crates/${crate}/Cargo.toml;
done
build-riscv:
runs-on: ubuntu-latest
needs: [set-image, check]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Build for RISC-V
run: |
for crate in ${ALSO_RISCV_CRATES}; do
echo ${crate};
RUSTFLAGS="--cfg substrate_runtime" cargo +nightly build \
--no-default-features --release \
--target $CLIPPY_TARGET \
--manifest-path ./crates/${crate}/Cargo.toml \
-Zbuild-std="core,alloc";
done
test:
runs-on: ubuntu-latest
# todo bring back more needs, so that we only run this `tests` stage
# if pre-conditions are filled.
# needs: [set-image, check]
needs: [set-image]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
partition: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
cache-on-failure: true
- name: Test
env:
# Fix for linking of `linkme` for `cargo test`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-dead-code -Clink-arg=-z -Clink-arg=nostart-stop-gc
# Since we run the tests with `--all-features` this implies the feature
# `ink-fuzz-tests` as well -- i.e. the fuzz tests are run.
# There's no way to disable a single feature while enabling all features
# at the same time, hence we use this workaround.
QUICKCHECK_TESTS: 0
run: |
rustup toolchain remove nightly-2025-02-20
rustup toolchain remove 1.85.0
rustup toolchain remove stable
cargo +nightly nextest run --all-features --no-fail-fast --workspace --locked --jobs 1 --partition count:${{ matrix.partition }}/35
test-docs:
runs-on: ubuntu-latest
needs: [set-image, check]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
workspace: [ink, linting]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Test
# todo check if this workspace condition is still necessary
if: ${{ matrix.workspace == 'ink' }}
env:
# Setting incremental = 0 to reduce compilation artifact size.
# The CI otherwise fails with "no disk space"
# todo Remove again at one point. This is a speed trade-off.
CARGO_INCREMENTAL: 0
# Fix for linking of `linkme` for `cargo test`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-dead-code -Clink-arg=-z -Clink-arg=nostart-stop-gc
# Since we run the tests with `--all-features` this implies the feature
# `ink-fuzz-tests` as well -- i.e. the fuzz tests are run.
# There's no way to disable a single feature while enabling all features
# at the same time, hence we use this workaround.
QUICKCHECK_TESTS: 0
run: |
cargo +nightly test --all-features --no-fail-fast --workspace --doc --locked
test-linting:
runs-on: ubuntu-latest
needs: [set-image, check]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
workspace: [ink, linting]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Test Linting
if: ${{ matrix.workspace == 'linting' }}
env:
# Fix for linking of `linkme` for `cargo test`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc -Clink-dead-code
# Since we run the tests with `--all-features` this implies the feature
# `ink-fuzz-tests` as well -- i.e. the fuzz tests are run.
# There's no way to disable a single feature while enabling all features
# at the same time, hence we use this workaround.
QUICKCHECK_TESTS: 0
run: |
pushd linting && cargo nextest run --all-features --no-fail-fast --workspace && popd
docs:
runs-on: ubuntu-latest
needs: [set-image, check, fmt, clippy, clippy-examples, dylint-checks, dylint-testing, spellcheck]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Create docs
env:
RUSTDOCFLAGS: -Dwarnings
run: |
for package in $(cargo metadata --format-version 1 | jq -r '.workspace_members[]' | awk '{print $1}'); do
# Run cargo doc for each workspace member
cargo +nightly doc --no-deps --all-features -p ${package}
done
mv ${CARGO_TARGET_DIR}/doc ./crate-docs
# FIXME: remove me after CI image gets nonroot
chown -R nonroot:nonroot ./crate-docs
- uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}-data
path: ./crate-docs
retention-days: 1
# todo bring this stage back
# codecov:
# runs-on: ubuntu-latest
# #needs: [set-image]
# container:
# image: xd009642/tarpaulin:develop-nightly
# options: --security-opt seccomp=unconfined
# # needs: [set-image, check, fmt, clippy, clippy-examples, dylint-checks, dylint-testing, spellcheck]
# defaults:
# run:
# shell: bash
# #container:
# #image: ${{ needs.set-image.outputs.IMAGE }}
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
#
# - name: Rust Info
# uses: ./.github/rust-info
#
# - name: Cache
# uses: Swatinem/rust-cache@v2
# with:
# cache-on-failure: true
# cache-directories: ${{ env.CARGO_TARGET_DIR }}
# cache-all-crates: true
#
# - name: Generate code coverage
# env:
# # For codecov it's sufficient to run the fuzz tests only once.
# QUICKCHECK_TESTS: 1
# INK_COVERAGE_REPORTING: true
# #CARGO_INCREMENTAL: 0
# run: |
# #rustup toolchain remove nightly-2025-02-20;
# #rustup toolchain remove stable;
# #rustup toolchain remove 1.85.0;
# #cargo +nightly install cargo-tarpaulin
# curl
# cargo +nightly tarpaulin --verbose --tests --all-features --all-targets --workspace --locked --out xml
#
# - name: Upload to codecov.io
# uses: codecov/codecov-action@v2
# with:
# # token: ${{secrets.CODECOV_TOKEN}} # not required for public repos
# fail_ci_if_error: true
### examples
examples-test:
runs-on: ubuntu-latest
needs: [fmt]
strategy:
fail-fast: false
matrix:
partition: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
cache-on-failure: true
- name: Test Examples
uses: docker://useink/ci
env:
# Fix for linking of `linkme` for `cargo test`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc -Clink-dead-code
with:
# Run all tests with --all-features, which will run the `e2e-tests` feature if present.
args:
/bin/bash -c "scripts/for_all_contracts_exec.sh --path integration-tests --ignore internal/static-buffer --ignore internal/mapping --partition ${{ matrix.partition }}/25 -- \
cargo +nightly test --all-features --all --manifest-path {}"
examples-test-mapping:
runs-on: ubuntu-latest
needs: [set-image]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
cache-on-failure: true
- name: Rust Info
uses: ./.github/rust-info
- name: Test Mapping Example
env:
# Fix for linking of `linkme` for `cargo test`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc -Clink-dead-code
# needed for `mapping::e2e_tests::fallible_storage_methods_work`
INK_STATIC_BUFFER_SIZE: 256
run:
rustup toolchain remove nightly-2025-02-20;
rustup toolchain remove stable;
rustup toolchain remove 1.85.0;
cargo +nightly test --all-features --all --manifest-path integration-tests/internal/mapping/Cargo.toml
examples-custom-test:
runs-on: ubuntu-latest
needs: [set-image, clippy, clippy-examples]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
cache-on-failure: true
- name: Rust Info
uses: ./.github/rust-info
- name: Test static-buffer example
env:
# Fix linking of `linkme`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc -Clink-dead-code
run: |
# run the static buffer test with a custom buffer size.
# the readme + test comments explain why `32`, in short because the tests write
# content into the buffer and want to provoke an exhaustion of the buffer.
cargo clean --manifest-path integration-tests/internal/static-buffer/Cargo.toml
INK_STATIC_BUFFER_SIZE=32 cargo +nightly-2025-02-20 test --manifest-path integration-tests/internal/static-buffer/Cargo.toml --all-features
- name: Run E2E test with on-chain contract
# todo disabled until `cargo-contract` supports mapping the account
if: false
env:
# Fix linking of `linkme`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc -Clink-dead-code
run: |
# run flipper E2E test with on-chain contract
ink-node -lruntime::revive=debug 2>&1 &
cargo +nightly contract build --release --manifest-path integration-tests/public/flipper/Cargo.toml
export CONTRACT_ADDR_HEX=$(cargo +nightly-2025-02-20 contract instantiate \
--manifest-path integration-tests/public/flipper/Cargo.toml \
--suri //Alice --args true -x -y --output-json | \
jq -r .contract | xargs subkey inspect | grep -o "0x.*" | head -n1)
CONTRACTS_NODE_URL=ws://127.0.0.1:9944 cargo +nightly-2025-02-20 test \
--features e2e-tests \
--manifest-path integration-tests/public/flipper/Cargo.toml \
e2e_test_deployed_contract \
-- --ignored --nocapture
examples-contract-build-riscv:
runs-on: ubuntu-latest
needs: [set-image]
# needs: [set-image, build-std, build-riscv]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
partition: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
cache-on-failure: true
- name: Rust Info
uses: ./.github/rust-info
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Build Contract Examples for RISC-V
env:
RUSTC_BOOTSTRAP: 1
MANIFEST_PATH: ""
CONTRACT_SIZE_FILE: "measurements-${{ steps.extract_branch.outputs.branch }}/contract_size_"
CARGO_INCREMENTAL: 0
run: |
mkdir -p measurements-${{ steps.extract_branch.outputs.branch }}/
scripts/for_all_contracts_exec2.sh --path integration-tests --partition ${{ matrix.partition }}/30 -- \
scripts/build_and_determine_contract_size.sh {}
#bash -c "scripts/build_and_determine_contract_size.sh {} >> ${CONTRACT_SIZE_FILE} && \
#sed -ie 's/^integration-tests\/\(public\/\|internal\/\)\?//' ${CONTRACT_SIZE_FILE}"
- uses: actions/upload-artifact@v4
with:
path: ./measurements-${{ steps.extract_branch.outputs.branch }}/*
name: ${{ env.RUN_UNIQUE_ID }}_artifact_${{ matrix.partition }}
retention-days: 1
process-contract-sizes:
needs: [examples-contract-build-riscv]
runs-on: ubuntu-latest
steps:
- name: Download reports' artifacts
uses: actions/download-artifact@v4
with:
path: downloaded_artifacts
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Combine contract sizes from individual examples
run: |
sed -e 's/^integration-tests\/\(public\/\|internal\/\)\?//' | \
sort | uniq > measurements-${{ steps.extract_branch.outputs.branch }}
cat measurements-${{ steps.extract_branch.outputs.branch }}
- uses: actions/upload-artifact@v4
with:
name: measurements-${{ steps.extract_branch.outputs.branch }}
path: ./measurements-${{ steps.extract_branch.outputs.branch }}
retention-days: 31
examples-docs:
runs-on: ubuntu-latest
needs: [set-image, build-std, build-riscv]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Create Examples Docs
env:
RUSTDOCFLAGS: -Dwarnings
run: |
# `--document-private-items` needs to be in here because currently our contract macro
# puts the contract functions in a private module.
# Once https://github.com/use-ink/ink/issues/336 has been implemented we can get rid
# of this flag.
scripts/for_all_contracts_exec.sh --path integration-tests -- cargo doc --manifest-path {} \
--document-private-items --no-deps
# measurements
# todo delete this stage and associated files
# measurements:
# needs: [examples-docs, examples-contract-build, examples-test, examples-custom-test, examples-test-mapping]
# uses: ./.github/workflows/measurements.yml
#
# fuzz
fuzz:
runs-on: ubuntu-latest
needs: [set-image, examples-docs, examples-contract-build-riscv, examples-test, examples-custom-test]
if: >
github.event_name == 'push' &&
github.ref == 'refs/heads/master'
permissions:
issues: write
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true
- name: Rust Info
uses: ./.github/rust-info
- name: Fuzz
id: fuzz_test
env:
QUICKCHECK_TESTS: 5000
run: |
rustup toolchain remove nightly-2025-02-20;
rustup toolchain remove stable;
rustup toolchain remove 1.85.0;
# We fuzz-test only crates which possess the `ink-fuzz-tests` feature
all_tests_passed=0
ALL_CRATES="${PURELY_STD_CRATES} ${ALSO_RISCV_CRATES}"
for crate in ${ALL_CRATES}; do
if grep "ink-fuzz-tests =" ./crates/${crate}/Cargo.toml;
then
cargo +nightly test --features ink-fuzz-tests --manifest-path ./crates/${crate}/Cargo.toml --no-fail-fast -- fuzz_ || exit_code=$?;
all_tests_passed=$(( all_tests_passed | exit_code ));
fi
done
exit ${all_tests_passed}
- name: Create Issue
if: ${{ failure() && steps.fuzz_test.conclusion == 'failure' }}
uses: actions/github-script@v7
with:
script: |
const runId = context.runId;
// Get the list of jobs for the current run using GitHub API
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId
});
// Find the job ID by name
const job = jobs.data.jobs.find(job => job.name === context.job);
if (!job) {
console.error(`Job with name '${jobName}' not found.`);
return;
}
const jobId = job.id;
const title = "[ci] Failing fuzz tests on master ('" + new Date().toLocaleDateString() + "')";
const runUrl = context.serverUrl + "/" + context.repo.owner + "/" + context.repo.repo + "/actions/runs/" + runId + "/job/" + jobId;
const commitUrl = context.serverUrl + "/" + context.repo.owner + "/" + context.repo.repo + "/commit/" + context.sha;
const message = context.payload.head_commit.message;
const body = `
The CI job [${runId}](${runUrl}) just failed.
The offending commit is [${message}](${commitUrl}).
`;
const issue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
assignees: [],
labels: ['P-high']
});
console.log(`Issue created: ${issue.data.html_url}`);
submit-contract-sizes:
runs-on: ubuntu-latest
needs: [set-image, process-contract-sizes]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
permissions:
pull-requests: write
if: github.ref != 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Extract GitHub
shell: bash
run: |
git config --global --add safe.directory /__w/ink/ink
ink_master_head=$(curl -s "https://api.github.com/repos/use-ink/ink/commits/master" | jq -r .sha)
head_in_branch=$(git log | grep -q $ink_master_head; echo $?)
echo "head_in_branch=$head_in_branch" >> $GITHUB_OUTPUT
id: extract_github
- name: Download master artifact
uses: dawidd6/action-download-artifact@v9
with:
workflow: ci.yml
branch: master
name: measurements-master
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Output branch name
run: |
echo "${{ steps.extract_branch.outputs.branch }}"
echo "${{ steps.extract_github.outputs.head_in_branch }}"
- name: Download artifact
uses: dawidd6/action-download-artifact@v9
with:
workflow: ci.yml
name: measurements-${{ steps.extract_branch.outputs.branch }}
branch: ${{ steps.extract_branch.outputs.branch }}
- name: Collect Contract Sizes
run: |
# Build the comparison table
cat measurements-master
cat measurements-${{ steps.extract_branch.outputs.branch }}
./scripts/contract_sizes_diff.sh measurements-master measurements-${{ steps.extract_branch.outputs.branch }} > contract_sizes_diff.md
cat contract_sizes_diff.md
- name: Submit Comment
env:
GITHUB_PR_TOKEN: ${{ secrets.github_token }}
GITHUB_PR_WORKFLOW_ID: ${{ github.event.workflow_run.id }}
PR_NUMBER: ${{ github.event.number }}
run: |
CARGO_CONTRACT_VERSION=$(cargo +nightly contract --version)
PR_COMMENTS_URL="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments"
WORKFLOW_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_PR_WORKFLOW_ID}"
# Submit the comparison table as a comment to the PR
echo "Submitting contract sizes diff to ${PR_COMMENTS_URL}"
GITHUB_PR_TOKEN=${GITHUB_PR_TOKEN} .github/scripts/contract_sizes_submit.sh ${PR_COMMENTS_URL} ${WORKFLOW_URL} ${CARGO_CONTRACT_VERSION} ${{ steps.extract_github.outputs.head_in_branch }}${head_in_branch} < ./contract_sizes_diff.md