Skip to content

Commit

Permalink
feat(it-tests): test schematics with yarn 1
Browse files Browse the repository at this point in the history
  • Loading branch information
vscaiceanu-1a committed Feb 20, 2024
1 parent da3eaf7 commit 3e78e32
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/it-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 3 additions & 4 deletions packages/@o3r/test-helpers/src/prepare-test-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, type Logger, packageManagerInstall, setPackagerManagerConfig, setupGit, isYarn1, YARN_1_LATEST_VERSION } from './utilities/index';
import { createTestEnvironmentOtterProjectWithApp } from './test-environments/create-test-environment-otter-project';
import { O3rCliError } from '@o3r/schematics';

Expand All @@ -19,8 +19,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<string, string> } =
Expand Down Expand Up @@ -53,7 +52,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',
Expand Down
9 changes: 9 additions & 0 deletions packages/@o3r/test-helpers/src/utilities/package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ export function getPackageManager() {
'yarn';
}

export const YARN_1_LATEST_VERSION = '1.22.19';

/**
*
*/
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`
Expand Down

0 comments on commit 3e78e32

Please sign in to comment.