Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ npminstall-log.txt
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.npmrc

# Dependency change files generated from npmx aka rush
package-deps.json
Expand Down
3 changes: 0 additions & 3 deletions .npmrc

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[handlebars]": {
"editor.formatOnSave": false
},
Expand Down
942 changes: 0 additions & 942 deletions .yarn/releases/yarn-4.12.0.cjs

This file was deleted.

1,000 changes: 1,000 additions & 0 deletions .yarn/releases/yarn-4.18.0.cjs

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Yarn will delete the comments on automatic file updates.
# Please bring them back!

# Scripts are disabled for all packages.
# To enable, add the package to dependenciesMeta in package.json.
enableScripts: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.12.0.cjs
# Only install packages >= 7 days old to match internal quarantine policy.
npmMinimalAgeGate: 7d

# Packages listed here must:
# 1. Be on the quarantine-exempt list for the internal feed
# 2. Only depend on < 7d old versions of other quarantine-exempt packages
npmPreapprovedPackages:
- '@microsoft/esrp-npm-release'
- beachball
- p-graph

yarnPath: .yarn/releases/yarn-4.18.0.cjs
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"babel-plugin-module-resolver": "5.0.3",
"babel-plugin-react-compiler": "1.0.0",
"babel-plugin-tester": "10.1.0",
"beachball": "3.0.0-alpha.7",
"beachball": "3.0.0-alpha.9",
"chalk": "4.1.0",
"chrome-remote-interface": "0.28.2",
"ci-info": "3.9.0",
Expand Down Expand Up @@ -351,6 +351,14 @@
"typings",
"starter-templates"
],
"dependenciesMeta": {
"cypress": {
"built": true
},
"puppeteer": {
"built": true
}
},
"resolutions": {
"@nx/devkit/minimatch": "^9.0.7",
"@nx/jest/minimatch": "^9.0.7",
Expand Down Expand Up @@ -382,5 +390,5 @@
"nx": {
"includedScripts": []
},
"packageManager": "yarn@4.12.0"
"packageManager": "yarn@4.18.0"
}
2 changes: 1 addition & 1 deletion scripts/update-release-notes/src/pullRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async function getMatchingRecentPullRequest(entry: ChangelogEntry): Promise<IPul
}

try {
if (author) {
if (author && authorEmail) {
// Get this author's recent PRs and look for one or more with a matching commit message and email
possiblePrs = (await getRecentPrsByAuthor(author, authorEmail)).filter(pr =>
(pr.commits ?? []).some(commit => commit.message === message && commit.authorEmail === authorEmail),
Expand Down
5 changes: 5 additions & 0 deletions tools/react-integration-tester/src/__tests__/cli.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ describe('rit CLI e2e', () => {
"tslib": "^2.8.0",
"typescript": "5.7.3",
},
"dependenciesMeta": Object {
"cypress": Object {
"built": true,
},
},
"license": "UNLICENSED",
"name": "@rit/react-18-root",
"private": true,
Expand Down
17 changes: 15 additions & 2 deletions tools/react-integration-tester/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { execSync } from 'node:child_process';

import * as ejs from 'ejs';

import type { Args, ReactVersion, PackageJson, TsConfig } from './shared';
import type { Args, ReactVersion, PackageJson as BasePackageJson, TsConfig } from './shared';
import {
runCmd,
readCommandsFromPreparedProject,
Expand All @@ -16,6 +16,10 @@ import {
} from './shared';
import { type Logger } from './logger';

type PackageJson = BasePackageJson & {
dependenciesMeta?: Record<string, { built?: boolean }>;
};

function findGitRoot(cwd: string) {
const output = execSync('git rev-parse --show-toplevel', { cwd });

Expand Down Expand Up @@ -167,11 +171,20 @@ function upsertReactRootPackageJson(params: {
const prevDeps = existingPkg?.dependencies ?? basePkg.dependencies ?? {};
const mergedDeps = { ...prevDeps, ...dependencies };
const depsChanged = JSON.stringify(prevDeps) !== JSON.stringify(mergedDeps) || !existsSync(reactRootPkgPath);
const dependenciesMeta = {
...existingPkg?.dependenciesMeta,
cypress: {
...existingPkg?.dependenciesMeta?.['cypress'],
built: true,
},
};
const dependenciesMetaChanged = JSON.stringify(existingPkg?.dependenciesMeta) !== JSON.stringify(dependenciesMeta);

if (depsChanged) {
if (depsChanged || dependenciesMetaChanged) {
const nextPkg: PackageJson = {
...(existingPkg ?? basePkg),
dependencies: mergedDeps,
dependenciesMeta,
};
writeJsonFile(reactRootPkgPath, nextPkg);
logger?.verbose?.(
Expand Down
64 changes: 62 additions & 2 deletions tools/workspace-plugin/src/plugins/workspace-plugin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
import { CreateNodesContext, CreateNodesResultV2, ProjectConfiguration, serializeJson } from '@nx/devkit';
import {
CreateNodesContext,
CreateNodesResultV2,
PostTasksExecutionContext,
ProjectConfiguration,
TaskResult,
serializeJson,
} from '@nx/devkit';

import { TempFs } from './testing-utils/index';
import { WorkspacePluginOptions, createNodesV2 } from './workspace-plugin';
import { WorkspacePluginOptions, createNodesV2, postTasksExecution } from './workspace-plugin';
import { PackageJson } from '../types';

const createTaskResult = (id: string, status: TaskResult['status']): TaskResult => ({
task: { id } as TaskResult['task'],
status,
code: status === 'failure' ? 1 : 0,
});

const postTasksExecutionContext: PostTasksExecutionContext = {
id: 'test-run',
workspaceRoot: '/test',
nxJsonConfiguration: {},
argv: [],
startTime: 0,
endTime: 1,
taskResults: {
'successful-project:build': createTaskResult('successful-project:build', 'success'),
'failed-project:type-check': createTaskResult('failed-project:type-check', 'failure'),
},
};

describe(`workspace-plugin`, () => {
const [, createNodesFunction] = createNodesV2;
const originalEnv = process.env;
let context: CreateNodesContext;
let tempFs: TempFs;
let cwd: string;
Expand All @@ -19,6 +46,9 @@ describe(`workspace-plugin`, () => {
tempFs = new TempFs('test');
cwd = process.cwd();
process.chdir(tempFs.tempDir);
process.env = { ...originalEnv };
delete process.env.GITHUB_ACTIONS;
delete process.env.TF_BUILD;

context = {
nxJsonConfiguration: {
Expand All @@ -34,11 +64,41 @@ describe(`workspace-plugin`, () => {
});

afterEach(() => {
process.env = originalEnv;
jest.restoreAllMocks();
jest.resetModules();
tempFs.cleanup();
process.chdir(cwd);
});

it('should report failed tasks as GitHub Actions errors', async () => {
process.env.GITHUB_ACTIONS = 'true';
const consoleLog = jest.spyOn(console, 'log').mockImplementation();

await postTasksExecution(undefined, postTasksExecutionContext);

expect(consoleLog).toHaveBeenCalledTimes(1);
expect(consoleLog).toHaveBeenCalledWith('::error::Nx task failed: failed-project:type-check');
});

it('should report failed tasks as Azure Pipelines errors', async () => {
process.env.TF_BUILD = 'true';
const consoleLog = jest.spyOn(console, 'log').mockImplementation();

await postTasksExecution(undefined, postTasksExecutionContext);

expect(consoleLog).toHaveBeenCalledTimes(1);
expect(consoleLog).toHaveBeenCalledWith('##vso[task.logissue type=error]Nx task failed: failed-project:type-check');
});

it('should not report failed tasks outside CI', async () => {
const consoleLog = jest.spyOn(console, 'log').mockImplementation();

await postTasksExecution(undefined, postTasksExecutionContext);

expect(consoleLog).not.toHaveBeenCalled();
});

it('should create nodes with clean,format targets for any project', async () => {
await tempFs.createFiles({
'proj/project.json': serializeJson({}),
Expand Down
25 changes: 25 additions & 0 deletions tools/workspace-plugin/src/plugins/workspace-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type CreateNodesContextV2,
type CreateNodesResult,
type CreateNodesV2,
type PostTasksExecution,
type ProjectConfiguration,
type TargetConfiguration,
createNodesFromFiles,
Expand Down Expand Up @@ -44,6 +45,30 @@ interface TargetPluginOption {
include?: string[];
}

/**
* With `--nxBail`, if the task that failed is running around the same time as another task with
* very noisy logs, the task failure might get lost in the output. This hook will print a
* CI error message for each failed task, which will be visible in the CI provider's UI.
*/
export const postTasksExecution: PostTasksExecution<WorkspacePluginOptions> = (_options, context) => {
const errorPrefix =
process.env.GITHUB_ACTIONS === 'true'
? '::error::'
: process.env.TF_BUILD?.toLowerCase() === 'true'
? '##vso[task.logissue type=error]'
: undefined;

if (!errorPrefix) {
return;
}

for (const result of Object.values(context.taskResults)) {
if (result.status === 'failure') {
console.log(`${errorPrefix}Nx task failed: ${result.task.id}`);
}
}
};

export const createNodesV2: CreateNodesV2<WorkspacePluginOptions> = [
projectConfigGlob,
async (configFiles, options, context) => {
Expand Down
Loading
Loading