Skip to content

Commit

Permalink
[gha] Run checks and build against both Node 18/20 (#303)
Browse files Browse the repository at this point in the history
* [gha] Run checks and build against both Node 18/20

* include workflow paths

* [gha] Add Node 20 to CI (#7197)

GitOrigin-RevId: 968e1d03fd3aa5d70da737c784eae7d65607177d

* CI update lock file for PR

---------

Co-authored-by: Corey Martin <[email protected]>
Co-authored-by: Lightspark Eng <[email protected]>
  • Loading branch information
3 people authored Oct 27, 2023
1 parent a59d636 commit b7ca10d
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 34 deletions.
38 changes: 12 additions & 26 deletions .github/workflows/test-release-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ on:
pull_request:
paths:
- "**"
- ".github/workflows/**"
push:
branches:
- main
paths:
- "**"
- ".github/workflows/**"

jobs:
update-lock-file:
Expand Down Expand Up @@ -62,16 +64,19 @@ jobs:
# Wait to see if the lock file should be updated before running checks:
needs: "update-lock-file"
runs-on: "ubuntu-22.04"
strategy:
matrix:
node-version: ["18.x", "20.x"]
steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
ref: ${{ needs.update-lock-file.outputs.VERIFIED_LOCK_COMMIT }}

- name: "Setup Node"
- name: "Setup Node v${{ matrix.node-version }}"
uses: "actions/setup-node@v3"
with:
node-version-file: ".nvmrc"
node-version: ${{ matrix.node-version }}
cache: "yarn"
cache-dependency-path: "yarn.lock"

Expand All @@ -80,17 +85,6 @@ jobs:
with:
cwd: "."

- name: Restore turbo cache
uses: actions/cache@v3
with:
path: ./node_modules/.cache/turbo
# see https://bit.ly/43Til68 - we only need a single cache for all turbo files
# but the cache still needs a unique id in order for it to properly save each time.
# restore-keys will always take the latest matching cache:
key: turbo-checks-${{ runner.os }}-${{ github.run_id }} # Can use time based key as well
restore-keys: |
turbo-checks-${{ runner.os }}
- name: Setup .lightsparkenv file
run: |
echo 'export LIGHTSPARK_WALLET_BASE_URL="api.dev.dev.sparkinfra.net"' > ~/.lightsparkenv
Expand Down Expand Up @@ -122,16 +116,19 @@ jobs:
# Wait to see if the lock file should be updated before running checks:
needs: "update-lock-file"
runs-on: "ubuntu-22.04"
strategy:
matrix:
node-version: ["18.x", "20.x"]
steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
ref: ${{ needs.update-lock-file.outputs.VERIFIED_LOCK_COMMIT }}

- name: "Setup Node"
- name: "Setup Node v${{ matrix.node-version }}"
uses: "actions/setup-node@v3"
with:
node-version-file: ".nvmrc"
node-version: ${{ matrix.node-version }}
cache: "yarn"
cache-dependency-path: "yarn.lock"

Expand All @@ -140,17 +137,6 @@ jobs:
with:
cwd: "."

- name: Restore turbo cache
uses: actions/cache@v3
with:
path: ./node_modules/.cache/turbo
# see https://bit.ly/43Til68 - we only need a single cache for all turbo files
# but the cache still needs a unique id in order for it to properly save each time.
# restore-keys will always take the latest matching cache:
key: turbo-build-${{ runner.os }}-${{ github.run_id }} # Can use time based key as well
restore-keys: |
turbo-build-${{ runner.os }}
- run: "yarn build"

# - name: "Notify failure on Slack"
Expand Down
2 changes: 1 addition & 1 deletion apps/examples/remote-signing-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"type": "module",
"scripts": {
"start": "nodemon --watch 'src/*.ts' --exec 'ts-node' src/startServer.ts",
"start": "./start.sh",
"test:start": "./test.sh start",
"test": "./test.sh test"
},
Expand Down
21 changes: 21 additions & 0 deletions apps/examples/remote-signing-server/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# See https://github.com/TypeStrong/ts-node/issues/1997#issuecomment-1774047586
# ts-node has a known issue with es modules in Node.js 20 and above so we need to
# run with a different command to workaround with a warning:

# Get the Node.js version and remove the 'v' prefix
NODE_VERSION=$(node -v | cut -c 2-)

# Split the version string into major, minor, and patch numbers
IFS='.' read -ra VERSION_PARTS <<< "$NODE_VERSION"

if (( ${VERSION_PARTS[0]} >= 20 )); then
CMD="node --loader ts-node/esm"
elif (( ${VERSION_PARTS[0]} == 18 )); then
CMD="ts-node"
else
echo "Only Node.js versions 18 and above are supported"
fi

yarn nodemon --watch 'src/*.ts' --exec $CMD src/startServer.ts
2 changes: 1 addition & 1 deletion apps/examples/uma-vasp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"type": "module",
"scripts": {
"start": "nodemon --watch 'src/*.ts' --exec 'ts-node' src/startServer.ts",
"start": "./start.sh",
"test:start": "./test.sh start",
"test": "./test.sh test"
},
Expand Down
21 changes: 21 additions & 0 deletions apps/examples/uma-vasp/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# See https://github.com/TypeStrong/ts-node/issues/1997#issuecomment-1774047586
# ts-node has a known issue with es modules in Node.js 20 and above so we need to
# run with a different command to workaround with a warning:

# Get the Node.js version and remove the 'v' prefix
NODE_VERSION=$(node -v | cut -c 2-)

# Split the version string into major, minor, and patch numbers
IFS='.' read -ra VERSION_PARTS <<< "$NODE_VERSION"

if (( ${VERSION_PARTS[0]} >= 20 )); then
CMD="node --loader ts-node/esm"
elif (( ${VERSION_PARTS[0]} == 18 )); then
CMD="ts-node"
else
echo "Only Node.js versions 18 and above are supported"
fi

yarn nodemon --watch 'src/*.ts' --exec $CMD src/startServer.ts
4 changes: 2 additions & 2 deletions packages/lightspark-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"scripts": {
"build": "tsc -p .",
"clean": "rm -rf .turbo && rm -rf dist",
"dev": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts",
"cli": "ts-node src/index.ts",
"cli:watch": "nodemon --watch 'src/**/*.ts' --exec 'node --loader ts-node/esm' src/index.ts",
"cli": "node --loader ts-node/esm src/index.ts",
"format:fix": "prettier src --write",
"format": "prettier src --check",
"lint:fix": "eslint --fix .",
Expand Down
1 change: 0 additions & 1 deletion packages/lightspark-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
"prettier": "3.0.2",
"prettier-plugin-organize-imports": "^3.2.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-absolute": "^1.0.1",
"tsup": "^6.7.0",
"typedoc": "^0.24.7",
Expand Down
4 changes: 2 additions & 2 deletions packages/wallet-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"scripts": {
"build": "tsc -p .",
"clean": "rm -rf .turbo && rm -rf dist",
"dev": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts",
"cli": "ts-node src/index.ts",
"cli:watch": "nodemon --watch 'src/**/*.ts' --exec 'node --loader ts-node/esm' src/index.ts",
"cli": "node --loader ts-node/esm src/index.ts",
"format:fix": "prettier src --write",
"format": "prettier src --check",
"lint:fix": "eslint --fix .",
Expand Down
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3750,7 +3750,6 @@ __metadata:
prettier: 3.0.2
prettier-plugin-organize-imports: ^3.2.2
ts-jest: ^29.1.1
ts-node: ^10.9.1
tsc-absolute: ^1.0.1
tsup: ^6.7.0
typedoc: ^0.24.7
Expand Down

0 comments on commit b7ca10d

Please sign in to comment.