Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating CI and bumping to 1.17 #11

Merged
merged 9 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ test-ledger
dist
.amman
.crates
.bin
13 changes: 12 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ You will then have access to the following commands.

- `programs:build` - Build all programs and fetch all dependant programs.
- `programs:test` - Test all programs.
- `programs:debug` - Test all programs with logs enabled.
- `programs:clean` - Clean all built and fetched programs.
- `clients:js:test` - Run the JS client tests.
- `pnpm generate` - Shortcut for `pnpm generate:idls && pnpm generate:clients`.
- `pnpm generate:idls` - Generate IDLs for all programs, as configured in the `configs/shank.cjs` file.
- `pnpm generate:clients` - Generate clients using Kinobi, as configured in the `configs/kinobi.cjs` file.
- `pnpm generate` - Shortcut for `pnpm generate:idls && pnpm generate:clients`.
- `pnpm validator` - Start a local validator using Amman, as configured in the `configs/validator.cjs` file.
- `pnpm validator:debug` - Start a local validator using Amman with logs enabled, as configured in the `configs/validator.cjs` file.
- `pnpm validator:stop` - Stop the local validator.
- `pnpm validator:logs` - Show the logs of the local validator.

Expand All @@ -28,6 +31,14 @@ Each client has its own README with instructions on how to get started. You can

- [JavaScript client](./clients/js/README.md)

In order to generate the clients, run the following command.

```sh
pnpm generate
```

You will need to run `pnpm generate` to re-generate the clients when something changes in the program(s).

## Setting up CI/CD using GitHub actions

Most of the CI/CD should already be set up for you and the `.github/.env` file can be used to tweak the variables of the workflows.
Expand Down
1 change: 1 addition & 0 deletions clients/js/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
'@typescript-eslint/no-unused-vars': 'off',
'class-methods-use-this': 'off',
'import/prefer-default-export': 'off',
'import/no-cycle': 'off',
'no-underscore-dangle': 'off',
'max-classes-per-file': 'off',
'no-param-reassign': 'off',
Expand Down
2 changes: 1 addition & 1 deletion clients/js/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ Then, we'll need to create a new GitHub environment called `js-client-documentat
- Install Command: `pnpm install`
- Development Command: _None_

With all that set up, you can now run the "Deploy JS Client" workflow by dispatching it from the GitHub UI.
With all that set up, you can now run the "Publish JS Client" workflow by dispatching it from the GitHub UI.
14 changes: 14 additions & 0 deletions configs/scripts/client/test-js.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
# go to parent folder
cd $(dirname $(dirname $(dirname $SCRIPT_DIR)))
WORKING_DIR=$(pwd)

# command-line input
ARGS=$*

# js client tests folder
cd ${WORKING_DIR}/clients/js

pnpm install && pnpm build && pnpm test ${ARGS}
35 changes: 35 additions & 0 deletions configs/scripts/program/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
OUTPUT="./programs/.bin"
# go to parent folder
cd $(dirname $(dirname $(dirname ${SCRIPT_DIR})))

if [ -z ${PROGRAMS+x} ]; then
PROGRAMS="$(cat .github/.env | grep "PROGRAMS" | cut -d '=' -f 2)"
fi

# default to input from the command-line
ARGS=$*

# command-line arguments override env variable
if [ ! -z "$ARGS" ]; then
PROGRAMS="[\"${1}\"]"
shift
ARGS=$*
fi

PROGRAMS=$(echo ${PROGRAMS} | jq -c '.[]' | sed 's/"//g')

# creates the output directory if it doesn't exist
if [ ! -d ${OUTPUT} ]; then
mkdir ${OUTPUT}
fi

WORKING_DIR=$(pwd)
export SBF_OUT_DIR="${WORKING_DIR}/${OUTPUT}"

for p in ${PROGRAMS[@]}; do
cd ${WORKING_DIR}/programs/${p}
cargo build-sbf --sbf-out-dir ${WORKING_DIR}/${OUTPUT} $ARGS
done
20 changes: 20 additions & 0 deletions configs/scripts/program/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
OUTPUT="./programs/.bin"
# go to parent folder
cd $(dirname $(dirname $(dirname ${SCRIPT_DIR})))

rm -rf $OUTPUT

if [ -z ${PROGRAMS+x} ]; then
PROGRAMS="$(cat .github/.env | grep "PROGRAMS" | cut -d '=' -f 2)"
fi

PROGRAMS=$(echo ${PROGRAMS} | jq -c '.[]' | sed 's/"//g')
WORKING_DIR=$(pwd)

for p in ${PROGRAMS[@]}; do
cd ${WORKING_DIR}/programs/${p}
rm -rf target
done
40 changes: 40 additions & 0 deletions configs/scripts/program/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
OUTPUT="./programs/.bin"
# go to parent folder
cd $(dirname $(dirname $(dirname $SCRIPT_DIR)))

if [ ! -z "$PROGRAM" ]; then
PROGRAMS='["'${PROGRAM}'"]'
fi

if [ -z "$PROGRAMS" ]; then
PROGRAMS="$(cat .github/.env | grep "PROGRAMS" | cut -d '=' -f 2)"
fi

# default to input from the command-line
ARGS=$*

# command-line arguments override env variable
if [ ! -z "$ARGS" ]; then
PROGRAMS="[\"${1}\"]"
shift
ARGS=$*
fi

PROGRAMS=$(echo $PROGRAMS | jq -c '.[]' | sed 's/"//g')

WORKING_DIR=$(pwd)
SOLFMT="solfmt"
export SBF_OUT_DIR="${WORKING_DIR}/${OUTPUT}"

for p in ${PROGRAMS[@]}; do
cd ${WORKING_DIR}/programs/${p}

if [ ! "$(command -v $SOLFMT)" = "" ]; then
CARGO_TERM_COLOR=always cargo test-sbf --sbf-out-dir ${WORKING_DIR}/${OUTPUT} ${ARGS} 2>&1 | ${SOLFMT}
else
RUST_LOG=error cargo test-sbf --sbf-out-dir ${WORKING_DIR}/${OUTPUT} ${ARGS}
fi
done
9 changes: 5 additions & 4 deletions configs/validator.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const path = require("path");

const programDir = path.join(__dirname, "..", "programs");
function getProgram(dir, programName) {
return path.join(programDir, dir, "target", "deploy", programName);

function getProgram(programBinary) {
return path.join(programDir, ".bin", programBinary);
}

module.exports = {
Expand All @@ -12,12 +13,12 @@ module.exports = {
{
label: "System Extras",
programId: "SysExL2WDyJi9aRZrXorrjHJut3JwHQ7R9bTyctbNNG",
deployPath: getProgram("system-extras", "mpl_system_extras.so"),
deployPath: getProgram("mpl_system_extras.so"),
},
{
label: "Token Extras",
programId: "TokExjvjJmhKaRBShsBAsbSvEWMA1AgUNK7ps4SAc2p",
deployPath: getProgram("token-extras", "mpl_token_extras.so"),
deployPath: getProgram("mpl_token_extras.so"),
},
],
},
Expand Down
15 changes: 0 additions & 15 deletions configs/validator.devnet.cjs

This file was deleted.

15 changes: 0 additions & 15 deletions configs/validator.mainnet.cjs

This file was deleted.

18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
{
"private": true,
"scripts": {
"programs:build": "./configs/scripts/program/build.sh",
"programs:test": "RUST_LOG=error ./configs/scripts/program/test.sh",
"programs:debug": "./configs/scripts/program/test.sh",
"programs:clean": "./configs/scripts/program/clean.sh",
"clients:js:test": "./configs/scripts/client/test-js.sh",
"generate": "pnpm generate:idls && pnpm generate:clients",
"generate:idls": "node ./configs/shank.cjs",
"generate:clients": "node ./configs/kinobi.cjs",
"validator": "pnpm validator:localnet",
"validator:localnet": "CI=1 amman start --config ./configs/validator.cjs",
"validator:devnet": "CI=1 amman start --config ./configs/validator.devnet.cjs",
"validator:mainnet": "CI=1 amman start --config ./configs/validator.mainnet.cjs",
"validator": "CI=1 amman start --config ./configs/validator.cjs",
"validator:debug": "amman start --config ./configs/validator.cjs",
"validator:logs": "CI=1 amman logs",
"validator:stop": "amman stop"
},
"devDependencies": {
"@metaplex-foundation/kinobi": "^0.14.0",
"@metaplex-foundation/kinobi": "^0.16.0",
"@metaplex-foundation/shank-js": "^0.1.0",
"@metaplex-foundation/amman": "^0.12.1",
"typescript": "^4.9.4"
},
"packageManager": "pnpm@8.2.0"
}
"packageManager": "pnpm@8.9.0"
}
12 changes: 8 additions & 4 deletions pnpm-lock.yaml

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

Loading
Loading