Skip to content

Commit

Permalink
[DO NOT MERGE] Debug windows e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum committed May 31, 2024
1 parent d14cc07 commit 6ce79ff
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 15 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,25 @@ concurrency:
cancel-in-progress: true

jobs:
core-tests:
uses: ./.github/workflows/call-core-tests.yml
do-not-merge-debug:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.18.0
uses: actions/setup-node@v4
with:
node-version: 18.18.0
cache: npm
- name: Install dependencies
run: npm ci
- name: Debug
run: npm run debug:packageManager
- name: Fail
run: exit 1

e2e-tests:
if: github.repository_owner == 'facebook'
uses: ./.github/workflows/call-e2e-canary-tests.yml
# core-tests:
# uses: ./.github/workflows/call-core-tests.yml

# e2e-tests:
# if: github.repository_owner == 'facebook'
# uses: ./.github/workflows/call-e2e-canary-tests.yml
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**/dist/**
**/build/**
**/npm/**
!scripts/npm/**
**/.output/**
**/.browser-profiles/**
**/__tests__/integration/fixtures/**
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"engineStrict": true,
"scripts": {
"debug:packageManager": "node scripts/shared/debugPackageManager",
"start": "cross-env NODE_ENV=development concurrently \"npm:collab\" \"npm run dev --prefix packages/lexical-playground\"",
"start:website": "npm run start --prefix packages/lexical-website -- --port 3001",
"start:playground": "npm run start-test-server",
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-playground/__tests__/utils/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {selectAll} from '../keyboardShortcuts/index.mjs';
function findAsset(pattern) {
const prefix = 'packages/lexical-playground/build';
const resolvedPattern = `${prefix}/assets/${pattern}`;
for (const fn of glob.sync(resolvedPattern)) {
for (const fn of glob.sync(resolvedPattern, {windowsPathsNoEscape: true})) {
return fn.slice(prefix.length);
}
throw new Error(`Missing asset at ${resolvedPattern}`);
Expand Down
8 changes: 6 additions & 2 deletions packages/lexical-website/plugins/package-docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ module.exports = async function (context, options) {
loadContent: () => {
fs.mkdirSync(options.targetDir, {recursive: true});
const oldTargets = new Set(
glob.sync(path.resolve(options.targetDir, '*.md')),
glob.sync(path.resolve(options.targetDir, '*.md'), {
windowsPathsNoEscape: true,
}),
);
for (const srcPath of glob.sync(`${options.baseDir}/*/README.md`)) {
for (const srcPath of glob.sync(`${options.baseDir}/*/README.md`, {
windowsPathsNoEscape: true,
})) {
const jsonPath = path.resolve(path.dirname(srcPath), 'package.json');
if (!fs.existsSync(jsonPath)) {
continue;
Expand Down
4 changes: 3 additions & 1 deletion scripts/__tests__/integration/prepare-release.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ describe('prepare-release tests', () => {
}
});
['examples', 'scripts/__tests__/integration/fixtures']
.flatMap((packagesDir) => glob.sync(`${packagesDir}/*/package.json`))
.flatMap((packagesDir) =>
glob.sync(`${packagesDir}/*/package.json`, {windowsPathsNoEscape: true}),
)
.forEach((exampleJsonPath) => describeExample(exampleJsonPath));
12 changes: 10 additions & 2 deletions scripts/__tests__/unit/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ describe('public package.json audits (`npm run update-packages` to fix most issu
});
}
it('has *.flow types', () => {
expect(glob.sync(pkg.resolve('flow', '*.flow'))).not.toEqual([]);
expect(
glob.sync(pkg.resolve('flow', '*.flow'), {
windowsPathsNoEscape: true,
}),
).not.toEqual([]);
});
it('uses the expected directory/npm naming convention', () => {
expect(npmName.replace(/^@/, '').replace('/', '-')).toBe(
Expand Down Expand Up @@ -118,7 +122,11 @@ describe('www public package audits (`npm run update-packages` to fix most issue
const wwwEntrypoint = `${npmToWwwName(npmName)}.js`;
describe(npmName, () => {
it('has *.flow types', () => {
expect(glob.sync(pkg.resolve('flow', '*.flow'))).not.toEqual([]);
expect(
glob.sync(pkg.resolve('flow', '*.flow'), {
windowsPathsNoEscape: true,
}),
).not.toEqual([]);
});
// Only worry about the entrypoint stub if it has a single module export
if (pkg.getExportedNpmModuleNames().every((name) => name === npmName)) {
Expand Down
4 changes: 3 additions & 1 deletion scripts/npm/prepare-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ function preparePackage(pkg) {
fs.removeSync(pkg.resolve('npm'));
fs.ensureDirSync(pkg.resolve('npm'));
fs.copySync(pkg.resolve('dist'), pkg.resolve('npm'));
const flowSources = glob.sync(pkg.resolve('flow', '*.flow'));
const flowSources = glob.sync(pkg.resolve('flow', '*.flow'), {
windowsPathsNoEscape: true,
});
if (flowSources.length === 0) {
console.error(
`Missing Flow type definitions for package ${pkg.getDirectoryName()}`,
Expand Down
5 changes: 4 additions & 1 deletion scripts/override-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ async function main() {
throw new Error('USAGE: node ./scripts/override-react --version=beta');
}
const packages = ['react', 'react-dom'];
['package.json', ...glob.sync('./packages/*/package.json')].forEach((fn) => {
[
'package.json',
...glob.sync('./packages/*/package.json', {windowsPathsNoEscape: true}),
].forEach((fn) => {
const json = fs.readJsonSync(fn);
const isRoot = fn === 'package.json';
let didUpdate = isRoot;
Expand Down
53 changes: 53 additions & 0 deletions scripts/shared/debugPackageManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict';

const glob = require('glob');
const path = require('node:path');

console.log('__dirname', __dirname);
console.log(
'path.dirname(path.dirname(__dirname))',
path.dirname(path.dirname(__dirname)),
);
console.log(
`\
path.resolve(
path.dirname(path.dirname(__dirname)),
'packages/*/package.json',
)`,
path.resolve(
path.dirname(path.dirname(__dirname)),
'packages/*/package.json',
),
);
console.log(
`\
path.join(
path.dirname(path.dirname(__dirname)),
'packages', '*', 'package.json',
)`,
path.join(
path.dirname(path.dirname(__dirname)),
'packages',
'*',
'package.json',
),
);

console.log(
glob
.sync(
path.join(
path.dirname(path.dirname(__dirname)),
'packages',
'*',
'package.json',
),
)
.join('\n'),
);
console.log('\n\n');
console.log(
[...require('./packagesManager').packagesManager.packagesByDirectoryName]
.map(([k, v]) => `${k} ${v.packageJsonPath}`)
.join('\n'),
);
1 change: 1 addition & 0 deletions scripts/shared/packagesManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,6 @@ exports.packagesManager = new PackagesManager(
path.dirname(path.dirname(__dirname)),
'packages/*/package.json',
),
{windowsPathsNoEscape: true},
),
);
1 change: 1 addition & 0 deletions scripts/update-tsconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ async function updateTsconfig({
testPaths.push([`${pkg.getNpmName()}/src`, [resolveRelative('src')]]);
for (const fn of glob.sync(
pkg.resolve('src', '__tests__', 'utils', '*.{ts,tsx,mjs,jsx}'),
{windowsPathsNoEscape: true},
)) {
testPaths.push([
`${pkg.getNpmName()}/src/__tests__/utils`,
Expand Down
2 changes: 1 addition & 1 deletion scripts/validate-tsc-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const diagnosticsHost = {
*/
function validateTscTypes() {
const dtsFilesPattern = './.ts-temp/packages/{lexical,lexical-*}/**/*.d.ts';
const dtsFiles = glob.sync(dtsFilesPattern);
const dtsFiles = glob.sync(dtsFilesPattern, {windowsPathsNoEscape: true});
if (dtsFiles.length === 0) {
console.error(
`Missing ${dtsFilesPattern}, \`npm run build-prod\` or \`npm run build-release\` first`,
Expand Down
4 changes: 3 additions & 1 deletion scripts/www/rewriteImports.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const transformFlowFileContents = require('./transformFlowFileContents');
// for each package so they can easily be copied to www.
async function rewriteImports() {
for (const pkg of packagesManager.getPackages()) {
for (const flowFile of glob.sync(pkg.resolve('flow', '*.flow'))) {
for (const flowFile of glob.sync(pkg.resolve('flow', '*.flow'), {
windowsPathsNoEscape: true,
})) {
const data = fs.readFileSync(flowFile, 'utf8');
const result = await transformFlowFileContents(data);
fs.writeFileSync(
Expand Down

0 comments on commit 6ce79ff

Please sign in to comment.