Skip to content

Commit

Permalink
Upgrade tooling to node 18, remove explicit support for node 14 (#5730)
Browse files Browse the repository at this point in the history
* 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 <bkend@google.com>
  • Loading branch information
joehan and bkendall authored May 9, 2023
1 parent b343e5d commit 9d0d4c8
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 36 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/node-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
node-version:
- "16"
- "18"
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -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

Expand All @@ -44,7 +44,6 @@ jobs:
strategy:
matrix:
node-version:
- "14"
- "16"
- "18"
steps:
Expand All @@ -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
Expand All @@ -80,7 +79,7 @@ jobs:
fail-fast: false
matrix:
node-version:
- "16"
- "18"
script:
- npm run test:client-integration
- npm run test:emulator
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -186,7 +185,7 @@ jobs:
strategy:
matrix:
node-version:
- "16"
- "18"

steps:
- uses: actions/checkout@v3
Expand All @@ -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)"
Expand All @@ -207,7 +206,7 @@ jobs:
strategy:
matrix:
node-version:
- "16"
- "18"

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 19 additions & 6 deletions scripts/emulator-import-export-tests/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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<string> {
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");
Expand Down Expand Up @@ -113,26 +125,27 @@ 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"
);
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"
);
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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/examples/hosting/update-single-file/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"engines": {
"node": ">=16.4.0"
"node": ">=18.0.0"
},
"author": "",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions scripts/firepit-builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16
FROM node:18

# Install dependencies
RUN apt-get update && \
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/functions-deploy-tests/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"firebase-functions": "^4.1.0"
},
"engines": {
"node": "16"
"node": "18"
},
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"firebase-functions": "^4.0.0"
},
"engines": {
"node": "16"
"node": "18"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"firebase-functions": "^4.0.0"
},
"engines": {
"node": "16"
"node": "18"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"firebase-functions": "^4.0.0"
},
"engines": {
"node": "16"
"node": "18"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"firebase-functions": "^4.0.0"
},
"engines": {
"node": "16"
"node": "18"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"firebase-functions": "^4.0.0"
},
"engines": {
"node": "16"
"node": "18"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@firebase/a-test-pkg": "0.0.1"
},
"engines": {
"node": "16"
"node": "18"
},
"private": true
}
2 changes: 1 addition & 1 deletion scripts/triggers-end-to-end-tests/triggers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Cloud Functions for Firebase",
"scripts": {},
"engines": {
"node": "16"
"node": "18"
},
"dependencies": {
"@firebase/database-compat": "0.1.2",
Expand Down
2 changes: 1 addition & 1 deletion scripts/triggers-end-to-end-tests/v1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Cloud Functions for Firebase",
"scripts": {},
"engines": {
"node": "16"
"node": "18"
},
"dependencies": {
"@firebase/database-compat": "0.1.2",
Expand Down
2 changes: 1 addition & 1 deletion scripts/triggers-end-to-end-tests/v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Cloud Functions for Firebase",
"scripts": {},
"engines": {
"node": "16"
"node": "18"
},
"dependencies": {
"firebase-admin": "^11.0.0",
Expand Down

0 comments on commit 9d0d4c8

Please sign in to comment.