Skip to content

Commit

Permalink
chore(examples): Separate examples from the workspace and check them …
Browse files Browse the repository at this point in the history
…in CI (#4961)

* chore(examples): Separate examples from the workspace and check them in CI

* Add `isRustExample` gate

* sort

* Update patch

* remove examples copy from docker files

* Loop over glob

* patch

* Remove failure check

* try changin runner

* Add missing outputs and remove extra checkouts

* Option 1

* add udeps

* globstar

* Revert checkout steps

* slightly improve logging

---------

Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
DaughterOfMars and thibault-martinez authored Jan 27, 2025
1 parent 5101ae1 commit 1a36c48
Show file tree
Hide file tree
Showing 21 changed files with 8,518 additions and 258 deletions.
17 changes: 16 additions & 1 deletion .github/actions/diffs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@ outputs:
isRust:
description: True when changes happened to the Rust code
value: "${{ steps.diff.outputs.isRust }}"
isRustExample:
description: True when changes happened to the Rust example code
value: "${{ steps.diff.outputs.isRustExample }}"
isRpc:
description: True when changes happened to the RPC code
value: "${{ steps.diff.outputs.isRpc }}"
isPgIntegration:
description: True when changes happened to the PG integration code
value: "${{ steps.diff.outputs.isPgIntegration }}"
isMove:
description: True when changes happened to the Move code
value: "${{ steps.diff.outputs.isMove }}"
isRosetta:
description: True when changes happened to the rosetta code
value: "${{ steps.diff.outputs.isRosetta }}"
isExternalCrates:
description: True when changes happened in external crates
value: "${{ steps.diff.outputs.isExternalCrates }}"
Expand All @@ -31,7 +43,6 @@ runs:
- "crates/**"
- "external-crates/**"
- "iota-execution/**"
- "docs/examples/rust/**"
- ".github/workflows/hierarchy.yml"
- ".github/workflows/codecov.yml"
- ".github/workflows/_rust.yml"
Expand All @@ -44,6 +55,10 @@ runs:
- "Cargo.lock"
- ".config/nextest.toml"
- "rust-toolchain.toml"
isRustExample:
- "examples/custom-indexer/rust/**"
- "examples/tic-tac-toe/cli/**"
- "docs/examples/rust/**"
isRpc:
- "crates/iota-json-rpc/**"
- "crates/iota-json-rpc-types/**"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
inputs:
isRust:
type: boolean
isRustExample:
type: boolean
isPgIntegration:
type: boolean

Expand Down Expand Up @@ -36,6 +38,7 @@ jobs:
uses: ./.github/workflows/_rust_lints.yml
with:
isRust: ${{ inputs.isRust }}
isRustExample: ${{ inputs.isRustExample }}

deny:
uses: ./.github/workflows/_cargo_deny.yml
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/_rust_lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
inputs:
isRust:
type: boolean
isRustExample:
type: boolean

concurrency:
group: rust-lints-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down Expand Up @@ -45,6 +47,26 @@ jobs:
exit 1 # Fail the workflow
fi
examples:
if: (!cancelled() && inputs.isRustExample)
runs-on: [self-hosted]
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Check examples
# Set the globstar opt here to enable recursive glob.
run: |
shopt -s globstar
for manifest in ./**/examples/**/Cargo.toml; do
echo "Checking format for $manifest"
cargo +nightly ci-fmt --manifest-path $manifest
echo "Clippy linting for $manifest"
cargo clippy --manifest-path $manifest --all-features
echo "Checking unused dependencies of $manifest"
cargo +nightly ci-udeps --manifest-path $manifest
done
clippy:
if: (!cancelled() && !failure() && inputs.isRust)
needs:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/hierarchy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ on:

jobs:
diff:
runs-on: [self-hosted]
runs-on: [ubuntu-latest]
concurrency:
group: diff-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/develop' }}
outputs:
isRust: ${{ steps.diff.outputs.isRust }}
isRustExample: ${{ steps.diff.outputs.isRustExample }}
isRpc: ${{ steps.diff.outputs.isRpc }}
isPgIntegration: ${{ steps.diff.outputs.isPgIntegration }}
isMove: ${{ steps.diff.outputs.isMove }}
Expand Down Expand Up @@ -108,6 +109,7 @@ jobs:
secrets: inherit
with:
isRust: ${{ needs.diff.outputs.isRust == 'true' }}
isRustExample: ${{ needs.diff.outputs.isRustExample == 'true' }}
isPgIntegration: ${{ needs.diff.outputs.isPgIntegration == 'true' }}

rosetta:
Expand Down
Loading

0 comments on commit 1a36c48

Please sign in to comment.