Skip to content

Commit 9102f1b

Browse files
committed
fix(integration_tests): fix listed v2 projects
1 parent 631e75f commit 9102f1b

File tree

4 files changed

+14
-62
lines changed

4 files changed

+14
-62
lines changed

integration_test_declarative/cloudbuild.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ options:
77

88
timeout: '3600s'
99

10-
substitutions:
11-
_PROJECT_ID: 'functions-integration-tests'
12-
_REGION: 'us-central1'
10+
# No substitutions needed - each test suite uses its own project from YAML config
1311

1412
steps:
1513
# Build SDK and run all enabled test suites sequentially
16-
- name: 'node:18'
14+
- name: 'node:20'
1715
id: 'build-sdk-and-test'
1816
entrypoint: 'bash'
1917
args:
@@ -44,7 +42,8 @@ steps:
4442
# This will run all suites defined in config/v1/suites.yaml and config/v2/suites.yaml
4543
# Commented out suites in YAML will be automatically skipped
4644
# The tests will automatically use the firebase-functions-local.tgz we just created
47-
npm run test:all:sequential
45+
# Use the already-packed SDK instead of packing again
46+
node scripts/run-tests.js --sequential --use-published-sdk=file:firebase-functions-local.tgz
4847
4948
# Artifacts to store
5049
artifacts:

integration_test_declarative/config/v2/suites.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Common values are defined in the defaults section to reduce duplication
44

55
defaults:
6-
projectId: functions-integration-tests
6+
projectId: functions-integration-tests-v2
77
region: us-central1
88
timeout: 540
99
dependencies:
@@ -114,7 +114,6 @@ suites:
114114

115115
# Identity Platform triggers (replaces v1 auth blocking)
116116
- name: v2_identity
117-
projectId: functions-integration-tests-v2 # Override default project
118117
description: "V2 Identity trigger tests"
119118
version: v2
120119
service: identity
@@ -126,7 +125,6 @@ suites:
126125

127126
# EventArc triggers
128127
- name: v2_eventarc
129-
projectId: functions-integration-tests-v2 # Override default project
130128
description: "V2 Eventarc trigger tests"
131129
version: v2
132130
service: eventarc

integration_test_declarative/scripts/run-tests.js

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class TestRunner {
4747
this.logFile = join(LOGS_DIR, `test-run-${this.timestamp}.log`);
4848
this.deploymentSuccess = false;
4949
this.results = { passed: [], failed: [] };
50-
this.sdkTarballPath = null; // Store the SDK tarball path to avoid repacking
5150
}
5251

5352
/**
@@ -280,63 +279,21 @@ class TestRunner {
280279
return suites;
281280
}
282281

283-
/**
284-
* Pack the local Firebase Functions SDK
285-
*/
286-
async packLocalSDK() {
287-
this.log("📦 Packing local firebase-functions SDK...", "info");
288-
289-
const parentDir = join(ROOT_DIR, "..");
290-
const targetPath = join(ROOT_DIR, "firebase-functions-local.tgz");
291-
292-
try {
293-
// Run npm pack in parent directory
294-
const result = await this.exec("npm pack", { cwd: parentDir, silent: true });
295-
296-
// Find the generated tarball name (last line of output)
297-
const tarballName = result.stdout.trim().split("\n").pop();
298-
299-
// Move to expected location
300-
const sourcePath = join(parentDir, tarballName);
301-
302-
if (existsSync(sourcePath)) {
303-
// Remove old tarball if exists
304-
if (existsSync(targetPath)) {
305-
rmSync(targetPath);
306-
}
307-
308-
// Move new tarball
309-
renameSync(sourcePath, targetPath);
310-
this.log("✓ Local SDK packed successfully", "success");
311-
return targetPath;
312-
} else {
313-
throw new Error(`Tarball not found at ${sourcePath}`);
314-
}
315-
} catch (error) {
316-
throw new Error(`Failed to pack local SDK: ${error.message}`);
317-
}
318-
}
319-
320282
/**
321283
* Generate functions from templates
322284
*/
323285
async generateFunctions(suiteNames) {
324286
this.log("📦 Generating functions...", "info");
325287

326-
// Pack local SDK unless using published version
288+
// Use SDK tarball (must be provided via --use-published-sdk or pre-packed)
327289
let sdkTarball;
328290
if (this.usePublishedSDK) {
329291
sdkTarball = this.usePublishedSDK;
330-
this.log(` Using published SDK: ${sdkTarball}`, "info");
331-
} else if (this.sdkTarballPath) {
332-
// Use already packed SDK
333-
sdkTarball = `file:firebase-functions-local.tgz`;
334-
this.log(` Using already packed SDK: ${this.sdkTarballPath}`, "info");
292+
this.log(` Using provided SDK: ${sdkTarball}`, "info");
335293
} else {
336-
// Pack the local SDK for the first time
337-
this.sdkTarballPath = await this.packLocalSDK();
294+
// Default to local tarball (should be pre-packed by Cloud Build or manually)
338295
sdkTarball = `file:firebase-functions-local.tgz`;
339-
this.log(` Using local SDK: ${this.sdkTarballPath}`, "info");
296+
this.log(` Using local SDK: firebase-functions-local.tgz`, "info");
340297
}
341298

342299
try {
@@ -834,11 +791,9 @@ class TestRunner {
834791
await this.cleanupExistingResources();
835792
}
836793

837-
// Pack the SDK once for all suites (unless using published SDK)
838-
if (!this.usePublishedSDK && !this.sdkTarballPath) {
839-
this.log("📦 Packing SDK once for all suites...", "info");
840-
this.sdkTarballPath = await this.packLocalSDK();
841-
this.log(`✓ SDK packed and will be reused for all suites`, "success");
794+
// SDK should be pre-packed (by Cloud Build or manually)
795+
if (!this.usePublishedSDK) {
796+
this.log("📦 Using pre-packed SDK for all suites...", "info");
842797
}
843798

844799
// Run each suite
@@ -1028,7 +983,7 @@ async function main() {
1028983
console.log(" --exclude=PATTERN Skip suites matching pattern");
1029984
console.log(" --test-run-id=ID Use specific TEST_RUN_ID");
1030985
console.log(
1031-
" --use-published-sdk=VER Use published SDK version instead of local (default: pack local)"
986+
" --use-published-sdk=VER Use published SDK version instead of local (default: use pre-packed local)"
1032987
);
1033988
console.log(" --save-artifact Save test metadata for future cleanup");
1034989
console.log(" --skip-cleanup Skip pre-run cleanup (sequential mode only)");

integration_test_declarative/templates/functions/package.json.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Generated Firebase Functions for {{name}}",
55
"main": "lib/index.js",
66
"engines": {
7-
"node": "18"
7+
"node": "20"
88
},
99
"scripts": {
1010
"build": "tsc",

0 commit comments

Comments
 (0)