Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add frameworks tests to windows job #7032

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c5bef98
add frameworks tests to windows job
leoortizz Apr 22, 2024
5efed7f
partial Windows fixes
leoortizz Apr 22, 2024
d4889d6
patterns with join
leoortizz Apr 22, 2024
43f0a20
separator fix
leoortizz Apr 22, 2024
7dfdaca
Merge branch 'master' into leoortizz_frameworksCi
leoortizz Apr 25, 2024
555ee24
Merge branch 'master' into leoortizz_frameworksCi
leoortizz Apr 26, 2024
e7785c0
more possible separator fixes
leoortizz Apr 26, 2024
0126c96
log
leoortizz Apr 26, 2024
afc2351
Merge branch 'master' into leoortizz_frameworksCi
leoortizz Apr 29, 2024
c922e0d
angular expected patterns fix
leoortizz Apr 29, 2024
e6a2557
run frameworks tests faster to debug
leoortizz Apr 29, 2024
e57c355
debug failing test
leoortizz Apr 29, 2024
6e484f7
Merge branch 'master' into leoortizz_frameworksCi
leoortizz Apr 30, 2024
50b40b1
disable content-type check in windows
leoortizz May 1, 2024
0c10112
Merge branch 'master' into leoortizz_frameworksCi
leoortizz May 1, 2024
9e8f056
disable headers checks for windows
leoortizz May 1, 2024
d46bde2
Revert "run frameworks tests faster to debug"
leoortizz May 1, 2024
1919710
remove console log
leoortizz May 1, 2024
f3ea259
test array instead of string.raw for next patterns
leoortizz May 1, 2024
96c5d45
filter & join in map
leoortizz May 1, 2024
55814c7
Merge branch 'master' into leoortizz_frameworksCi
leoortizz May 1, 2024
69db676
rename sep to PATH_SEPARATOR
leoortizz May 1, 2024
f3cc4a6
fix typos
leoortizz May 1, 2024
017926b
Merge branch 'master' into leoortizz_frameworksCi
leoortizz May 6, 2024
520a1c3
Merge branch 'master' into leoortizz_frameworksCi
leoortizz May 9, 2024
2f0b081
remove realpath option (#7148)
leoortizz May 9, 2024
0cf1f97
Merge branch 'master' into leoortizz_frameworksCi
leoortizz May 9, 2024
70879d9
Merge branch 'master' into leoortizz_frameworksCi
leoortizz May 9, 2024
d40c594
Merge branch 'master' into leoortizz_frameworksCi
leoortizz May 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/node-test.yml
Expand Up @@ -148,6 +148,7 @@ jobs:
- npm run test:triggers-end-to-end:inspect
- npm run test:storage-deploy
# - npm run test:storage-emulator-integration
- npm run test:frameworks
steps:
- name: Setup Java JDK
uses: actions/setup-java@v3.3.0
Expand Down
118 changes: 67 additions & 51 deletions scripts/webframeworks-deploy-tests/tests.ts
Expand Up @@ -2,13 +2,13 @@
import * as glob from "glob";
import { join, normalize, relative } from "path";
import { readFileSync } from "fs";
import fetch from "node-fetch";
import type { NextConfig } from "next";
import * as deepEqualUnordered from "deep-equal-in-any-order";
use(deepEqualUnordered);

import { getBuildId } from "../../src/frameworks/next/utils";
import { fileExistsSync } from "../../src/fsutils";
import { IS_WINDOWS } from "../../src/utils";
import { readFile } from "fs/promises";

const NEXT_OUTPUT_PATH = `${__dirname}/.firebase/demo-nextjs`;
Expand All @@ -21,6 +21,7 @@
const DEFAULT_LANG = "en";
const LOG_FILE = "firebase-debug.log";
const NEXT_SOURCE = `${__dirname}/nextjs`;
const PATH_SEPARATOR = IS_WINDOWS ? `\\\\` : `\/`;

Check warning on line 24 in scripts/webframeworks-deploy-tests/tests.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unnecessary escape character: \/

async function getFilesListFromDir(dir: string): Promise<string[]> {
const files = await new Promise<string[]>((resolve, reject) => {
Expand All @@ -39,12 +40,12 @@

before(async () => {
expect(FIREBASE_EMULATOR_HUB, "$FIREBASE_EMULATOR_HUB").to.not.be.empty;
const hubResponse = await fetch(`http://${FIREBASE_EMULATOR_HUB}/emulators`);

Check warning on line 43 in scripts/webframeworks-deploy-tests/tests.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "string | undefined" of template literal expression
const {

Check warning on line 44 in scripts/webframeworks-deploy-tests/tests.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
hosting: { port, host },
} = await hubResponse.json();
NEXTJS_HOST = `http://${host}:${port}/${NEXT_BASE_PATH}`.replace(/\/$/, "");

Check warning on line 47 in scripts/webframeworks-deploy-tests/tests.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 47 in scripts/webframeworks-deploy-tests/tests.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression
ANGULAR_HOST = `http://${host}:${port + 5}/${ANGULAR_BASE_PATH}`.replace(/\/$/, "");

Check warning on line 48 in scripts/webframeworks-deploy-tests/tests.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 48 in scripts/webframeworks-deploy-tests/tests.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 48 in scripts/webframeworks-deploy-tests/tests.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Operands of '+' operation with any is possible only with string, number, bigint or any
});

after(() => {
Expand Down Expand Up @@ -172,7 +173,7 @@
i18n: {
root: "/",
},
public: ".firebase/demo-nextjs/hosting",
public: join(".firebase", "demo-nextjs", "hosting"),
webFramework: "next_ssr",
},
{
Expand Down Expand Up @@ -205,7 +206,7 @@
i18n: {
root: "/",
},
public: ".firebase/demo-angular/hosting",
public: join(".firebase", "demo-angular", "hosting"),
webFramework: "angular_ssr",
},
],
Expand All @@ -217,11 +218,11 @@
},
{
codebase: "firebase-frameworks-demo-nextjs",
source: ".firebase/demo-nextjs/functions",
source: join(".firebase", "demo-nextjs", "functions"),
},
{
codebase: "firebase-frameworks-demo-angular",
source: ".firebase/demo-angular/functions",
source: join(".firebase", "demo-angular", "functions"),
},
],
});
Expand All @@ -231,14 +232,24 @@
describe("next.js", () => {
describe("app directory", () => {
it("should have working static routes", async () => {
const apiStaticJSON = JSON.parse(

Check warning on line 235 in scripts/webframeworks-deploy-tests/tests.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
readFileSync(`${NEXT_OUTPUT_PATH}/hosting/${NEXT_BASE_PATH}/app/api/static`).toString(),
readFileSync(
join(NEXT_OUTPUT_PATH, "hosting", NEXT_BASE_PATH, "app", "api", "static"),
).toString(),
);
const apiStaticResponse = await fetch(`${NEXTJS_HOST}/app/api/static`);

const jsonResponse = await apiStaticResponse.json();

Check warning on line 242 in scripts/webframeworks-deploy-tests/tests.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

expect(apiStaticResponse.ok).to.be.true;
expect(apiStaticResponse.headers.get("content-type")).to.eql("application/json");
expect(apiStaticResponse.headers.get("custom-header")).to.eql("custom-value");
expect(await apiStaticResponse.json()).to.eql(apiStaticJSON);

// TODO(leoortizz|jamesdaniels): Figure out why custom headers aren't working with emulators on Windows
if (!IS_WINDOWS) {
expect(apiStaticResponse.headers.get("content-type")).to.eql("application/json");
expect(apiStaticResponse.headers.get("custom-header")).to.eql("custom-value");
}

expect(jsonResponse).to.eql(apiStaticJSON);
});

it("should have working SSG", async () => {
Expand All @@ -247,7 +258,7 @@
const fooResponseText = await fooResponse.text();

const fooHtml = readFileSync(
`${NEXT_OUTPUT_PATH}/hosting/${NEXT_BASE_PATH}/app/ssg.html`,
join(NEXT_OUTPUT_PATH, "hosting", NEXT_BASE_PATH, "app", "ssg.html"),
).toString();
expect(fooHtml).to.eql(fooResponseText);
});
Expand Down Expand Up @@ -336,42 +347,50 @@
const EXPECTED_FILES = ["", "en", "fr"]
.flatMap((locale) => [
...(locale
? [
`/${NEXT_BASE_PATH}/_next/data/${buildId}/${locale}/pages/fallback/1.json`,
`/${NEXT_BASE_PATH}/_next/data/${buildId}/${locale}/pages/fallback/2.json`,
]
? [1, 2].map((num) =>
join(
NEXT_BASE_PATH,
"_next",
"data",
buildId,
locale,
"pages",
"fallback",
`${num}.json`,
),
)
: [
`/${NEXT_BASE_PATH}/_next/data/${buildId}/pages/ssg.json`,
`/${NEXT_BASE_PATH}/_next/static/${buildId}/_buildManifest.js`,
`/${NEXT_BASE_PATH}/_next/static/${buildId}/_ssgManifest.js`,
`/${NEXT_BASE_PATH}/app/api/static`,
`/${NEXT_BASE_PATH}/app/image.html`,
`/${NEXT_BASE_PATH}/app/ssg.html`,
`/${NEXT_BASE_PATH}/404.html`,
join(NEXT_BASE_PATH, "_next", "data", buildId, "pages", "ssg.json"),
join(NEXT_BASE_PATH, "_next", "static", buildId, "_buildManifest.js"),
join(NEXT_BASE_PATH, "_next", "static", buildId, "_ssgManifest.js"),
join(NEXT_BASE_PATH, "app", "api", "static"),
join(NEXT_BASE_PATH, "app", "image.html"),
join(NEXT_BASE_PATH, "app", "ssg.html"),
join(NEXT_BASE_PATH, "404.html"),
]),
`/${I18N_BASE}/${locale}/${NEXT_BASE_PATH}/pages/fallback/1.html`,
`/${I18N_BASE}/${locale}/${NEXT_BASE_PATH}/pages/fallback/2.html`,
`/${I18N_BASE}/${locale}/${NEXT_BASE_PATH}/pages/ssg.html`,
join(I18N_BASE, locale, NEXT_BASE_PATH, "pages", "fallback", "1.html"),
join(I18N_BASE, locale, NEXT_BASE_PATH, "pages", "fallback", "2.html"),
join(I18N_BASE, locale, NEXT_BASE_PATH, "pages", "ssg.html"),
// TODO(jamesdaniels) figure out why 404 isn't being translated
// `/${I18N_BASE}/${locale}/${NEXT_BASE_PATH}/404.html`,
`/${I18N_BASE}/${locale}/${NEXT_BASE_PATH}/500.html`,
`/${I18N_BASE}/${locale}/${NEXT_BASE_PATH}/index.html`,
join(I18N_BASE, locale, NEXT_BASE_PATH, "500.html"),
join(I18N_BASE, locale, NEXT_BASE_PATH, "index.html"),
])
.map(normalize)
.map((it) => (it.startsWith("/") ? it.substring(1) : it));

const EXPECTED_PATTERNS = [
`${NEXT_BASE_PATH}\/_next\/static\/chunks\/[^-]+-[^\.]+\.js`,
`${NEXT_BASE_PATH}\/_next\/static\/chunks\/app\/layout-[^\.]+\.js`,
`${NEXT_BASE_PATH}\/_next\/static\/chunks\/main-[^\.]+\.js`,
`${NEXT_BASE_PATH}\/_next\/static\/chunks\/main-app-[^\.]+\.js`,
`${NEXT_BASE_PATH}\/_next\/static\/chunks\/pages\/_app-[^\.]+\.js`,
`${NEXT_BASE_PATH}\/_next\/static\/chunks\/pages\/_error-[^\.]+\.js`,
`${NEXT_BASE_PATH}\/_next\/static\/chunks\/pages\/index-[^\.]+\.js`,
`${NEXT_BASE_PATH}\/_next\/static\/chunks\/polyfills-[^\.]+\.js`,
`${NEXT_BASE_PATH}\/_next\/static\/chunks\/webpack-[^\.]+\.js`,
`${NEXT_BASE_PATH}\/_next\/static\/css\/[^\.]+\.css`,
].map((it) => new RegExp(it));
[NEXT_BASE_PATH, "_next", "static", "chunks", `[^-]+-[^.]+.js`],
[NEXT_BASE_PATH, "_next", "static", "chunks", "app", `layout-[^.]+.js`],
[NEXT_BASE_PATH, "_next", "static", "chunks", `main-[^.]+.js`],
[NEXT_BASE_PATH, "_next", "static", "chunks", `main-app-[^.]+.js`],
[NEXT_BASE_PATH, "_next", "static", "chunks", "pages", `_app-[^.]+.js`],
[NEXT_BASE_PATH, "_next", "static", "chunks", "pages", `_error-[^.]+.js`],
[NEXT_BASE_PATH, "_next", "static", "chunks", "pages", `index-[^.]+.js`],
[NEXT_BASE_PATH, "_next", "static", "chunks", `polyfills-[^.]+.js`],
[NEXT_BASE_PATH, "_next", "static", "chunks", `webpack-[^.]+.js`],
[NEXT_BASE_PATH, "_next", "static", "css", `[^.]+.css`],
].map((it) => new RegExp(it.filter(Boolean).join(PATH_SEPARATOR)));

const files = await getFilesListFromDir(`${NEXT_OUTPUT_PATH}/hosting`);
const unmatchedFiles = files.filter(
Expand Down Expand Up @@ -440,25 +459,22 @@
it("should have the expected static files to be deployed", async () => {
const EXPECTED_FILES = ["", "en", "fr", "es"]
.flatMap((locale) => [
`/${I18N_BASE}/${locale}/${ANGULAR_BASE_PATH}/index.html`,
`/${I18N_BASE}/${locale}/${ANGULAR_BASE_PATH}/3rdpartylicenses.txt`,
`/${I18N_BASE}/${locale}/${ANGULAR_BASE_PATH}/favicon.ico`,
`/${I18N_BASE}/${locale}/${ANGULAR_BASE_PATH}/index.original.html`,
`/${I18N_BASE}/${locale}/${ANGULAR_BASE_PATH}/3rdpartylicenses.txt`,
join(I18N_BASE, locale, ANGULAR_BASE_PATH, "index.html"),
join(I18N_BASE, locale, ANGULAR_BASE_PATH, "3rdpartylicenses.txt"),
join(I18N_BASE, locale, ANGULAR_BASE_PATH, "favicon.ico"),
join(I18N_BASE, locale, ANGULAR_BASE_PATH, "index.original.html"),
join(I18N_BASE, locale, ANGULAR_BASE_PATH, "3rdpartylicenses.txt"),
])
.map(normalize)
.map((it) => (it.startsWith("/") ? it.substring(1) : it));
.map(normalize);

const EXPECTED_PATTERNS = ["", "en", "fr", "es"]
.flatMap((locale) => [
`/${I18N_BASE}/${locale}/${ANGULAR_BASE_PATH}/main\.[^\.]+\.js`,
`/${I18N_BASE}/${locale}/${ANGULAR_BASE_PATH}/polyfills\.[^\.]+\.js`,
`/${I18N_BASE}/${locale}/${ANGULAR_BASE_PATH}/runtime\.[^\.]+\.js`,
`/${I18N_BASE}/${locale}/${ANGULAR_BASE_PATH}/styles\.[^\.]+\.css`,
[I18N_BASE, locale, ANGULAR_BASE_PATH, `main\.[^\.]+\.js`],
[I18N_BASE, locale, ANGULAR_BASE_PATH, `polyfills\.[^\.]+\.js`],
[I18N_BASE, locale, ANGULAR_BASE_PATH, `runtime\.[^\.]+\.js`],
[I18N_BASE, locale, ANGULAR_BASE_PATH, `styles\.[^\.]+\.css`],
])
.map(normalize)
.map((it) => (it.startsWith("/") ? it.substring(1) : it))
.map((it) => new RegExp(it.replace("/", "\\/")));
.map((it) => new RegExp(it.filter(Boolean).join(PATH_SEPARATOR)));

const files = await getFilesListFromDir(`${ANGULAR_OUTPUT_PATH}/hosting`);
const unmatchedFiles = files.filter(
Expand Down
1 change: 0 additions & 1 deletion src/frameworks/next/utils.ts
Expand Up @@ -479,7 +479,6 @@ export async function getProductionDistDirFiles(
cwd: join(sourceDir, distDir),
nodir: true,
absolute: false,
realpath: IS_WINDOWS,
},
(err, matches) => {
if (err) reject(err);
Expand Down