Skip to content

Commit

Permalink
solana/CI: check crate versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kcsongor committed Apr 29, 2024
1 parent 1ac742d commit 0e19d3c
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 22 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/solana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions solana/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion solana/idl/json/dummy_transfer_hook.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.1.0",
"version": "2.0.0",
"name": "dummy_transfer_hook",
"instructions": [
{
Expand Down
2 changes: 1 addition & 1 deletion solana/idl/json/example_native_token_transfers.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
"version": "2.0.0",
"name": "example_native_token_transfers",
"instructions": [
{
Expand Down
2 changes: 1 addition & 1 deletion solana/idl/json/ntt_quoter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
"version": "2.0.0",
"name": "ntt_quoter",
"instructions": [
{
Expand Down
2 changes: 1 addition & 1 deletion solana/idl/json/wormhole_governance.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
"version": "2.0.0",
"name": "wormhole_governance",
"instructions": [
{
Expand Down
4 changes: 2 additions & 2 deletions solana/idl/ts/dummy_transfer_hook.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type DummyTransferHook = {
"version": "0.1.0",
"version": "2.0.0",
"name": "dummy_transfer_hook",
"instructions": [
{
Expand Down Expand Up @@ -110,7 +110,7 @@ export type DummyTransferHook = {
};

export const IDL: DummyTransferHook = {
"version": "0.1.0",
"version": "2.0.0",
"name": "dummy_transfer_hook",
"instructions": [
{
Expand Down
4 changes: 2 additions & 2 deletions solana/idl/ts/example_native_token_transfers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type ExampleNativeTokenTransfers = {
"version": "1.0.0",
"version": "2.0.0",
"name": "example_native_token_transfers",
"instructions": [
{
Expand Down Expand Up @@ -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": [
{
Expand Down
4 changes: 2 additions & 2 deletions solana/idl/ts/ntt_quoter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type NttQuoter = {
"version": "1.0.0",
"version": "2.0.0",
"name": "ntt_quoter",
"instructions": [
{
Expand Down Expand Up @@ -588,7 +588,7 @@ export type NttQuoter = {
};

export const IDL: NttQuoter = {
"version": "1.0.0",
"version": "2.0.0",
"name": "ntt_quoter",
"instructions": [
{
Expand Down
4 changes: 2 additions & 2 deletions solana/idl/ts/wormhole_governance.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type WormholeGovernance = {
"version": "1.0.0",
"version": "2.0.0",
"name": "wormhole_governance",
"instructions": [
{
Expand Down Expand Up @@ -76,7 +76,7 @@ export type WormholeGovernance = {
};

export const IDL: WormholeGovernance = {
"version": "1.0.0",
"version": "2.0.0",
"name": "wormhole_governance",
"instructions": [
{
Expand Down
2 changes: 1 addition & 1 deletion solana/modules/ntt-messages/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntt-messages"
version = "1.0.0"
version = "2.0.0"
edition = "2021"

[features]
Expand Down
2 changes: 1 addition & 1 deletion solana/programs/dummy-transfer-hook/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dummy-transfer-hook"
version = "0.1.0"
version = "2.0.0"
description = "Created with Anchor"
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion solana/programs/example-native-token-transfers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
2 changes: 1 addition & 1 deletion solana/programs/ntt-quoter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntt-quoter"
version = "1.0.0"
version = "2.0.0"
edition = "2021"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion solana/programs/wormhole-governance/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
58 changes: 58 additions & 0 deletions solana/scripts/sync-versions
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0e19d3c

Please sign in to comment.