Skip to content

Commit

Permalink
Update node versions used in GitHub actions (#1479)
Browse files Browse the repository at this point in the history
Also bump/enable test timeouts to successfully run in node 18/20 environments.
  • Loading branch information
taeold authored Nov 2, 2023
1 parent 3e7a4b7 commit 93c47e3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/postmerge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/bin-test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
79 changes: 44 additions & 35 deletions scripts/bin-test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -124,7 +123,7 @@ async function startBin(
throw e;
}
return true;
}, TIMEOUT_M);
}, TIMEOUT_L);

if (debug) {
proc.stdout?.on("data", (data: unknown) => {
Expand All @@ -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);
Expand All @@ -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<void>;
Expand All @@ -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;
Expand All @@ -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",
Expand Down Expand Up @@ -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);
});
}
});
});

0 comments on commit 93c47e3

Please sign in to comment.