Commit 7a30f1fa authored by tom goriunov's avatar tom goriunov Committed by GitHub

Merge pull request #645 from blockscout/node-18

node.js v18
parents 127e81f2 3f3853a4
...@@ -13,7 +13,7 @@ jobs: ...@@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 18
cache: 'yarn' cache: 'yarn'
- name: Install dependencies - name: Install dependencies
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile
......
...@@ -6,20 +6,20 @@ on: ...@@ -6,20 +6,20 @@ on:
- main - main
jobs: jobs:
jest_tests: # jest_tests:
name: Run tests with Jest # name: Run tests with Jest
runs-on: ubuntu-latest # runs-on: ubuntu-latest
if: ${{ false }} # disable since there are no jest test yet # if: ${{ false }} # disable since there are no jest test yet
steps: # steps:
- uses: actions/checkout@v3 # - uses: actions/checkout@v3
- uses: actions/setup-node@v3 # - uses: actions/setup-node@v3
with: # with:
node-version: 16 # node-version: 18
cache: 'yarn' # cache: 'yarn'
- name: Install dependencies # - name: Install dependencies
run: yarn install --frozen-lockfile # run: yarn install --frozen-lockfile
- name: Run tests # - name: Run tests
run: yarn test:jest # run: yarn test:jest
pw_tests: pw_tests:
name: Run components visual tests with PlayWright name: Run components visual tests with PlayWright
...@@ -34,7 +34,7 @@ jobs: ...@@ -34,7 +34,7 @@ jobs:
lfs: 'true' lfs: 'true'
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 18
cache: 'yarn' cache: 'yarn'
- name: Install dependencies - name: Install dependencies
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile
......
# Install dependencies only when needed # Install dependencies only when needed
FROM node:16-alpine AS deps FROM node:18-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat RUN apk add --no-cache libc6-compat
WORKDIR /app WORKDIR /app
...@@ -10,7 +10,7 @@ RUN apk add git ...@@ -10,7 +10,7 @@ RUN apk add git
RUN yarn --frozen-lockfile RUN yarn --frozen-lockfile
# Rebuild the source code only when needed # Rebuild the source code only when needed
FROM node:16-alpine AS builder FROM node:18-alpine AS builder
WORKDIR /app WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
...@@ -33,7 +33,7 @@ ENV NEXT_PUBLIC_GIT_COMMIT_SHA=$GIT_COMMIT_SHA ...@@ -33,7 +33,7 @@ ENV NEXT_PUBLIC_GIT_COMMIT_SHA=$GIT_COMMIT_SHA
RUN yarn build RUN yarn build
# Production image, copy all the files and run next # Production image, copy all the files and run next
FROM node:16-alpine AS runner FROM node:18-alpine AS runner
WORKDIR /app WORKDIR /app
ENV NODE_ENV production ENV NODE_ENV production
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"private": true, "private": true,
"homepage": "https://github.com/blockscout/frontend#readme", "homepage": "https://github.com/blockscout/frontend#readme",
"engines": { "engines": {
"node": "16", "node": "18",
"npm": "8" "npm": "8"
}, },
"scripts": { "scripts": {
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
"prepare": "husky install", "prepare": "husky install",
"format-svg": "./node_modules/.bin/svgo -r ./icons", "format-svg": "./node_modules/.bin/svgo -r ./icons",
"test:pw": "./playwright/make-envs-script.sh && NODE_OPTIONS=\"--max-old-space-size=4096\" playwright test -c playwright-ct.config.ts", "test:pw": "./playwright/make-envs-script.sh && NODE_OPTIONS=\"--max-old-space-size=4096\" playwright test -c playwright-ct.config.ts",
"test:pw:local": "export NODE_PATH=$(pwd)/node_modules && yarn test:pw", "test:pw:local": "export NODE_PATH=$(pwd)/node_modules && rm -rf ./playwright/.cache && yarn test:pw",
"test:pw:docker": "docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.28.0-focal ./playwright/run-tests.sh", "test:pw:docker": "docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.31.0-focal ./playwright/run-tests.sh",
"test:jest": "jest", "test:jest": "jest",
"test:jest:watch": "jest --watch" "test:jest:watch": "jest --watch"
}, },
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
"wagmi": "^0.10.6" "wagmi": "^0.10.6"
}, },
"devDependencies": { "devDependencies": {
"@playwright/experimental-ct-react": "^1.28.0", "@playwright/experimental-ct-react": "1.31.0",
"@svgr/webpack": "^6.5.1", "@svgr/webpack": "^6.5.1",
"@testing-library/react": "^13.4.0", "@testing-library/react": "^13.4.0",
"@types/d3": "^7.4.0", "@types/d3": "^7.4.0",
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
"lint-staged": ">=10", "lint-staged": ">=10",
"mockdate": "^3.0.5", "mockdate": "^3.0.5",
"next-transpile-modules": "^10.0.0", "next-transpile-modules": "^10.0.0",
"playwright": "^1.28.0", "playwright": "1.31.0",
"svgo": "^2.8.0", "svgo": "^2.8.0",
"ts-jest": "^29.0.3", "ts-jest": "^29.0.3",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
......
...@@ -33,7 +33,12 @@ export const getServerSideProps: GetServerSideProps<Props> = async({ req, res, r ...@@ -33,7 +33,12 @@ export const getServerSideProps: GetServerSideProps<Props> = async({ req, res, r
try { try {
const q = String(query.q); const q = String(query.q);
const url = buildUrlNode('search_check_redirect', undefined, { q }); const url = buildUrlNode('search_check_redirect', undefined, { q });
const redirectsResponse = await fetchFactory(req)(url); const redirectsResponse = await fetchFactory(req)(url, {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore:next-line timeout property exist for AbortSignal since Node.js 17 - https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
// but @types/node has not updated their types yet, see issue https://github.com/DefinitelyTyped/DefinitelyTyped/issues/60868
signal: AbortSignal.timeout(1_000),
});
const payload = await redirectsResponse.json() as SearchRedirectResult; const payload = await redirectsResponse.json() as SearchRedirectResult;
if (!payload || typeof payload !== 'object' || !payload.redirect) { if (!payload || typeof payload !== 'object' || !payload.redirect) {
......
import type { PlaywrightTestConfig } from '@playwright/experimental-ct-react'; import type { PlaywrightTestConfig } from '@playwright/experimental-ct-react';
import { devices } from '@playwright/experimental-ct-react'; import { devices, defineConfig } from '@playwright/experimental-ct-react';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
import svgr from 'vite-plugin-svgr'; import svgr from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths'; import tsconfigPaths from 'vite-tsconfig-paths';
...@@ -7,7 +7,7 @@ import tsconfigPaths from 'vite-tsconfig-paths'; ...@@ -7,7 +7,7 @@ import tsconfigPaths from 'vite-tsconfig-paths';
/** /**
* See https://playwright.dev/docs/test-configuration. * See https://playwright.dev/docs/test-configuration.
*/ */
const config: PlaywrightTestConfig = { const config: PlaywrightTestConfig = defineConfig({
testDir: './', testDir: './',
testMatch: /.*\.pw\.tsx/, testMatch: /.*\.pw\.tsx/,
...@@ -57,6 +57,9 @@ const config: PlaywrightTestConfig = { ...@@ -57,6 +57,9 @@ const config: PlaywrightTestConfig = {
sourcemap: false, sourcemap: false,
minify: false, minify: false,
}, },
define: {
'process.env': 'process.env', // Port over window.process envs
},
}, },
}, },
...@@ -112,6 +115,6 @@ const config: PlaywrightTestConfig = { ...@@ -112,6 +115,6 @@ const config: PlaywrightTestConfig = {
}, },
}, },
], ],
}; });
export default config; export default config;
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment