Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 17 commits into from
Jan 27, 2025
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
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
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
echo "Checking format for $manifest"
cargo +nightly ci-fmt --manifest-path $manifest

echo "Clippy linting for $manifest"
cargo clippy --manifest-path $manifest --all-features
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved

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
Loading