Skip to content

Commit

Permalink
chore(CI): Add unused dependencies check (#1741)
Browse files Browse the repository at this point in the history
* chore(CI): Add unused dependencies check

* comment

* use flags matrix

* Add a comment to force workflow run

* fix duplicate flags and add to external

* remove unused dependencies

* Remove more unused dependencies

* More ignores

* do external udeps

* lock file

* fix doc tests

* fix mysten-common

* revert doc

* a few more unused deps

* external

* merge methods

* review

---------

Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
DaughterOfMars and thibault-martinez authored Aug 16, 2024
1 parent cb0f591 commit 5659d99
Show file tree
Hide file tree
Showing 43 changed files with 345 additions and 288 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ ci-clippy-external = [
"-Dwarnings",
]
ci-license = "license-template --template .license_template"
ci-udeps = "udeps --all-targets --backend=depinfo"
ci-udeps-external = "udeps --all-targets --manifest-path external-crates/move/Cargo.toml --backend=depinfo"

[build]
rustflags = ["-C", "force-frame-pointers=yes", "-C", "force-unwind-tables=yes"]
Expand Down
25 changes: 23 additions & 2 deletions .github/workflows/_external_rust_tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Rust tests

on: workflow_call
on:
workflow_call:
inputs:
isRust:
type: boolean

jobs:
changes:
if: inputs.isRust
runs-on: [self-hosted]
outputs:
components: ${{ steps.filter.outputs.changes }}
Expand All @@ -18,7 +23,7 @@ jobs:
test:
name: Test ${{ matrix.components }}
needs: changes
if: needs.changes.outputs.components != '[]'
if: always() && inputs.isRust && needs.changes.outputs.components != '[]'
env:
# Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var
# causes #[sim_test] to only run under the deterministic `simtest` job, and not the
Expand All @@ -42,3 +47,19 @@ jobs:
-E '!test(prove) and !test(run_all::simple_build_with_docs/args.txt) and !test(run_test::nested_deps_bad_parent/Move.toml) and rdeps(${{matrix.components}})'
-p ${{matrix.components}}
--profile ci
check-unused-deps:
name: Check Unused Dependencies of ${{ matrix.components }} (${{ matrix.flags }})
if: always() && inputs.isRust && needs.changes.outputs.components != '[]'
strategy:
matrix:
components: ${{ fromJson(needs.changes.outputs.components) }}
flags: ["--all-features", "--no-default-features"]
fail-fast: false
runs-on: [self-hosted]
needs: changes

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
- name: Run Cargo Udeps
run: cargo +nightly ci-udeps-external -p ${{matrix.components}} ${{ matrix.flags }}
6 changes: 4 additions & 2 deletions .github/workflows/_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,20 @@ jobs:
isRust: ${{ inputs.isRust }}

rust-tests:
if: inputs.isRust
needs:
- rust-lints
- external-lints
uses: ./.github/workflows/_rust_tests.yml
with:
isRust: ${{ inputs.isRust }}

external-tests:
if: inputs.isRust
needs:
- rust-lints
- external-lints
uses: ./.github/workflows/_external_rust_tests.yml
with:
isRust: ${{ inputs.isRust }}

mysticeti-tests:
if: inputs.isRust
Expand Down
45 changes: 42 additions & 3 deletions .github/workflows/_rust_tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Rust tests

on: workflow_call
on:
workflow_call:
inputs:
isRust:
type: boolean

jobs:
changes:
if: inputs.isRust
runs-on: [self-hosted]
outputs:
components: ${{ steps.filter.outputs.changes }}
Expand All @@ -18,7 +23,7 @@ jobs:
test:
name: Test ${{ matrix.components }}
needs: changes
if: needs.changes.outputs.components != '[]'
if: always() && inputs.isRust && needs.changes.outputs.components != '[]'
env:
# Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var
# causes #[sim_test] to only run under the deterministic `simtest` job, and not the
Expand All @@ -36,6 +41,7 @@ jobs:
run: cargo nextest run --profile ci -E 'rdeps(${{matrix.components}})' -p ${{matrix.components}}

iota-sdk-changes:
if: inputs.isRust
runs-on: [self-hosted]
outputs:
changed: ${{ steps.filter.outputs.iota-sdk }}
Expand All @@ -50,7 +56,7 @@ jobs:
test-iota-sdk:
name: Test iota-sdk
if: needs.iota-sdk-changes.outputs.changed == 'true'
if: always() && inputs.isRust && needs.iota-sdk-changes.outputs.changed == 'true'
env:
# Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var
# causes #[sim_test] to only run under the deterministic `simtest` job, and not the
Expand All @@ -67,6 +73,39 @@ jobs:
# (we have the stardust iota-sdk package as a dependency)
run: cargo nextest run --profile ci -E 'rdeps(iota-sdk)' -p [email protected]

check-unused-deps:
name: Check Unused Dependencies of ${{ matrix.components }} (${{ matrix.flags }})
if: always() && inputs.isRust && needs.changes.outputs.components != '[]'
strategy:
matrix:
components: ${{ fromJson(needs.changes.outputs.components) }}
flags: ["--all-features", "--no-default-features"]
fail-fast: false
runs-on: [self-hosted]
needs: changes

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
- name: Run Cargo Udeps
run: cargo +nightly ci-udeps -p ${{matrix.components}} ${{ matrix.flags }}

check-unused-deps-iota-sdk:
name: Check Unused Dependencies of iota-sdk (${{ matrix.flags }})
if: always() && inputs.isRust && needs.iota-sdk-changes.outputs.changed == 'true'
runs-on: [self-hosted]
needs: iota-sdk-changes
strategy:
matrix:
flags: ["--all-features", "--no-default-features"]

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
# iota-sdk version needs to be explicitly defined here due to this bug
# https://github.com/rust-lang/cargo/issues/12891
# (we have the stardust iota-sdk package as a dependency)
- name: Run Cargo Udeps
run: cargo +nightly ci-udeps -p [email protected] ${{ matrix.flags }}

test-extra:
env:
# Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var
Expand Down
Loading

0 comments on commit 5659d99

Please sign in to comment.