Skip to content

Commit 2699171

Browse files
devin-ai-integration[bot]Jayant Krishnamurthyjayantk
authored
Add cargo fmt and cargo clippy to CI workflows (#2475)
* Add cargo fmt and cargo clippy to CI workflows Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz> * refactor: remove toolchain version arguments from cargo commands Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz> * update worfklows * trigger workflows on edit * fix workflows * fix aptos * hm * hm * ci: remove workflow file paths from PR triggers and redundant if conditions Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz> * Revert "ci: remove workflow file paths from PR triggers and redundant if conditions" This reverts commit 37b0de9. --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Jayant Krishnamurthy <jayant@dourolabs.xyz> Co-authored-by: Jayant Krishnamurthy <jayantkrishnamurthy@gmail.com>
1 parent 5a681d7 commit 2699171

File tree

10 files changed

+133
-12
lines changed

10 files changed

+133
-12
lines changed

.github/workflows/ci-aptos-contract.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
on:
22
pull_request:
33
paths:
4+
- .github/workflows/ci-aptos-contract.yml
45
- target_chains/aptos/contracts/**
56
push:
67
branches:
@@ -19,10 +20,22 @@ jobs:
1920
- uses: actions/checkout@v3
2021

2122
- name: Download CLI
22-
run: wget https://github.com/aptos-labs/aptos-core/releases/download/aptos-cli-v3.1.0/aptos-cli-3.1.0-Ubuntu-22.04-x86_64.zip
23+
run: wget https://github.com/aptos-labs/aptos-core/releases/download/aptos-cli-v6.1.1/aptos-cli-6.1.1-Ubuntu-22.04-x86_64.zip
2324

2425
- name: Unzip CLI
25-
run: unzip aptos-cli-3.1.0-Ubuntu-22.04-x86_64.zip
26+
run: unzip aptos-cli-6.1.1-Ubuntu-22.04-x86_64.zip
27+
28+
- name: Install movefmt
29+
run: ./aptos update movefmt
30+
31+
- name: Check Formatting
32+
run: ./aptos move fmt
33+
if: success() || failure()
34+
35+
- name: Lint
36+
run: ./aptos move lint --check-test-code --dev
37+
if: success() || failure()
2638

2739
- name: Run tests
2840
run: ./aptos move test
41+
if: success() || failure()

.github/workflows/ci-cosmwasm-contract.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Test CosmWasm Contract
33
on:
44
pull_request:
55
paths:
6+
- .github/workflows/ci-cosmwasm-contract.yml
67
- target_chains/cosmwasm/**
78
- wormhole_attester/sdk/rust/**
89
push:
@@ -26,7 +27,15 @@ jobs:
2627
toolchain: 1.82.0
2728
components: rustfmt, clippy
2829
override: true
30+
- name: Format check
31+
run: cargo fmt --all -- --check
32+
if: success() || failure()
33+
- name: Clippy check
34+
run: cargo clippy --tests -- --deny warnings
35+
if: success() || failure()
2936
- name: Build
3037
run: cargo build --verbose
38+
if: success() || failure()
3139
- name: Run tests
3240
run: cargo test --verbose
41+
if: success() || failure()

.github/workflows/ci-fortuna.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ name: Check Fortuna
33
on:
44
pull_request:
55
paths:
6+
- .github/workflows/ci-fortuna.yml
67
- apps/fortuna/**
78
push:
89
branches: [main]
910
jobs:
1011
test:
1112
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: apps/fortuna
1216
steps:
1317
- uses: actions/checkout@v2
1418
- uses: Swatinem/rust-cache@v2
@@ -19,5 +23,12 @@ jobs:
1923
profile: minimal
2024
toolchain: 1.82.0
2125
override: true
22-
- name: Run executor tests
23-
run: cargo test --manifest-path ./apps/fortuna/Cargo.toml
26+
- name: Format check
27+
run: cargo fmt --all -- --check
28+
if: success() || failure()
29+
- name: Clippy check
30+
run: cargo clippy --tests -- --deny warnings
31+
if: success() || failure()
32+
- name: Run tests
33+
run: cargo test
34+
if: success() || failure()

.github/workflows/ci-hermes-server.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ name: Check Hermes Server
33
on:
44
pull_request:
55
paths:
6+
- .github/workflows/ci-hermes-server.yml
67
- apps/hermes/server/**
78
push:
89
branches: [main]
910
jobs:
1011
test:
1112
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: apps/hermes/server
1216
steps:
1317
- uses: actions/checkout@v2
1418
- uses: Swatinem/rust-cache@v2
@@ -24,5 +28,12 @@ jobs:
2428
uses: arduino/setup-protoc@v3
2529
with:
2630
repo-token: ${{ secrets.GITHUB_TOKEN }}
31+
- name: Format check
32+
run: cargo fmt --all -- --check
33+
if: success() || failure()
34+
- name: Clippy check
35+
run: cargo clippy --tests -- --deny warnings
36+
if: success() || failure()
2737
- name: Run executor tests
28-
run: cargo test --manifest-path ./apps/hermes/server/Cargo.toml
38+
run: cargo test
39+
if: success() || failure()

.github/workflows/ci-lazer-rust.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
- main
66
pull_request:
77
paths:
8+
- .github/workflows/ci-lazer-rust.yml
89
- lazer/**
910

1011
jobs:
@@ -36,7 +37,15 @@ jobs:
3637
echo "$HOME/.local/share/solana/install/active_release/bin" >> "$GITHUB_PATH"
3738
- name: check Cargo.toml formatting
3839
run: find . -name Cargo.toml -exec taplo fmt --check --diff {} \;
40+
- name: Format check
41+
run: cargo fmt --all -- --check
42+
if: success() || failure()
43+
- name: Clippy check
44+
run: cargo clippy --all-targets -- --deny warnings
45+
if: success() || failure()
3946
- name: Build Solana programs
4047
run: cargo build-sbf
48+
if: success() || failure()
4149
- name: test
4250
run: cargo test
51+
if: success() || failure()

.github/workflows/ci-message-buffer-idl.yml renamed to .github/workflows/ci-message-buffer.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
name: Message Buffer IDL Check
1+
name: Message Buffer Check
22
on:
33
pull_request:
44
paths:
5+
- .github/workflows/ci-message-buffer.yml
56
- pythnet/message_buffer/**
67
push:
78
branches:
89
- main
910
jobs:
1011
abi-check:
11-
name: Check Message Buffer IDL files are up to date
12+
name: Check Message Buffer formatting & IDL files
1213
runs-on: ubuntu-latest
1314
defaults:
1415
run:
@@ -33,10 +34,10 @@ jobs:
3334
- name: Install Anchor
3435
run: |
3536
cargo install --git https://github.com/coral-xyz/anchor --tag v0.27.0 anchor-cli --locked
36-
- name: Build and generate IDLs
37-
run: anchor build
38-
- name: Copy anchor target files
39-
run: cp ./target/idl/message_buffer.json idl/ && cp ./target/types/message_buffer.ts idl/
37+
- name: Install g++ 12
38+
run: |
39+
sudo apt-get install g++-12
40+
echo "CXX=/usr/bin/g++-12" >> "${GITHUB_ENV}"
4041
# Libusb is a build requirement for the node-hid package and so pnpm
4142
# install will fail if this isn't in the build environment and if a
4243
# precompiled binary isn't found.
@@ -46,10 +47,21 @@ jobs:
4647
name: Install pnpm
4748
- name: Install prettier globally
4849
run: pnpm install -g prettier@2.7.1
50+
- name: Build and generate IDLs
51+
run: anchor build
52+
- name: Copy anchor target files
53+
run: cp ./target/idl/message_buffer.json idl/ && cp ./target/types/message_buffer.ts idl/
4954
- name: Run prettier (to avoid pre-commit failures)
5055
run: |
5156
pnpm dlx prettier@2.7.1 --write "./idl/*"
5257
- name: Check IDL changes
5358
# Fails if the IDL files are not up to date. Please use anchor build to regenerate the IDL files for
5459
# the current version of the contract and update idl directory.
5560
run: git diff --exit-code idl/*
61+
if: success() || failure()
62+
- name: Cargo format
63+
run: cargo fmt --all -- --check
64+
if: success() || failure()
65+
- name: Cargo clippy
66+
run: cargo clippy --tests -- --deny warnings
67+
if: success() || failure()

.github/workflows/ci-pythnet-sdk.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Check Pythnet SDK
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- .github/workflows/ci-pythnet-sdk.yml
7+
- pythnet/pythnet_sdk/**
8+
push:
9+
branches: [main]
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: pythnet/pythnet_sdk
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: Swatinem/rust-cache@v2
19+
with:
20+
workspaces: "pythnet/pythnet_sdk -> target"
21+
- uses: actions-rs/toolchain@v1
22+
with:
23+
profile: minimal
24+
toolchain: 1.82.0
25+
override: true
26+
- name: Format check
27+
run: cargo fmt --all -- --check
28+
if: success() || failure()
29+
- name: Clippy check
30+
run: cargo clippy --tests -- --deny warnings
31+
if: success() || failure()
32+
- name: Run executor tests
33+
run: cargo test
34+
if: success() || failure()

.github/workflows/ci-remote-executor.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ name: Check Remote Executor
33
on:
44
pull_request:
55
paths:
6+
- .github/workflows/ci-remote-executor.yml
67
- governance/remote_executor/**
78
push:
89
branches: [main]
910
jobs:
1011
test:
1112
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: governance/remote_executor
1216
steps:
1317
- uses: actions/checkout@v2
1418
- uses: actions/setup-python@v2
@@ -25,5 +29,12 @@ jobs:
2529
run: |
2630
sh -c "$(curl -sSfL https://release.solana.com/v1.18.23/install)"
2731
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
32+
- name: Format check
33+
run: cargo fmt --all -- --check
34+
if: success() || failure()
35+
- name: Clippy check
36+
run: cargo clippy --tests -- --deny warnings
37+
if: success() || failure()
2838
- name: Run executor tests
29-
run: cargo test-sbf --manifest-path ./governance/remote_executor/Cargo.toml
39+
run: cargo test-sbf
40+
if: success() || failure()

.github/workflows/ci-solana-contract.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Test Solana Contract
33
on:
44
pull_request:
55
paths:
6+
- .github/workflows/ci-solana-contract.yml
67
- target_chains/solana/**
78
- pythnet/pythnet_sdk/**
89
push:
@@ -32,9 +33,18 @@ jobs:
3233
run: |
3334
sh -c "$(curl -sSfL https://release.solana.com/v1.16.20/install)"
3435
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
36+
- name: Format check
37+
run: cargo fmt --all -- --check
38+
if: success() || failure()
39+
- name: Clippy check
40+
run: cargo clippy --tests -- --deny warnings
41+
if: success() || failure()
3542
- name: Build
3643
run: cargo-build-sbf
44+
if: success() || failure()
3745
- name: Run tests
3846
run: cargo-test-sbf
47+
if: success() || failure()
3948
- name: Run sdk tests
4049
run: cargo test --package pyth-solana-receiver-sdk
50+
if: success() || failure()

target_chains/aptos/contracts/sources/governance/governance_action.move

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module pyth::governance_action {
1111
value: u8,
1212
}
1313

14+
#[lint::skip(unnecessary_numerical_extreme_comparison)]
1415
public fun from_u8(value: u8): GovernanceAction {
1516
assert!(CONTRACT_UPGRADE <= value && value <= SET_STALE_PRICE_THRESHOLD, error::invalid_governance_action());
1617
GovernanceAction { value }

0 commit comments

Comments
 (0)