Skip to content

Commit

Permalink
fix: labels consistency across packages
Browse files Browse the repository at this point in the history
  • Loading branch information
todti committed Aug 9, 2024
1 parent d3dcdf2 commit 3668769
Show file tree
Hide file tree
Showing 21 changed files with 181 additions and 79 deletions.
7 changes: 6 additions & 1 deletion .yarn/sdks/eslint/bin/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
Expand All @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) {
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real eslint/bin/eslint.js your application uses
module.exports = absRequire(`eslint/bin/eslint.js`);
module.exports = wrapWithUserWrapper(absRequire(`eslint/bin/eslint.js`));
7 changes: 6 additions & 1 deletion .yarn/sdks/eslint/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
Expand All @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) {
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real eslint your application uses
module.exports = absRequire(`eslint`);
module.exports = wrapWithUserWrapper(absRequire(`eslint`));
7 changes: 6 additions & 1 deletion .yarn/sdks/eslint/lib/unsupported-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
Expand All @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) {
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real eslint/use-at-your-own-risk your application uses
module.exports = absRequire(`eslint/use-at-your-own-risk`);
module.exports = wrapWithUserWrapper(absRequire(`eslint/use-at-your-own-risk`));
7 changes: 6 additions & 1 deletion .yarn/sdks/prettier/bin/prettier.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
Expand All @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) {
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real prettier/bin/prettier.cjs your application uses
module.exports = absRequire(`prettier/bin/prettier.cjs`);
module.exports = wrapWithUserWrapper(absRequire(`prettier/bin/prettier.cjs`));
7 changes: 6 additions & 1 deletion .yarn/sdks/prettier/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
Expand All @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) {
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real prettier your application uses
module.exports = absRequire(`prettier`);
module.exports = wrapWithUserWrapper(absRequire(`prettier`));
7 changes: 6 additions & 1 deletion .yarn/sdks/typescript/bin/tsc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
Expand All @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) {
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real typescript/bin/tsc your application uses
module.exports = absRequire(`typescript/bin/tsc`);
module.exports = wrapWithUserWrapper(absRequire(`typescript/bin/tsc`));
7 changes: 6 additions & 1 deletion .yarn/sdks/typescript/bin/tsserver
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
Expand All @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) {
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real typescript/bin/tsserver your application uses
module.exports = absRequire(`typescript/bin/tsserver`);
module.exports = wrapWithUserWrapper(absRequire(`typescript/bin/tsserver`));
7 changes: 6 additions & 1 deletion .yarn/sdks/typescript/lib/tsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
Expand All @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) {
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real typescript/lib/tsc.js your application uses
module.exports = absRequire(`typescript/lib/tsc.js`);
module.exports = wrapWithUserWrapper(absRequire(`typescript/lib/tsc.js`));
11 changes: 10 additions & 1 deletion .yarn/sdks/typescript/lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
Expand All @@ -23,7 +24,15 @@ if (existsSync(absPnpApiPath)) {
}
}

const moduleWrapper = tsserver => {
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

const moduleWrapper = exports => {
return wrapWithUserWrapper(moduleWrapperFn(exports));
};

const moduleWrapperFn = tsserver => {
if (!process.versions.pnp) {
return tsserver;
}
Expand Down
11 changes: 10 additions & 1 deletion .yarn/sdks/typescript/lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
Expand All @@ -23,7 +24,15 @@ if (existsSync(absPnpApiPath)) {
}
}

const moduleWrapper = tsserver => {
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

const moduleWrapper = exports => {
return wrapWithUserWrapper(moduleWrapperFn(exports));
};

const moduleWrapperFn = tsserver => {
if (!process.versions.pnp) {
return tsserver;
}
Expand Down
7 changes: 6 additions & 1 deletion .yarn/sdks/typescript/lib/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
Expand All @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) {
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real typescript your application uses
module.exports = absRequire(`typescript`);
module.exports = wrapWithUserWrapper(absRequire(`typescript`));
16 changes: 15 additions & 1 deletion packages/allure-codeceptjs/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ import { event } from "codeceptjs";
import path from "node:path";
import { LabelName, Stage, Status, type StepResult } from "allure-js-commons";
import { type RuntimeMessage, extractMetadataFromString, getMessageAndTraceFromError } from "allure-js-commons/sdk";
import { ReporterRuntime, createDefaultWriter, getEnvironmentLabels, md5 } from "allure-js-commons/sdk/reporter";
import {
ReporterRuntime,
createDefaultWriter,
getEnvironmentLabels,
getHostLabel,
getPackageLabelFromPath,
getThreadLabel,
md5,
} from "allure-js-commons/sdk/reporter";
import type { ReporterConfig } from "allure-js-commons/sdk/reporter";
import { extractMeta } from "./helpers.js";
import type { CodeceptError, CodeceptHook, CodeceptStep, CodeceptTest } from "./model.js";
Expand Down Expand Up @@ -52,6 +60,9 @@ export class AllureCodeceptJsReporter {
const titleMetadata = extractMetadataFromString(test.title);
// @ts-ignore
const { labels } = extractMeta(test);
const packageLabel = getPackageLabelFromPath(fullName);
const hostLabel = getHostLabel();
const threadLabel = getThreadLabel();

this.currentTestUuid = this.allureRuntime.startTest(
{
Expand All @@ -67,6 +78,9 @@ export class AllureCodeceptJsReporter {
result.labels.push(...titleMetadata.labels);
result.labels.push({ name: LabelName.LANGUAGE, value: "javascript" });
result.labels.push({ name: LabelName.FRAMEWORK, value: "codeceptjs" });
result.labels.push(packageLabel);
result.labels.push(hostLabel);
result.labels.push(threadLabel);
result.labels.push(...getEnvironmentLabels());

if (test?.parent?.title) {
Expand Down
12 changes: 7 additions & 5 deletions packages/allure-cucumberjs/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
type TestStepResult,
TestStepResultStatus,
} from "@cucumber/messages";
import os from "node:os";
import { extname } from "node:path";
import process from "node:process";
import type { Label, Link, TestResult } from "allure-js-commons";
Expand All @@ -21,6 +20,8 @@ import {
createDefaultWriter,
createStepResult,
getEnvironmentLabels,
getHostLabel,
getPackageLabelFromPath,
getWorstStepResultStatus,
md5,
} from "allure-js-commons/sdk/reporter";
Expand Down Expand Up @@ -246,12 +247,11 @@ export default class AllureCucumberReporter extends Formatter {
fullName,
};

const hostLabel = getHostLabel();
const packageLabel = getPackageLabelFromPath(fullName);

result.labels!.push(...getEnvironmentLabels());
result.labels!.push(
{
name: LabelName.HOST,
value: os.hostname(),
},
{
name: LabelName.LANGUAGE,
value: "javascript",
Expand All @@ -260,6 +260,8 @@ export default class AllureCucumberReporter extends Formatter {
name: LabelName.FRAMEWORK,
value: "cucumberjs",
},
packageLabel,
hostLabel,
{
name: LabelName.THREAD,
value: data.workerId || ALLURE_THREAD_NAME || process.pid.toString(),
Expand Down
6 changes: 6 additions & 0 deletions packages/allure-cypress/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
ReporterRuntime,
createDefaultWriter,
getEnvironmentLabels,
getHostLabel,
getPackageLabelFromPath,
getSuiteLabels,
getThreadLabel,
parseTestPlan,
} from "allure-js-commons/sdk/reporter";
import type {
Expand Down Expand Up @@ -164,6 +167,9 @@ export class AllureCypress {
name: LabelName.FRAMEWORK,
value: "cypress",
},
getHostLabel(),
getPackageLabelFromPath(message.data.filename),
getThreadLabel(),
...suiteLabels,
...titleMetadata.labels,
...getEnvironmentLabels(),
Expand Down
12 changes: 10 additions & 2 deletions packages/allure-jasmine/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import * as allure from "allure-js-commons";
import { Stage, Status } from "allure-js-commons";
import { LabelName, Stage, Status, label } from "allure-js-commons";
import type { RuntimeMessage } from "allure-js-commons/sdk";
import { getMessageAndTraceFromError, getStatusFromError, isPromise } from "allure-js-commons/sdk";
import type { FixtureType, ReporterConfig } from "allure-js-commons/sdk/reporter";
import {
ReporterRuntime,
createDefaultWriter,
getEnvironmentLabels,
getHostLabel,
getPackageLabelFromPath,
getSuiteLabels,
getThreadLabel,
hasSkipLabel,
} from "allure-js-commons/sdk/reporter";
import { MessageTestRuntime, setGlobalTestRuntime } from "allure-js-commons/sdk/runtime";
Expand Down Expand Up @@ -132,7 +135,7 @@ export default class AllureJasmineReporter implements jasmine.CustomReporter {
}
}

specDone(spec: jasmine.SpecResult): void {
specDone(spec: jasmine.SpecResult & { filename: string }): void {
if (!this.currentAllureTestUuid) {
return;
}
Expand All @@ -144,6 +147,11 @@ export default class AllureJasmineReporter implements jasmine.CustomReporter {

result.labels.push(...suitesLabels);
result.labels.push(...getEnvironmentLabels());
result.labels.push({ name: LabelName.LANGUAGE, value: "javascript" });
result.labels.push({ name: LabelName.FRAMEWORK, value: "jasmine" });
result.labels.push(getHostLabel());
result.labels.push(getPackageLabelFromPath(spec.filename));
result.labels.push(getThreadLabel());

if (spec.status === "pending" || spec.status === "disabled" || spec.status === "excluded") {
result.status = Status.SKIPPED;
Expand Down
Loading

0 comments on commit 3668769

Please sign in to comment.