From 9d0d4c8d5925691ce5932487b2137fd30841fe7a Mon Sep 17 00:00:00 2001 From: joehan Date: Tue, 9 May 2023 08:38:59 -0700 Subject: [PATCH] Upgrade tooling to node 18, remove explicit support for node 14 (#5730) * Upgrade tooling to node 18, remove explicit support for node 14 * Add log to debug broken test * formats * Fix functions-discovery tests * Fix functions-discover tests * Try longer wait for import/export test * Keep import-export on node 16 * check if npm 9 is the issue * Comment out import-export for now * flex my ip resolution knowledge by using a resolver * reinstate import-export test --------- Co-authored-by: Bryan Kendall --- .github/workflows/node-test.yml | 25 +++++++++---------- npm-shrinkwrap.json | 2 +- package.json | 2 +- scripts/emulator-import-export-tests/tests.ts | 25 ++++++++++++++----- .../update-single-file/package-lock.json | 2 +- .../hosting/update-single-file/package.json | 2 +- scripts/firepit-builder/Dockerfile | 6 ++--- .../functions/package.json | 2 +- .../fixtures/codebases/v1/package.json | 2 +- .../fixtures/codebases/v2/package.json | 2 +- .../fixtures/esm/functions/package.json | 2 +- .../fixtures/pnpm/functions/package.json | 2 +- .../fixtures/simple/functions/package.json | 2 +- .../packages/functions/package.json | 2 +- .../triggers/package.json | 2 +- .../triggers-end-to-end-tests/v1/package.json | 2 +- .../triggers-end-to-end-tests/v2/package.json | 2 +- 17 files changed, 48 insertions(+), 36 deletions(-) diff --git a/.github/workflows/node-test.yml b/.github/workflows/node-test.yml index 807ea33765a..d4f98b11b3d 100644 --- a/.github/workflows/node-test.yml +++ b/.github/workflows/node-test.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: node-version: - - "16" + - "18" steps: - uses: actions/checkout@v3 with: @@ -35,7 +35,7 @@ jobs: cache: npm cache-dependency-path: npm-shrinkwrap.json - - run: npm i -g npm@8.7 + - run: npm i -g npm@9.5 - run: npm ci - run: npm run lint:changed-files @@ -44,7 +44,6 @@ jobs: strategy: matrix: node-version: - - "14" - "16" - "18" steps: @@ -55,12 +54,12 @@ jobs: cache: npm cache-dependency-path: npm-shrinkwrap.json - - run: npm i -g npm@8.7 + - run: npm i -g npm@9.5 - run: npm ci - run: npm test -- -- --forbid-only - uses: codecov/codecov-action@v3 - if: matrix.node-version == '14' + if: matrix.node-version == '16' integration: needs: unit @@ -80,7 +79,7 @@ jobs: fail-fast: false matrix: node-version: - - "16" + - "18" script: - npm run test:client-integration - npm run test:emulator @@ -110,7 +109,7 @@ jobs: key: ${{ runner.os }}-firebase-emulators-${{ hashFiles('emulator-cache/**') }} continue-on-error: true - - run: npm i -g npm@8.7 + - run: npm i -g npm@9.5 - run: npm ci - run: echo ${{ secrets.service_account_json_base64 }} | base64 -d > ./scripts/service-account.json - run: ${{ matrix.script }} @@ -137,13 +136,13 @@ jobs: fail-fast: false matrix: node-version: - - "16" + - "18" script: - npm run test:hosting # - npm run test:hosting-rewrites # Long-running test that might conflict across test runs. Run this manually. - npm run test:client-integration - npm run test:emulator - # - npm run test:import-export # Fails becuase port 4000 is taken after first run - hub not shhutting down? + # - npm run test:import-export # Fails becuase port 4000 is taken after first run - hub not shutting down? # - npm run test:extensions-emulator # Fails due to cannot find module sharp (not waiting for npm install?) - npm run test:functions-discover - npm run test:triggers-end-to-end @@ -173,7 +172,7 @@ jobs: - run: echo ${{ secrets.service_account_json_base64 }} > tmp.txt - run: certutil -decode tmp.txt scripts/service-account.json - - run: npm i -g npm@8.7 + - run: npm i -g npm@9.5 - run: npm ci - run: ${{ matrix.script }} - name: Print debug logs @@ -186,7 +185,7 @@ jobs: strategy: matrix: node-version: - - "16" + - "18" steps: - uses: actions/checkout@v3 @@ -196,7 +195,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: npm cache-dependency-path: npm-shrinkwrap.json - - run: npm i -g npm@8.7 + - run: npm i -g npm@9.5 # --ignore-scripts prevents the `prepare` script from being run. - run: npm install --package-lock-only --ignore-scripts - run: "git diff --exit-code -- npm-shrinkwrap.json || (echo 'Error: npm-shrinkwrap.json is changed during npm install! Please make sure to use npm >= 8 and commit npm-shrinkwrap.json.' && false)" @@ -207,7 +206,7 @@ jobs: strategy: matrix: node-version: - - "16" + - "18" steps: - uses: actions/checkout@v3 diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 1d8a290c4b1..33b27c6ab9a 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -161,7 +161,7 @@ "vite": "^4.2.1" }, "engines": { - "node": "^14.18.0 || >=16.4.0" + "node": ">=16.13.0 || >=18.0.0" } }, "node_modules/@ampproject/remapping": { diff --git a/package.json b/package.json index 6d3022c500f..e659354e6ef 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ ], "preferGlobal": true, "engines": { - "node": "^14.18.0 || >=16.4.0" + "node": ">=16.13.0 || >=18.0.0" }, "author": "Firebase (https://firebase.google.com/)", "license": "MIT", diff --git a/scripts/emulator-import-export-tests/tests.ts b/scripts/emulator-import-export-tests/tests.ts index 66c9f204f31..823cc9653b8 100644 --- a/scripts/emulator-import-export-tests/tests.ts +++ b/scripts/emulator-import-export-tests/tests.ts @@ -6,6 +6,7 @@ import * as path from "path"; import { CLIProcess } from "../integration-helpers/cli"; import { FrameworkOptions } from "../integration-helpers/framework"; +import { Resolver } from "../../src/emulator/dns"; const FIREBASE_PROJECT = process.env.FBTOOLS_TARGET_PROJECT || ""; const ADMIN_CREDENTIAL = { @@ -25,6 +26,17 @@ const ALL_EMULATORS_STARTED_LOG = "All emulators ready"; */ const TEST_SETUP_TIMEOUT = 60000; +const r = new Resolver(); +let addr: string; +async function localhost(): Promise { + if (addr) { + return addr; + } + const a = await r.lookupFirst("localhost"); + addr = a.address; + return addr; +} + function readConfig(): FrameworkOptions { const filename = path.join(__dirname, "firebase.json"); const data = fs.readFileSync(filename, "utf8"); @@ -113,10 +125,11 @@ describe("import/export end to end", () => { // Write some data to export const config = readConfig(); const port = config.emulators!.database.port; + const host = await localhost(); const aApp = admin.initializeApp( { projectId: FIREBASE_PROJECT, - databaseURL: `http://localhost:${port}?ns=namespace-a`, + databaseURL: `http://${host}:${port}?ns=namespace-a`, credential: ADMIN_CREDENTIAL, }, "rtdb-export-a" @@ -124,7 +137,7 @@ describe("import/export end to end", () => { const bApp = admin.initializeApp( { projectId: FIREBASE_PROJECT, - databaseURL: `http://localhost:${port}?ns=namespace-b`, + databaseURL: `http://${host}:${port}?ns=namespace-b`, credential: ADMIN_CREDENTIAL, }, "rtdb-export-b" @@ -132,7 +145,7 @@ describe("import/export end to end", () => { const cApp = admin.initializeApp( { projectId: FIREBASE_PROJECT, - databaseURL: `http://localhost:${port}?ns=namespace-c`, + databaseURL: `http://${host}:${port}?ns=namespace-c`, credential: ADMIN_CREDENTIAL, }, "rtdb-export-c" @@ -228,7 +241,7 @@ describe("import/export end to end", () => { const config = readConfig(); const port = config.emulators!.auth.port; try { - process.env.FIREBASE_AUTH_EMULATOR_HOST = `localhost:${port}`; + process.env.FIREBASE_AUTH_EMULATOR_HOST = `${await localhost()}:${port}`; const adminApp = admin.initializeApp( { projectId: project, @@ -335,7 +348,7 @@ describe("import/export end to end", () => { const config = readConfig(); const port = config.emulators!.auth.port; try { - process.env.FIREBASE_AUTH_EMULATOR_HOST = `localhost:${port}`; + process.env.FIREBASE_AUTH_EMULATOR_HOST = `${await localhost()}:${port}`; const adminApp = admin.initializeApp( { projectId: project, @@ -477,7 +490,7 @@ describe("import/export end to end", () => { const config = readConfig(); const port = config.emulators!.storage.port; - process.env.STORAGE_EMULATOR_HOST = `http://localhost:${port}`; + process.env.STORAGE_EMULATOR_HOST = `http://${await localhost()}:${port}`; // Write some data to export const aApp = admin.initializeApp( diff --git a/scripts/examples/hosting/update-single-file/package-lock.json b/scripts/examples/hosting/update-single-file/package-lock.json index cdc14289fde..1a7aac3473c 100644 --- a/scripts/examples/hosting/update-single-file/package-lock.json +++ b/scripts/examples/hosting/update-single-file/package-lock.json @@ -21,7 +21,7 @@ "typescript": "^4.7.4" }, "engines": { - "node": ">=16.4.0" + "node": ">=18.0.0" } }, "node_modules/@types/debug": { diff --git a/scripts/examples/hosting/update-single-file/package.json b/scripts/examples/hosting/update-single-file/package.json index af6023dba45..f6d9d62f6a9 100644 --- a/scripts/examples/hosting/update-single-file/package.json +++ b/scripts/examples/hosting/update-single-file/package.json @@ -12,7 +12,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "engines": { - "node": ">=16.4.0" + "node": ">=18.0.0" }, "author": "", "license": "MIT", diff --git a/scripts/firepit-builder/Dockerfile b/scripts/firepit-builder/Dockerfile index 32e473be367..c35b8dd6aae 100644 --- a/scripts/firepit-builder/Dockerfile +++ b/scripts/firepit-builder/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16 +FROM node:18 # Install dependencies RUN apt-get update && \ @@ -8,8 +8,8 @@ RUN apt-get update && \ RUN curl -fsSL --output hub.tgz https://github.com/github/hub/releases/download/v2.11.2/hub-linux-amd64-2.11.2.tgz RUN tar --strip-components=2 -C /usr/bin -xf hub.tgz hub-linux-amd64-2.11.2/bin/hub -# Upgrade npm to 8. -RUN npm install --global npm@8.7 +# Upgrade npm to 9. +RUN npm install --global npm@9.5 # Create app directory WORKDIR /usr/src/app diff --git a/scripts/functions-deploy-tests/functions/package.json b/scripts/functions-deploy-tests/functions/package.json index affb998fa58..94834d41623 100644 --- a/scripts/functions-deploy-tests/functions/package.json +++ b/scripts/functions-deploy-tests/functions/package.json @@ -11,7 +11,7 @@ "firebase-functions": "^4.1.0" }, "engines": { - "node": "16" + "node": "18" }, "private": true } diff --git a/scripts/functions-discover-tests/fixtures/codebases/v1/package.json b/scripts/functions-discover-tests/fixtures/codebases/v1/package.json index adf0b75f8b1..e57e928a5e2 100644 --- a/scripts/functions-discover-tests/fixtures/codebases/v1/package.json +++ b/scripts/functions-discover-tests/fixtures/codebases/v1/package.json @@ -4,6 +4,6 @@ "firebase-functions": "^4.0.0" }, "engines": { - "node": "16" + "node": "18" } } diff --git a/scripts/functions-discover-tests/fixtures/codebases/v2/package.json b/scripts/functions-discover-tests/fixtures/codebases/v2/package.json index 77e5ecf8296..63b1894db29 100644 --- a/scripts/functions-discover-tests/fixtures/codebases/v2/package.json +++ b/scripts/functions-discover-tests/fixtures/codebases/v2/package.json @@ -5,6 +5,6 @@ "firebase-functions": "^4.0.0" }, "engines": { - "node": "16" + "node": "18" } } diff --git a/scripts/functions-discover-tests/fixtures/esm/functions/package.json b/scripts/functions-discover-tests/fixtures/esm/functions/package.json index 8dae4f69724..bdd9f5344f5 100644 --- a/scripts/functions-discover-tests/fixtures/esm/functions/package.json +++ b/scripts/functions-discover-tests/fixtures/esm/functions/package.json @@ -5,6 +5,6 @@ "firebase-functions": "^4.0.0" }, "engines": { - "node": "16" + "node": "18" } } diff --git a/scripts/functions-discover-tests/fixtures/pnpm/functions/package.json b/scripts/functions-discover-tests/fixtures/pnpm/functions/package.json index b71df5af785..58ff3bbce4d 100644 --- a/scripts/functions-discover-tests/fixtures/pnpm/functions/package.json +++ b/scripts/functions-discover-tests/fixtures/pnpm/functions/package.json @@ -4,6 +4,6 @@ "firebase-functions": "^4.0.0" }, "engines": { - "node": "16" + "node": "18" } } diff --git a/scripts/functions-discover-tests/fixtures/simple/functions/package.json b/scripts/functions-discover-tests/fixtures/simple/functions/package.json index c72ddec5aa1..b62715e92f1 100644 --- a/scripts/functions-discover-tests/fixtures/simple/functions/package.json +++ b/scripts/functions-discover-tests/fixtures/simple/functions/package.json @@ -4,6 +4,6 @@ "firebase-functions": "^4.0.0" }, "engines": { - "node": "16" + "node": "18" } } diff --git a/scripts/functions-discover-tests/fixtures/yarn-workspaces/packages/functions/package.json b/scripts/functions-discover-tests/fixtures/yarn-workspaces/packages/functions/package.json index d97802dab12..cb4bf923d8a 100644 --- a/scripts/functions-discover-tests/fixtures/yarn-workspaces/packages/functions/package.json +++ b/scripts/functions-discover-tests/fixtures/yarn-workspaces/packages/functions/package.json @@ -7,7 +7,7 @@ "@firebase/a-test-pkg": "0.0.1" }, "engines": { - "node": "16" + "node": "18" }, "private": true } diff --git a/scripts/triggers-end-to-end-tests/triggers/package.json b/scripts/triggers-end-to-end-tests/triggers/package.json index 5e2e278cb5d..53631f02926 100644 --- a/scripts/triggers-end-to-end-tests/triggers/package.json +++ b/scripts/triggers-end-to-end-tests/triggers/package.json @@ -3,7 +3,7 @@ "description": "Cloud Functions for Firebase", "scripts": {}, "engines": { - "node": "16" + "node": "18" }, "dependencies": { "@firebase/database-compat": "0.1.2", diff --git a/scripts/triggers-end-to-end-tests/v1/package.json b/scripts/triggers-end-to-end-tests/v1/package.json index 4f5fa9cbe7b..20e5f269842 100644 --- a/scripts/triggers-end-to-end-tests/v1/package.json +++ b/scripts/triggers-end-to-end-tests/v1/package.json @@ -3,7 +3,7 @@ "description": "Cloud Functions for Firebase", "scripts": {}, "engines": { - "node": "16" + "node": "18" }, "dependencies": { "@firebase/database-compat": "0.1.2", diff --git a/scripts/triggers-end-to-end-tests/v2/package.json b/scripts/triggers-end-to-end-tests/v2/package.json index b88c3b6c82f..4fc272f1852 100644 --- a/scripts/triggers-end-to-end-tests/v2/package.json +++ b/scripts/triggers-end-to-end-tests/v2/package.json @@ -3,7 +3,7 @@ "description": "Cloud Functions for Firebase", "scripts": {}, "engines": { - "node": "16" + "node": "18" }, "dependencies": { "firebase-admin": "^11.0.0",