Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 95 additions & 90 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ on:
env:
# Image can be edited at https://github.com/use-ink/docker-images
IMAGE: useink/ci
CARGO_TARGET_DIR: /ci-cache/${{ github.repository }}/targets/${{ github.ref_name }}/${{ github.job }}
CARGO_TARGET_DIR: /ci-cache/${{ github.repository }}/targets/${{ github.ref_name }}/
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
Expand Down Expand Up @@ -142,6 +142,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand Down Expand Up @@ -176,6 +177,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand Down Expand Up @@ -214,6 +216,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand Down Expand Up @@ -253,6 +256,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand Down Expand Up @@ -294,6 +298,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand Down Expand Up @@ -330,6 +335,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand Down Expand Up @@ -368,6 +374,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand All @@ -394,14 +401,19 @@ jobs:

test:
runs-on: ubuntu-latest
needs: [check]
# 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]
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
Expand All @@ -411,11 +423,10 @@ jobs:
- name: Cache
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: |
${{ env.CARGO_TARGET_DIR }}
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Test
uses: docker://useink/ci
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
Expand All @@ -424,10 +435,9 @@ jobs:
# 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
#rustup toolchain remove nightly-2025-02-20 && rustup toolchain remove stable && rustup toolchain remove 1.85.0;
with:
args:
/bin/bash -c "cargo +nightly nextest run --all-features --no-fail-fast --workspace --locked --jobs 2 --partition count:${{ matrix.partition }}/20"
run: |
rustup toolchain remove nightly-2025-02-20; rustup toolchain remove stable; rustup toolchain remove 1.85.0;
cargo +nightly nextest run --all-features --no-fail-fast --workspace --locked --jobs 1 --partition count:${{ matrix.partition }}/30

test-docs:
runs-on: ubuntu-latest
Expand All @@ -450,8 +460,8 @@ jobs:
- name: Cache
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: |
${{ env.CARGO_TARGET_DIR }}
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand Down Expand Up @@ -495,8 +505,9 @@ jobs:
- name: Cache
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: |
${{ env.CARGO_TARGET_DIR }}
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info

Expand Down Expand Up @@ -531,6 +542,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand All @@ -553,69 +565,54 @@ jobs:
path: ./crate-docs
retention-days: 1

codecov:
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: 0

- name: Rust Info
uses: ./.github/rust-info

- name: Codecov
env:
# For codecov it's sufficient to run the fuzz tests only once.
QUICKCHECK_TESTS: 1
INK_COVERAGE_REPORTING: true
CARGO_INCREMENTAL: 0
# Needed because `codecov` requires nightly features to work
# (see `-Z` in the `RUSTFLAGS` below).
RUSTC_BOOTSTRAP: 1
RUSTDOCFLAGS: -Cpanic=abort
# Variables partly came from https://github.com/mozilla/grcov/blob/master/README.md
RUSTFLAGS: -Zmir-opt-level=0 -Ccodegen-units=1
-Clink-dead-code -Copt-level=0 -Coverflow-checks=off
-Cinstrument-coverage -Zpanic_abort_tests
# The `cargo-tarpaulin` coverage reporting tool seems to have better code instrumentation and thus
# produces better results for Rust codebases in general. However, unlike `grcov` it requires
# running docker with `--security-opt seccomp=unconfined` which is why we use `grcov` instead.
CODECOV_L_TOKEN: ${{ secrets.CODECOV_L_TOKEN }}
run: |
df -h
rustup toolchain remove nightly-2025-02-20;
rustup toolchain remove stable;
df -h
# rustup toolchain remove 1.85.0;
# RUSTFLAGS are the cause target cache can't be used here
# FIXME: rust-covfix doesn't support the external target dir
# https://github.com/Kogia-sima/rust-covfix/issues/7
unset "CARGO_TARGET_DIR"
# cargo +nightly clean
# make sure there are no stale coverage artifacts
find . -name "*.profraw" -type f -delete
find . -name "*.gcda" -type f -delete
# FIXME: Access from 2 users, should be solved once ci-image works from a non-root user
git config --global --add safe.directory '*'
cargo +nightly build --all-features --workspace
cargo +nightly test --all-features --no-fail-fast --workspace --locked -- --skip ui_tests
# coverage with branches
grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --branch \
--ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info
rust-covfix lcov-w-branch.info --output lcov-w-branch-fixed.info
codecov --token "$CODECOV_L_TOKEN" --file lcov-w-branch-fixed.info --nonZero
# lines coverage
grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm \
--ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info
rust-covfix lcov-lines.info --output lcov-lines-fixed.info
codecov --token "$CODECOV_L_TOKEN" --file lcov-lines-fixed.info --nonZero
# 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@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
# 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

Expand All @@ -636,6 +633,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Test Examples
uses: docker://useink/ci
Expand Down Expand Up @@ -666,6 +664,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand Down Expand Up @@ -702,6 +701,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand All @@ -715,7 +715,7 @@ jobs:
# 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 test --manifest-path integration-tests/internal/static-buffer/Cargo.toml --all-features
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
Expand All @@ -727,11 +727,11 @@ jobs:
# run flipper E2E test with on-chain contract
substrate-contracts-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 contract instantiate \
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 test \
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 \
Expand Down Expand Up @@ -760,6 +760,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand Down Expand Up @@ -796,6 +797,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand All @@ -812,20 +814,22 @@ jobs:
--document-private-items --no-deps

# measurements

measurements:
needs: [examples-docs, examples-contract-build, examples-test, examples-custom-test, examples-test-mapping]
uses: ./.github/workflows/measurements.yml
# todo bring this stage back
# 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, examples-test, examples-custom-test]
if: >
github.event_name == 'push' &&
github.ref == 'refs/heads/master'

# todo bring back more needs, so that we only run this `fuzz` stage
# if pre-conditions are filled.
#needs: [set-image, examples-docs, examples-contract-build, examples-test, examples-custom-test]
needs: [set-image]
#if: >
#github.event_name == 'push' &&
#github.ref == 'refs/heads/master'
permissions:
issues: write
defaults:
Expand All @@ -843,6 +847,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/measurements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
cache-all-crates: true

- name: Rust Info
uses: ./.github/rust-info
Expand Down
Loading
Loading