Skip to content

Commit

Permalink
Set Node to v20 (#6055)
Browse files Browse the repository at this point in the history
* fix: set front-end to Node v20, fix use of ts-node

* fix: Cypress CI workflow now uses required Node version and dependencies cache

* fix: Add install=false for cypress-io/github-action

* fix: in CI workflow, install and cache Cypress binary

* docs: add JSDoc description to register-tsNodeESM.js file
  • Loading branch information
Erick Cardenas Mendez authored and Mathilde Daugy committed Nov 2, 2023
1 parent 508eec4 commit f1ca39f
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 22 deletions.
51 changes: 50 additions & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,37 @@ jobs:
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: './web/.node-version'
- name: Cache Cypress binary
id: cache-cypress
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ hashFiles('./web/pnpm-lock.yaml') }}
- name: Restore node_modules for web
id: cache-web
uses: actions/cache@v3
with:
path: web/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('./web/pnpm-lock.yaml') }}
- name: Install web dependencies
if: steps.cache-web.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile
working-directory: ./web
- name: Install Cypress binary
if: steps.cache-cypress.outputs.cache-hit != 'true'
run: pnpm exec cypress install
working-directory: ./web
- name: Cypress run component tests
uses: cypress-io/github-action@v6
env:
TZ: Europe/Copenhagen
with:
working-directory: ./web
install: true
install: false
# to run component tests we need to use "component: true"
component: true
- name: Upload screenshots
Expand All @@ -38,12 +62,37 @@ jobs:
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: './web/.node-version'
- name: Cache Cypress binary
id: cache-cypress
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ hashFiles('./web/pnpm-lock.yaml') }}
- name: Restore node_modules for web
id: cache-web
uses: actions/cache@v3
with:
path: web/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('./web/pnpm-lock.yaml') }}
- name: Install web dependencies
if: steps.cache-web.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile
working-directory: ./web
- name: Install Cypress binary
if: steps.cache-cypress.outputs.cache-hit != 'true'
run: pnpm exec cypress install
working-directory: ./web
- name: Cypress run e2e tests
uses: cypress-io/github-action@v6
env:
TZ: Europe/Copenhagen
with:
working-directory: ./web
install: false
build: pnpm run build --mode testing
start: pnpm run preview
config: baseUrl=http://127.0.0.1:4173/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-preview-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node v18.x
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: './web/.node-version'
- name: Restore node_modules for web
id: cache-web
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node v18.x
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: './web/.node-version'
- name: Restore node_modules for web
id: cache-web
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node v18.x
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: './web/.node-version'
- name: Restore node_modules for web
id: cache-web
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/jsonlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node LTS
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: './web/.node-version'
- name: Install jsonlint-mod
run: |
npm install -g jsonlint-mod
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node v18.x
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: './web/.node-version'
- name: Restore node_modules for web
id: cache-web
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node v18.x
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: './web/.node-version'
- name: Restore node_modules for web
id: cache-web
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node v18.x
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: './web/.node-version'
- name: Restore node_modules for web
id: cache-web
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate_generate_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node v18.x
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: './web/.node-version'
- name: Restore node_modules for web
id: cache-web
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate_generated_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node v18.x
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: './web/.node-version'
- name: Restore node_modules
id: cache
uses: actions/cache@v3
Expand Down
1 change: 1 addition & 0 deletions mockserver/.node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
1 change: 1 addition & 0 deletions web/.node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
6 changes: 3 additions & 3 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"build": "pnpm update-version && vite build",
"update-version": "echo '{\"version\": \"'$npm_package_version'\"}' > public/client-version.json",
"create-generated-files": "pnpm run generate-world && pnpm run generate-zones-config",
"generate-world": "ts-node --esm ./geo/generateWorld.ts",
"generate-zones-config": "ts-node --esm ./scripts/generateZonesConfig.ts",
"generate-world": "node --import=./scripts/register-tsNodeESM.js ./geo/generateWorld.ts",
"generate-zones-config": "node --import=./scripts/register-tsNodeESM.js ./scripts/generateZonesConfig.ts",
"predev": "pnpm run create-generated-files",
"dev": "vite --open",
"cy:component": "cypress open --component -b electron",
Expand Down Expand Up @@ -195,7 +195,7 @@
"workbox-window": "7.0.0"
},
"engines": {
"node": ">=18",
"node": "^20",
"pnpm": "^8"
}
}
8 changes: 8 additions & 0 deletions web/scripts/register-tsNodeESM.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* This script is meant to be used with 'node --import=register-tsNodeESM.js', and allows
* node v20 to use ts-node to execute Typescript files that contain ESM modules, without
* outputting JS files.
*/
import { register } from 'node:module';
import { pathToFileURL } from 'node:url';
register('ts-node/esm', pathToFileURL('./'));

0 comments on commit f1ca39f

Please sign in to comment.