diff --git a/.github/workflows/postmerge.yaml b/.github/workflows/postmerge.yaml index 15835d76a..543f77c2c 100644 --- a/.github/workflows/postmerge.yaml +++ b/.github/workflows/postmerge.yaml @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 - uses: google-github-actions/auth@v0 with: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a02370d1f..686953002 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -30,9 +30,8 @@ jobs: strategy: matrix: node-version: - - 14.x - - 16.x - 18.x + - 20.x steps: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 @@ -51,9 +50,8 @@ jobs: strategy: matrix: node-version: - - 14.x - - 16.x - 18.x + - 20.x steps: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 diff --git a/scripts/bin-test/run.sh b/scripts/bin-test/run.sh index c3e3da673..aa10b4286 100755 --- a/scripts/bin-test/run.sh +++ b/scripts/bin-test/run.sh @@ -12,8 +12,8 @@ for f in scripts/bin-test/sources/*; do fi done -## DEBUG -ls -la scripts/bin-test/sources/commonjs/node_modules +# Make sure firebase-functions binary is executable +chmod +x ./lib/bin/firebase-functions.js mocha \ --file ./scripts/bin-test/mocha-setup.ts \ diff --git a/scripts/bin-test/test.ts b/scripts/bin-test/test.ts index b15012d70..efc5a5127 100644 --- a/scripts/bin-test/test.ts +++ b/scripts/bin-test/test.ts @@ -6,7 +6,6 @@ import { expect } from "chai"; import * as yaml from "js-yaml"; import fetch from "node-fetch"; import * as portfinder from "portfinder"; -import * as semver from "semver"; const TIMEOUT_XL = 20_000; const TIMEOUT_L = 10_000; @@ -124,7 +123,7 @@ async function startBin( throw e; } return true; - }, TIMEOUT_M); + }, TIMEOUT_L); if (debug) { proc.stdout?.on("data", (data: unknown) => { @@ -139,7 +138,7 @@ async function startBin( return { port, cleanup: async () => { - process.kill(proc.pid); + process.kill(proc.pid, 9); await retryUntil(async () => { try { process.kill(proc.pid, 0); @@ -148,12 +147,15 @@ async function startBin( return Promise.resolve(true); } return Promise.resolve(false); - }, TIMEOUT_M); + }, TIMEOUT_L); }, }; } -describe("functions.yaml", () => { +describe("functions.yaml", function () { + // eslint-disable-next-line @typescript-eslint/no-invalid-this + this.timeout(TIMEOUT_XL); + function runTests(tc: Testcase) { let port: number; let cleanup: () => Promise; @@ -168,7 +170,10 @@ describe("functions.yaml", () => { await cleanup?.(); }); - it("functions.yaml returns expected Manifest", async () => { + it("functions.yaml returns expected Manifest", async function () { + // eslint-disable-next-line @typescript-eslint/no-invalid-this + this.timeout(TIMEOUT_M); + const res = await fetch(`http://localhost:${port}/__/functions.yaml`); const text = await res.text(); let parsed: any; @@ -181,7 +186,10 @@ describe("functions.yaml", () => { }); } - describe("commonjs", () => { + describe("commonjs", function () { + // eslint-disable-next-line @typescript-eslint/no-invalid-this + this.timeout(TIMEOUT_L); + const testcases: Testcase[] = [ { name: "basic", @@ -250,34 +258,35 @@ describe("functions.yaml", () => { runTests(tc); }); } - }).timeout(TIMEOUT_L); + }); - if (semver.gt(process.versions.node, "13.2.0")) { - describe("esm", () => { - const testcases: Testcase[] = [ - { - name: "basic", - modulePath: "./scripts/bin-test/sources/esm", - expected: BASE_STACK, - }, - { - name: "with main", + describe("esm", function () { + // eslint-disable-next-line @typescript-eslint/no-invalid-this + this.timeout(TIMEOUT_L); - modulePath: "./scripts/bin-test/sources/esm-main", - expected: BASE_STACK, - }, - { - name: "with .m extension", - modulePath: "./scripts/bin-test/sources/esm-ext", - expected: BASE_STACK, - }, - ]; + const testcases: Testcase[] = [ + { + name: "basic", + modulePath: "./scripts/bin-test/sources/esm", + expected: BASE_STACK, + }, + { + name: "with main", - for (const tc of testcases) { - describe(tc.name, () => { - runTests(tc); - }); - } - }).timeout(TIMEOUT_L); - } -}).timeout(TIMEOUT_XL); + modulePath: "./scripts/bin-test/sources/esm-main", + expected: BASE_STACK, + }, + { + name: "with .m extension", + modulePath: "./scripts/bin-test/sources/esm-ext", + expected: BASE_STACK, + }, + ]; + + for (const tc of testcases) { + describe(tc.name, () => { + runTests(tc); + }); + } + }); +});