From 0e19d3c2f5ea5183c44cc5d976cb0297389ded77 Mon Sep 17 00:00:00 2001 From: Csongor Kiss Date: Mon, 29 Apr 2024 19:00:55 +0100 Subject: [PATCH] solana/CI: check crate versions --- .github/workflows/solana.yml | 8 +++ solana/Cargo.lock | 10 ++-- solana/idl/json/dummy_transfer_hook.json | 2 +- .../json/example_native_token_transfers.json | 2 +- solana/idl/json/ntt_quoter.json | 2 +- solana/idl/json/wormhole_governance.json | 2 +- solana/idl/ts/dummy_transfer_hook.ts | 4 +- .../idl/ts/example_native_token_transfers.ts | 4 +- solana/idl/ts/ntt_quoter.ts | 4 +- solana/idl/ts/wormhole_governance.ts | 4 +- solana/modules/ntt-messages/Cargo.toml | 2 +- .../programs/dummy-transfer-hook/Cargo.toml | 2 +- .../example-native-token-transfers/Cargo.toml | 2 +- solana/programs/ntt-quoter/Cargo.toml | 2 +- .../programs/wormhole-governance/Cargo.toml | 2 +- solana/scripts/sync-versions | 58 +++++++++++++++++++ 16 files changed, 88 insertions(+), 22 deletions(-) create mode 100755 solana/scripts/sync-versions diff --git a/.github/workflows/solana.yml b/.github/workflows/solana.yml index 5cb598de0..0faa6174e 100644 --- a/.github/workflows/solana.yml +++ b/.github/workflows/solana.yml @@ -97,6 +97,14 @@ jobs: cargo build-sbf --features "mainnet" cargo test-sbf --features "mainnet" cargo test + check-version: + name: Check version + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: ./scripts/sync-versions --check + shell: bash + anchor-test: name: Anchor Test runs-on: ubuntu-latest diff --git a/solana/Cargo.lock b/solana/Cargo.lock index 541661c36..4424e6667 100644 --- a/solana/Cargo.lock +++ b/solana/Cargo.lock @@ -1394,7 +1394,7 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "dummy-transfer-hook" -version = "0.1.0" +version = "2.0.0" dependencies = [ "anchor-lang", "anchor-spl", @@ -1553,7 +1553,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "example-native-token-transfers" -version = "1.0.0" +version = "2.0.0" dependencies = [ "anchor-lang", "anchor-spl", @@ -2476,7 +2476,7 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "ntt-messages" -version = "1.0.0" +version = "2.0.0" dependencies = [ "anchor-lang", "hex", @@ -2486,7 +2486,7 @@ dependencies = [ [[package]] name = "ntt-quoter" -version = "1.0.0" +version = "2.0.0" dependencies = [ "anchor-lang", "cfg-if", @@ -6392,7 +6392,7 @@ dependencies = [ [[package]] name = "wormhole-governance" -version = "1.0.0" +version = "2.0.0" dependencies = [ "anchor-lang", "hex", diff --git a/solana/idl/json/dummy_transfer_hook.json b/solana/idl/json/dummy_transfer_hook.json index 27f37cb16..2f6864c36 100644 --- a/solana/idl/json/dummy_transfer_hook.json +++ b/solana/idl/json/dummy_transfer_hook.json @@ -1,5 +1,5 @@ { - "version": "0.1.0", + "version": "2.0.0", "name": "dummy_transfer_hook", "instructions": [ { diff --git a/solana/idl/json/example_native_token_transfers.json b/solana/idl/json/example_native_token_transfers.json index 00501f9f8..fb1c9c06b 100644 --- a/solana/idl/json/example_native_token_transfers.json +++ b/solana/idl/json/example_native_token_transfers.json @@ -1,5 +1,5 @@ { - "version": "1.0.0", + "version": "2.0.0", "name": "example_native_token_transfers", "instructions": [ { diff --git a/solana/idl/json/ntt_quoter.json b/solana/idl/json/ntt_quoter.json index c756bd654..d6c6f2f7a 100644 --- a/solana/idl/json/ntt_quoter.json +++ b/solana/idl/json/ntt_quoter.json @@ -1,5 +1,5 @@ { - "version": "1.0.0", + "version": "2.0.0", "name": "ntt_quoter", "instructions": [ { diff --git a/solana/idl/json/wormhole_governance.json b/solana/idl/json/wormhole_governance.json index 895f58575..1561e7350 100644 --- a/solana/idl/json/wormhole_governance.json +++ b/solana/idl/json/wormhole_governance.json @@ -1,5 +1,5 @@ { - "version": "1.0.0", + "version": "2.0.0", "name": "wormhole_governance", "instructions": [ { diff --git a/solana/idl/ts/dummy_transfer_hook.ts b/solana/idl/ts/dummy_transfer_hook.ts index 4e068844b..25e31bff3 100644 --- a/solana/idl/ts/dummy_transfer_hook.ts +++ b/solana/idl/ts/dummy_transfer_hook.ts @@ -1,5 +1,5 @@ export type DummyTransferHook = { - "version": "0.1.0", + "version": "2.0.0", "name": "dummy_transfer_hook", "instructions": [ { @@ -110,7 +110,7 @@ export type DummyTransferHook = { }; export const IDL: DummyTransferHook = { - "version": "0.1.0", + "version": "2.0.0", "name": "dummy_transfer_hook", "instructions": [ { diff --git a/solana/idl/ts/example_native_token_transfers.ts b/solana/idl/ts/example_native_token_transfers.ts index f624a528b..715e0a277 100644 --- a/solana/idl/ts/example_native_token_transfers.ts +++ b/solana/idl/ts/example_native_token_transfers.ts @@ -1,5 +1,5 @@ export type ExampleNativeTokenTransfers = { - "version": "1.0.0", + "version": "2.0.0", "name": "example_native_token_transfers", "instructions": [ { @@ -2028,7 +2028,7 @@ export type ExampleNativeTokenTransfers = { }; export const IDL: ExampleNativeTokenTransfers = { - "version": "1.0.0", + "version": "2.0.0", "name": "example_native_token_transfers", "instructions": [ { diff --git a/solana/idl/ts/ntt_quoter.ts b/solana/idl/ts/ntt_quoter.ts index 298ae9042..063f2ec30 100644 --- a/solana/idl/ts/ntt_quoter.ts +++ b/solana/idl/ts/ntt_quoter.ts @@ -1,5 +1,5 @@ export type NttQuoter = { - "version": "1.0.0", + "version": "2.0.0", "name": "ntt_quoter", "instructions": [ { @@ -588,7 +588,7 @@ export type NttQuoter = { }; export const IDL: NttQuoter = { - "version": "1.0.0", + "version": "2.0.0", "name": "ntt_quoter", "instructions": [ { diff --git a/solana/idl/ts/wormhole_governance.ts b/solana/idl/ts/wormhole_governance.ts index d3ccfd9bb..b988f040d 100644 --- a/solana/idl/ts/wormhole_governance.ts +++ b/solana/idl/ts/wormhole_governance.ts @@ -1,5 +1,5 @@ export type WormholeGovernance = { - "version": "1.0.0", + "version": "2.0.0", "name": "wormhole_governance", "instructions": [ { @@ -76,7 +76,7 @@ export type WormholeGovernance = { }; export const IDL: WormholeGovernance = { - "version": "1.0.0", + "version": "2.0.0", "name": "wormhole_governance", "instructions": [ { diff --git a/solana/modules/ntt-messages/Cargo.toml b/solana/modules/ntt-messages/Cargo.toml index cf6f5468c..b3443dd67 100644 --- a/solana/modules/ntt-messages/Cargo.toml +++ b/solana/modules/ntt-messages/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ntt-messages" -version = "1.0.0" +version = "2.0.0" edition = "2021" [features] diff --git a/solana/programs/dummy-transfer-hook/Cargo.toml b/solana/programs/dummy-transfer-hook/Cargo.toml index 6f78242db..9e408629d 100644 --- a/solana/programs/dummy-transfer-hook/Cargo.toml +++ b/solana/programs/dummy-transfer-hook/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dummy-transfer-hook" -version = "0.1.0" +version = "2.0.0" description = "Created with Anchor" edition = "2021" diff --git a/solana/programs/example-native-token-transfers/Cargo.toml b/solana/programs/example-native-token-transfers/Cargo.toml index 9a131c741..c248cb6c0 100644 --- a/solana/programs/example-native-token-transfers/Cargo.toml +++ b/solana/programs/example-native-token-transfers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "example-native-token-transfers" -version = "1.0.0" +version = "2.0.0" description = "Example implementation of native token transfer standard" edition = "2021" diff --git a/solana/programs/ntt-quoter/Cargo.toml b/solana/programs/ntt-quoter/Cargo.toml index fcc3ba281..ee06ec7ae 100644 --- a/solana/programs/ntt-quoter/Cargo.toml +++ b/solana/programs/ntt-quoter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ntt-quoter" -version = "1.0.0" +version = "2.0.0" edition = "2021" [lib] diff --git a/solana/programs/wormhole-governance/Cargo.toml b/solana/programs/wormhole-governance/Cargo.toml index 93a1b664d..0d384e87e 100644 --- a/solana/programs/wormhole-governance/Cargo.toml +++ b/solana/programs/wormhole-governance/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wormhole-governance" -version = "1.0.0" +version = "2.0.0" description = "Governance for programs controlled by Wormhole Guardians" edition = "2021" diff --git a/solana/scripts/sync-versions b/solana/scripts/sync-versions new file mode 100755 index 000000000..5d0998229 --- /dev/null +++ b/solana/scripts/sync-versions @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# cd to the solana root (one level up from the script location) +cd "$(dirname "$0")"/.. + +# check if --check is passed (in a way that doesn't complain about unbound variables) +check=false +if [[ "${1:-}" == "--check" ]]; then + check=true +fi + +version= + +# grab all lib.rs files that export a VERSION constant +# and ensure there is exactly one +for lib in $(find . -name lib.rs); do + if grep -q "pub const VERSION" $lib; then + echo "Found version in $lib" + if [[ -n $version ]]; then + echo "Error: multiple versions found" >&2 + exit 1 + fi + version=$(grep "pub const VERSION" $lib | cut -d '"' -f 2) + echo "Version is $version" + fi +done + +if [[ -z $version ]]; then + echo "Error: version not found" >&2 + exit 1 +fi + +failed=0 + +# update Cargo.toml versions in all Cargo.toml files in the `programs` and +# `modules` directories +for cargo in $(find programs modules -name Cargo.toml); do + if $check; then + if ! grep -q "version = \"$version\"" $cargo; then + echo "Error: $cargo is out of date" >&2 + failed=$((failed + 1)) + fi + else + # NOTE: we don't use sed -i because it's not portable + cp $cargo $cargo.bak + sed "s/^version = .*/version = \"$version\"/" $cargo.bak > $cargo + if ! diff $cargo $cargo.bak > /dev/null; then + echo "Updated $cargo" + fi + rm $cargo.bak + fi +done + +if [[ $failed -gt 0 ]]; then + exit 1 +fi