Skip to content

Commit

Permalink
ci: Refactor JS tests to avoid running so often (#5841)
Browse files Browse the repository at this point in the history
  • Loading branch information
joncinque authored Nov 15, 2023
1 parent ed0a37f commit e333bef
Show file tree
Hide file tree
Showing 22 changed files with 88 additions and 57 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/pull-request-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Pull Request JS

on:
pull_request:
paths:
- 'libraries/type-length-value/js/**'
- 'memo/js/**'
- 'name-service/js/**'
- 'single-pool/js/**'
- 'stake-pool/js/**'
- 'token/js/**'
- 'token-lending/js/**'
- 'token-metadata/js/**'
- 'token-swap/js/**'
- 'pnpm-lock.yaml'
- '.github/workflows/pull-request-js.yml'
push:
branches: [master]
paths:
- 'libraries/type-length-value/js/**'
- 'memo/js/**'
- 'single-pool/js/**'
- 'stake-pool/js/**'
- 'token/js/**'
- 'token-lending/js/**'
- 'token-metadata/js/**'
- 'token-swap/js/**'
- 'pnpm-lock.yaml'
- '.github/workflows/pull-request-js.yml'

jobs:
js-test:
strategy:
matrix:
package: [libraries, memo, name-service, single-pool, stake-pool, token, token-lending, token-metadata, token-swap]
runs-on: ubuntu-latest
env:
NODE_VERSION: 20.5
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/cache@v2
with:
path: ~/.npm
key: node-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
node-
- run: ./ci/js-test-${{ matrix.package }}.sh
4 changes: 2 additions & 2 deletions .github/workflows/pull-request-libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ on:
paths:
- 'libraries/**'
- 'ci/*-version.sh'
- 'pnpm-lock.yaml'
- '!libraries/**/js/**'
push:
branches: [master]
paths:
- 'libraries/**'
- 'ci/*-version.sh'
- 'pnpm-lock.yaml'
- '!libraries/**/js/**'

jobs:
cargo-test-sbf:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request-memo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ on:
paths:
- 'memo/**'
- 'ci/*-version.sh'
- 'pnpm-lock.yaml'
- '!memo/js/**'
push:
branches: [master]
paths:
- 'memo/**'
- 'ci/*-version.sh'
- 'pnpm-lock.yaml'
- '!memo/js/**'

jobs:
cargo-test-sbf:
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/pull-request-name-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ on:
paths:
- 'name-service/**'
- 'ci/*-version.sh'
- 'pnpm-lock.yaml'
- '!name-service/js/**'
push:
branches: [master]
paths:
- 'name-service/**'
- 'ci/*-version.sh'
- 'pnpm-lock.yaml'
- '!name-service/js/**'

jobs:
cargo-test-sbf:
Expand Down Expand Up @@ -70,7 +70,6 @@ jobs:
runs-on: ubuntu-latest
env:
NODE_VERSION: 16.x
needs: cargo-test-sbf
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
Expand All @@ -86,9 +85,4 @@ jobs:
key: node-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
node-
- name: Download programs
uses: actions/download-artifact@v2
with:
name: name-service-programs
path: target/deploy
- run: ./ci/js-test-name-service.sh
10 changes: 2 additions & 8 deletions .github/workflows/pull-request-single-pool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- 'associated-token-account/**'
- 'ci/*-version.sh'
- '.github/workflows/pull-request-single-pool.yml'
- 'pnpm-lock.yaml'
- '!single-pool/js/**'
push:
branches: [master]
paths:
Expand All @@ -17,7 +17,7 @@ on:
- 'associated-token-account/**'
- 'ci/*-version.sh'
- '.github/workflows/pull-request-single-pool.yml'
- 'pnpm-lock.yaml'
- '!single-pool/js/**'

jobs:
cargo-test-sbf:
Expand Down Expand Up @@ -121,7 +121,6 @@ jobs:
runs-on: ubuntu-latest
env:
NODE_VERSION: 20.5
needs: cargo-test-sbf
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
Expand All @@ -137,9 +136,4 @@ jobs:
key: node-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
node-
- name: Download programs
uses: actions/download-artifact@v2
with:
name: single-pool-programs
path: target/deploy
- run: ./ci/js-test-single-pool.sh
4 changes: 2 additions & 2 deletions .github/workflows/pull-request-stake-pool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- 'ci/*-version.sh'
- 'ci/warning/purge-ubuntu-runner.sh'
- '.github/workflows/pull-request-stake-pool.yml'
- 'pnpm-lock.yaml'
- '!stake-pool/js/**'
push:
branches: [master]
paths:
Expand All @@ -17,7 +17,7 @@ on:
- 'ci/*-version.sh'
- 'ci/warning/purge-ubuntu-runner.sh'
- '.github/workflows/pull-request-stake-pool.yml'
- 'pnpm-lock.yaml'
- '!stake-pool/js/**'

jobs:
cargo-test-sbf:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request-token-lending.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on:
- 'token-lending/**'
- 'token/**'
- 'ci/*-version.sh'
- 'pnpm-lock.yaml'
- '!token-lending/js/**'
push:
branches: [master]
paths:
- 'token-lending/**'
- 'token/**'
- 'ci/*-version.sh'
- 'pnpm-lock.yaml'
- '!token-lending/js/**'

jobs:
cargo-test-sbf:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request-token-metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:
- 'token/program-2022/**'
- 'ci/*-version.sh'
- '.github/workflows/pull-request-token-metadata.yml'
- 'pnpm-lock.yaml'
- '!token-metadata/js/**'
push:
branches: [master]
paths:
- 'token-metadata/**'
- 'token/program-2022/**'
- 'ci/*-version.sh'
- '.github/workflows/pull-request-token-metadata.yml'
- 'pnpm-lock.yaml'
- '!token-metadata/js/**'

jobs:
cargo-test-sbf:
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/pull-request-token-swap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:
- 'token/**'
- 'libraries/math/**'
- 'ci/*-version.sh'
- 'pnpm-lock.yaml'
- '!token-swap/js/**'
push:
branches: [master]
paths:
- 'token-swap/**'
- 'token/**'
- 'libraries/math/**'
- 'ci/*-version.sh'
- 'pnpm-lock.yaml'
- '!token-swap/js/**'

jobs:
cargo-test-sbf:
Expand Down Expand Up @@ -87,7 +87,6 @@ jobs:
runs-on: ubuntu-latest
env:
NODE_VERSION: 16.x
needs: cargo-test-sbf
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
Expand All @@ -103,11 +102,6 @@ jobs:
key: node-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
node-
- name: Download programs
uses: actions/download-artifact@v2
with:
name: token-swap-programs
path: target/deploy
- run: ./ci/js-test-token-swap.sh

fuzz:
Expand Down
20 changes: 2 additions & 18 deletions .github/workflows/pull-request-token.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:
- 'token/**'
- 'ci/*-version.sh'
- '.github/workflows/pull-request-token.yml'
- 'pnpm-lock.yaml'
- '!token/js/**'
push:
branches: [master]
paths:
- 'associated-token-account/**'
- 'token/**'
- 'ci/*-version.sh'
- '.github/workflows/pull-request-token.yml'
- 'pnpm-lock.yaml'
- '!token/js/**'

jobs:
cargo-test-sbf:
Expand Down Expand Up @@ -255,7 +255,6 @@ jobs:
runs-on: ubuntu-latest
env:
NODE_VERSION: 16.x
needs: [cargo-test-sbf, cargo-test-sbf-associated-token-account, cargo-test-sbf-transfer-hook]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
Expand All @@ -271,21 +270,6 @@ jobs:
key: node-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
node-
- name: Download programs
uses: actions/download-artifact@v2
with:
name: token-programs
path: target/deploy
- name: Download associated-token-account program
uses: actions/download-artifact@v2
with:
name: associated-token-account-program
path: target/deploy
- name: Download spl-transfer-hook-example program
uses: actions/download-artifact@v2
with:
name: spl-transfer-hook-example
path: target/deploy
- run: ./ci/js-test-token.sh

cargo-build-test-cli:
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions ci/js-test-name-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ cd name-service/js

pnpm install
pnpm lint
pnpm build:program
pnpm build
pnpm test
1 change: 1 addition & 0 deletions ci/js-test-single-pool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pnpm lint
pnpm build

cd ../classic
pnpm build:program
pnpm lint
pnpm build
pnpm test
5 changes: 2 additions & 3 deletions ci/js-test-token-swap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pnpm install
pnpm build

cd token-swap/js
pnpm build:program
pnpm lint
pnpm start-with-test-validator
(cd ../../target/deploy && mv spl_token_swap_production.so spl_token_swap.so)
SWAP_PROGRAM_OWNER_FEE_ADDRESS="HfoTxFR1Tm6kGmWgYWD6J7YHVy1UwqSULUGVLXkJqaKN" pnpm start-with-test-validator
pnpm test
1 change: 1 addition & 0 deletions ci/js-test-token.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ pnpm install
pnpm build

cd token/js
pnpm build:program
pnpm lint
pnpm test
1 change: 1 addition & 0 deletions name-service/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"scripts": {
"dev": "tsc && node --trace-warnings dist/transfer.js",
"build": "tsc",
"build:program": "cargo build-sbf --manifest-path=../program/Cargo.toml",
"prepublish": "tsc",
"lint": "npm run pretty && eslint --max-warnings 0 'src/*.ts'",
"lint:fix": "npm run pretty:fix && eslint 'src/*.ts' --fix",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
],
"scripts": {
"build": "turbo run build",
"build:program": "turbo run build:program",
"clean": "turbo run clean",
"lint": "turbo run lint",
"lint:fix": "turbo run lint:fix",
Expand Down
1 change: 1 addition & 0 deletions single-pool/js/packages/classic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"scripts": {
"clean": "rm -rf dist/*",
"build": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./ts-fixup.sh",
"build:program": "cargo build-sbf --manifest-path=../../../program/Cargo.toml",
"lint": "eslint --max-warnings 0 .",
"lint:fix": "eslint . --fix",
"test": "sed -i '1s/.*/{ \"type\": \"module\",/' package.json && NODE_OPTIONS='--loader=tsx' ava ; ret=$?; sed -i '1s/.*/{/' package.json && exit $ret"
Expand Down
1 change: 1 addition & 0 deletions stake-pool/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "SPL Stake Pool Program JS API",
"scripts": {
"build": "tsc && cross-env NODE_ENV=production rollup -c",
"build:program": "cargo build-sbf --manifest-path=../program/Cargo.toml",
"lint": "eslint --max-warnings 0 .",
"lint:fix": "eslint . --fix",
"test": "jest",
Expand Down
5 changes: 3 additions & 2 deletions token-swap/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
"clean": "rm -rf lib/*",
"build": "tsc --build --verbose tsconfig.all.json",
"postbuild": "echo '{\"type\":\"commonjs\"}' > lib/cjs/package.json && echo '{\"type\":\"module\"}' > lib/esm/package.json",
"test": "mocha test",
"start-with-test-validator": "start-server-and-test 'solana-test-validator --bpf-program SwapsVeCiPHMUAtzQWZw7RjsKjgCjhwU55QGu4U1Szw ../../target/deploy/spl_token_swap.so --reset --quiet' http://127.0.0.1:8899/health test",
"build:program": "cargo build-sbf --manifest-path=../program/Cargo.toml",
"test:js": "mocha test",
"test": "start-server-and-test 'solana-test-validator --bpf-program SwapsVeCiPHMUAtzQWZw7RjsKjgCjhwU55QGu4U1Szw ../../target/deploy/spl_token_swap.so --reset --quiet' http://127.0.0.1:8899/health test:js",
"lint": "npm run pretty && eslint --max-warnings 0 .",
"lint:fix": "npm run pretty:fix && eslint . --fix",
"build:program": "cargo build-sbf --manifest-path ../program/Cargo.toml",
Expand Down
1 change: 1 addition & 0 deletions token/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"clean": "shx rm -rf lib **/*.tsbuildinfo || true",
"build": "tsc --build --verbose tsconfig.all.json",
"postbuild": "shx echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json",
"build:program": "cargo build-sbf --manifest-path=../program/Cargo.toml && cargo build-sbf --manifest-path=../program-2022/Cargo.toml && cargo build-sbf --manifest-path=../../associated-token-account/program/Cargo.toml && cargo build-sbf --manifest-path=../transfer-hook/example/Cargo.toml",
"watch": "tsc --build --verbose --watch tsconfig.all.json",
"release": "npm run clean && npm run build",
"fmt": "prettier --write '{*,**/*}.{ts,tsx,js,jsx,json}'",
Expand Down
3 changes: 3 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"dependsOn": ["^build"],
"outputs": ["dist/**", "lib/**"]
},
"build:program": {
"dependsOn": ["^build:program"]
},
"clean": {},
"lint:fix": {
"inputs": ["src/**", "test/**"],
Expand Down

0 comments on commit e333bef

Please sign in to comment.