diff --git a/.github/workflows/it-tests.yml b/.github/workflows/it-tests.yml index f8a6beb075..35b1eb92c4 100644 --- a/.github/workflows/it-tests.yml +++ b/.github/workflows/it-tests.yml @@ -51,7 +51,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - packageManager: [yarn, npm] + packageManager: [yarn, npm, yarn1] testEnvironment: [o3r-project-with-app] runs-on: ${{ matrix.os }} env: diff --git a/packages/@o3r/test-helpers/src/prepare-test-env.ts b/packages/@o3r/test-helpers/src/prepare-test-env.ts index 854c09d39f..e85c96e840 100644 --- a/packages/@o3r/test-helpers/src/prepare-test-env.ts +++ b/packages/@o3r/test-helpers/src/prepare-test-env.ts @@ -3,7 +3,7 @@ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statS import * as path from 'node:path'; import type { PackageJson } from 'type-fest'; import { createTestEnvironmentBlank } from './test-environments/create-test-environment-blank'; -import { createWithLock, getPackageManager, type Logger, packageManagerInstall, setPackagerManagerConfig, setupGit } from './utilities/index'; +import { createWithLock, getPackageManager, isYarn1, type Logger, packageManagerInstall, setPackagerManagerConfig, setupGit, YARN_1_LATEST_VERSION } from './utilities/index'; import { createTestEnvironmentOtterProjectWithApp } from './test-environments/create-test-environment-otter-project'; import { O3rCliError } from '@o3r/schematics'; @@ -15,8 +15,7 @@ export type PrepareTestEnvType = 'blank' | 'o3r-project-with-app'; /** * Retrieve the version used by yarn and setup at root level - * @param rootFolderPath: path to the folder where to take the configuration from - * @param rootFolderPath + * @param rootFolderPath path to the folder where to take the configuration from */ export function getYarnVersionFromRoot(rootFolderPath: string) { const o3rPackageJson: PackageJson & { generatorDependencies?: Record } = @@ -49,7 +48,7 @@ export async function prepareTestEnv(folderName: string, options?: PrepareTestEn const cacheFolderPath = path.resolve(globalFolderPath, 'cache'); JSON.parse(readFileSync(path.join(rootFolderPath, 'packages', '@o3r', 'core', 'package.json')).toString()); - const yarnVersion: string = yarnVersionParam || getYarnVersionFromRoot(rootFolderPath); + const yarnVersion: string = yarnVersionParam || (isYarn1() && YARN_1_LATEST_VERSION) || getYarnVersionFromRoot(rootFolderPath); const execAppOptions: ExecSyncOptions = { cwd: workspacePath, stdio: 'inherit', diff --git a/packages/@o3r/test-helpers/src/utilities/package-manager.ts b/packages/@o3r/test-helpers/src/utilities/package-manager.ts index 02a1d82c90..c2178803d4 100644 --- a/packages/@o3r/test-helpers/src/utilities/package-manager.ts +++ b/packages/@o3r/test-helpers/src/utilities/package-manager.ts @@ -49,6 +49,19 @@ export function getPackageManager() { 'yarn'; } + +/** + * latest version of yarn 1 + */ +export const YARN_1_LATEST_VERSION = '1.22.19'; + +/** + * is yarn 1 + */ +export function isYarn1() { + return process.env.ENFORCED_PACKAGE_MANAGER === 'yarn1'; +} + /** * Need to add additional dashes when running command like exec on npm * Convert `npm exec test --param` to `npm exec test -- --param`