From ab664af0137db69ea0257b0c839c953d9bdf2735 Mon Sep 17 00:00:00 2001 From: metaproph3t Date: Thu, 10 Aug 2023 00:00:00 +0000 Subject: [PATCH 1/3] Add a `justfile` for setting up your local machine for tests I was about to work on a PR to address #2586 and was trying to get my tests set up so that I could test locally. I found it pretty cumbersome to copy all of the commands from the ci files in `.github` (maybe there's a better way? in which case, this isn't necessary), so I threw them in a `justfile` in case it'd be helpful for others. --- justfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 justfile diff --git a/justfile b/justfile new file mode 100644 index 0000000000..612259b90a --- /dev/null +++ b/justfile @@ -0,0 +1,11 @@ +setup-for-tests: + solana-install init 1.16.0 && \ + git submodule update --init --recursive --depth 1 && \ + cd ts/packages/borsh && yarn --frozen-lockfile && yarn build && yarn link --force && cd ../../../ && \ + cd ts/packages/anchor && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../ && \ + cd ts/packages/spl-associated-token-account && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../ && \ + cd ts/packages/spl-token && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../ && \ + cd examples/tutorial && yarn link @coral-xyz/anchor @coral-xyz/borsh && yarn --frozen-lockfile && cd ../../ && \ + cd tests && yarn link @coral-xyz/anchor @coral-xyz/borsh @coral-xyz/spl-associated-token-account @coral-xyz/spl-token && yarn --frozen-lockfile && cd .. && \ + cargo install --path cli anchor-cli --locked --force --debug + From fbcbfb54bf9b831469d16a0bb253effb5ac2c72e Mon Sep 17 00:00:00 2001 From: metaproph3t Date: Fri, 11 Aug 2023 00:00:00 +0000 Subject: [PATCH 2/3] Replace `justfile` with bash script `setup_tests.sh` --- justfile | 11 ----------- setup_tests.sh | 12 ++++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-) delete mode 100644 justfile create mode 100755 setup_tests.sh diff --git a/justfile b/justfile deleted file mode 100644 index 612259b90a..0000000000 --- a/justfile +++ /dev/null @@ -1,11 +0,0 @@ -setup-for-tests: - solana-install init 1.16.0 && \ - git submodule update --init --recursive --depth 1 && \ - cd ts/packages/borsh && yarn --frozen-lockfile && yarn build && yarn link --force && cd ../../../ && \ - cd ts/packages/anchor && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../ && \ - cd ts/packages/spl-associated-token-account && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../ && \ - cd ts/packages/spl-token && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../ && \ - cd examples/tutorial && yarn link @coral-xyz/anchor @coral-xyz/borsh && yarn --frozen-lockfile && cd ../../ && \ - cd tests && yarn link @coral-xyz/anchor @coral-xyz/borsh @coral-xyz/spl-associated-token-account @coral-xyz/spl-token && yarn --frozen-lockfile && cd .. && \ - cargo install --path cli anchor-cli --locked --force --debug - diff --git a/setup_tests.sh b/setup_tests.sh new file mode 100755 index 0000000000..bef73bc999 --- /dev/null +++ b/setup_tests.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +solana-install init 1.16.0 +git submodule update --init --recursive --depth 1 +cd ts/packages/borsh && yarn --frozen-lockfile && yarn build && yarn link --force && cd ../../../ +cd ts/packages/anchor && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../ +cd ts/packages/spl-associated-token-account && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../ +cd ts/packages/spl-token && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../ +cd examples/tutorial && yarn link @coral-xyz/anchor @coral-xyz/borsh && yarn --frozen-lockfile && cd ../../ +cd tests && yarn link @coral-xyz/anchor @coral-xyz/borsh @coral-xyz/spl-associated-token-account @coral-xyz/spl-token && yarn --frozen-lockfile && cd .. +cargo install --path cli anchor-cli --locked --force --debug + From c3d127f8996c4d7410f86f91b34a5cc6b3273a35 Mon Sep 17 00:00:00 2001 From: metaproph3t Date: Fri, 11 Aug 2023 00:00:00 +0000 Subject: [PATCH 3/3] Conditionalize the `solana-install` --- setup_tests.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/setup_tests.sh b/setup_tests.sh index bef73bc999..fda85b11e9 100755 --- a/setup_tests.sh +++ b/setup_tests.sh @@ -1,6 +1,10 @@ #!/bin/bash -solana-install init 1.16.0 +active_version=$(solana -V | awk '{print $2}') +if [ "$active_version" != "1.16.0" ]; then + solana-install init 1.16.0 +fi + git submodule update --init --recursive --depth 1 cd ts/packages/borsh && yarn --frozen-lockfile && yarn build && yarn link --force && cd ../../../ cd ts/packages/anchor && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../ @@ -9,4 +13,3 @@ cd ts/packages/spl-token && yarn --frozen-lockfile && yarn build:node && yarn li cd examples/tutorial && yarn link @coral-xyz/anchor @coral-xyz/borsh && yarn --frozen-lockfile && cd ../../ cd tests && yarn link @coral-xyz/anchor @coral-xyz/borsh @coral-xyz/spl-associated-token-account @coral-xyz/spl-token && yarn --frozen-lockfile && cd .. cargo install --path cli anchor-cli --locked --force --debug -