Skip to content

Commit

Permalink
Move Rust SDK version checker into guidelines enforcer workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
yogh333 committed Jan 31, 2025
1 parent 8ff996a commit f73739a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/_check_clang_static_analyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@ jobs:
path: app-repository
submodules: recursive

- name: Check Rust SDK version
if: ${{ inputs.is_rust == 'true'}}
run: |
cd ${{ inputs.relative_app_directory }}
# Get the list of dependencies and filter the Rust SDK crates
all_crates=$(cargo +$RUST_NIGHTLY tree --depth 1 --prefix none | awk '{print $1}' | sort -u)
for crate in "ledger_secure_sdk_sys" "ledger_device_sdk" "include_gif"; do
if echo "$all_crates" | grep -q "^$crate$"; then
curr_version=$(cargo +$RUST_NIGHTLY tree -p $crate | grep -oE "$crate v[0-9]+\.[0-9]+\.[0-9]+" | awk '{print $2}' | sed 's/^v//')
latest_version=$(cargo +$RUST_NIGHTLY info $crate | grep -oE 'version:\s*[0-9]+\.[0-9]+\.[0-9]+' | awk '{print $2}')
if [[ $latest_version != $curr_version ]]; then
echo "$crate : version is $curr_version whereas $latest_version is available; please update!"
echo "For your information, app is always built with the latest version of the Rust SDK crates"
echo "Don't forget to activate dependabot in your repository settings to automatically update the Rust SDK dependencies"
echo "see https://github.com/LedgerHQ/app-boilerplate-rust/blob/main/.github/dependabot.yml"
exit 1
fi
fi
done

Check failure on line 73 in .github/workflows/_check_clang_static_analyzer.yml

View workflow job for this annotation

GitHub Actions / Check yaml files

73:17 [trailing-spaces] trailing spaces
- name: Run Clippy
if: ${{ inputs.is_rust == 'true'}}
run: |
Expand Down
25 changes: 3 additions & 22 deletions .github/workflows/reusable_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,12 @@ jobs:
then
BUILD_DEVICE_NAME="$(echo ${{ matrix.device }} | sed 's/nanosp/nanosplus/')" && \
cd ${{ needs.call_get_app_metadata.outputs.build_directory }}
# Get the list of crates to update from cargo tree and filter only the required crates
# Update the Rust SDK crates

Check failure on line 86 in .github/workflows/reusable_build.yml

View workflow job for this annotation

GitHub Actions / Check yaml files

86:43 [trailing-spaces] trailing spaces
all_crates=$(cargo +$RUST_NIGHTLY tree --depth 1 --prefix none | awk '{print $1}' | sort -u)
crates=()
for crate in "ledger_secure_sdk_sys" "ledger_device_sdk" "include_gif"; do
if echo "$all_crates" | grep -q "^$crate$"; then
crates+=("$crate")
fi
done
for crate in "${crates[@]}"; do
tree_version_curr=$(cargo +$RUST_NIGHTLY tree --depth 1 --prefix none | grep $crate | awk '{print $2}' | tr -d 'v')
echo "==> Try to update $crate"
if echo "$all_crates" | grep -q "^$crate$"; then
cargo +$RUST_NIGHTLY update $crate
tree_version_new=$(cargo +$RUST_NIGHTLY tree --depth 1 --prefix none | grep $crate | awk '{print $2}' | tr -d 'v')
if [[ $tree_version_curr != $tree_version_new ]]; then
echo "$crate : version is $tree_version_curr whereas $tree_version_new is available; please update !"
echo "Don't forget to activate dependabot in your repository settings to automatically update the Rust SDK dependencies"
echo "see https://github.com/LedgerHQ/app-boilerplate-rust/blob/main/.github/dependabot.yml"
exit 1
else
latest_version=$(cargo +$RUST_NIGHTLY search $crate | grep "^$crate" | awk '{print $3}' | tr -d '"')
if [[ $latest_version != $tree_version_curr ]]; then
echo "$crate : version is enforced to $tree_version_curr whereas $latest_version is available; please update !"
exit 1
fi
fi
fi
done
cargo ledger build ${BUILD_DEVICE_NAME} && \
binary_path=$(cargo metadata --no-deps --format-version 1 | jq -r '.target_directory')/ && \
Expand Down

0 comments on commit f73739a

Please sign in to comment.