diff --git a/src/config/app.spec.ts b/src/config/app.spec.ts index 827ea14..6a07975 100644 --- a/src/config/app.spec.ts +++ b/src/config/app.spec.ts @@ -92,5 +92,92 @@ describe('config/app', () => { process.env = environment; }); + + it('should auto-enable backwardCompatibilityCheck for Laminas-related repositories', () => { + const originalEnv = process.env; + + // Mock GITHUB_REPOSITORY for a Laminas repo + process.env = { + GITHUB_REPOSITORY: 'laminas/laminas-diactoros' + }; + + const config = createConfig( + { codeChecks: true, docLinting: true }, + `${phpIniFromConfigurationPath}/composer.json`, + `${phpIniFromConfigurationPath}/composer.lock`, + `${phpIniFromConfigurationPath}/.laminas-ci.json` + ); + + expect(config.backwardCompatibilityCheck).toBe(true); + + // Mock GITHUB_REPOSITORY for a Mezzio repo + process.env = { + GITHUB_REPOSITORY: 'mezzio/mezzio-swoole' + }; + + const mezzioConfig = createConfig( + { codeChecks: true, docLinting: true }, + `${phpIniFromConfigurationPath}/composer.json`, + `${phpIniFromConfigurationPath}/composer.lock`, + `${phpIniFromConfigurationPath}/.laminas-ci.json` + ); + + expect(mezzioConfig.backwardCompatibilityCheck).toBe(true); + + // Mock GITHUB_REPOSITORY for a laminas-api-tools repo + process.env = { + GITHUB_REPOSITORY: 'laminas-api-tools/api-tools-skeleton' + }; + + const apiToolsConfig = createConfig( + { codeChecks: true, docLinting: true }, + `${phpIniFromConfigurationPath}/composer.json`, + `${phpIniFromConfigurationPath}/composer.lock`, + `${phpIniFromConfigurationPath}/.laminas-ci.json` + ); + + expect(apiToolsConfig.backwardCompatibilityCheck).toBe(true); + + process.env = originalEnv; + }); + + it('should NOT auto-enable backwardCompatibilityCheck for non-Laminas repositories', () => { + const originalEnv = process.env; + + process.env = { + GITHUB_REPOSITORY: 'some-user/some-repo' + }; + + const config = createConfig( + { codeChecks: true, docLinting: true }, + `${phpIniFromConfigurationPath}/composer.json`, + `${phpIniFromConfigurationPath}/composer.lock`, + `${phpIniFromConfigurationPath}/.laminas-ci.json` + ); + + expect(config.backwardCompatibilityCheck).toBe(false); + + process.env = originalEnv; + }); + + it('should respect explicit false for backwardCompatibilityCheck even in Laminas repositories', () => { + const originalEnv = process.env; + + process.env = { + GITHUB_REPOSITORY: 'laminas/laminas-diactoros' + }; + + const bcCheckDisabledPath = 'tests/bc-check-disabled'; + const config = createConfig( + { codeChecks: true, docLinting: true }, + `${bcCheckDisabledPath}/composer.json`, + `${bcCheckDisabledPath}/composer.lock`, + `${bcCheckDisabledPath}/.laminas-ci.json` + ); + + expect(config.backwardCompatibilityCheck).toBe(false); + + process.env = originalEnv; + }); }); }); diff --git a/src/config/app.ts b/src/config/app.ts index 9bd24e1..e569dbc 100644 --- a/src/config/app.ts +++ b/src/config/app.ts @@ -29,6 +29,11 @@ import { export const OPERATING_SYSTEM = 'ubuntu-latest'; export const ACTION = 'laminas/laminas-continuous-integration-action@v1'; +export const LAMINAS_RELATED_ORGANIZATIONS = [ + 'laminas', + 'mezzio', + 'laminas-api-tools', +]; export enum ComposerDependencySet { LOWEST = 'lowest', @@ -555,6 +560,9 @@ export default function createConfig( baseReference = null; } + const [ owner = ''] = (process.env.GITHUB_REPOSITORY ?? '').split('/', 2); + const isLaminasRelatedRepository = LAMINAS_RELATED_ORGANIZATIONS.includes(owner); + return { codeChecks : requirements.codeChecks, docLinting : requirements.docLinting, @@ -567,7 +575,7 @@ export default function createConfig( lockedDependenciesExists : fs.existsSync(composerLockJsonFileName), ignorePhpPlatformRequirements : configurationFromFile.ignore_php_platform_requirements ?? {}, additionalComposerArguments : [ ... new Set(configurationFromFile.additional_composer_arguments ?? []) ], - backwardCompatibilityCheck : configurationFromFile.backwardCompatibilityCheck ?? false, + backwardCompatibilityCheck : configurationFromFile.backwardCompatibilityCheck ?? isLaminasRelatedRepository, baseReference : baseReference, }; } diff --git a/tests/bc-check-disabled/.laminas-ci.json b/tests/bc-check-disabled/.laminas-ci.json new file mode 100644 index 0000000..f627bd0 --- /dev/null +++ b/tests/bc-check-disabled/.laminas-ci.json @@ -0,0 +1 @@ +{"backwardCompatibilityCheck": false} diff --git a/tests/bc-check-disabled/composer.json b/tests/bc-check-disabled/composer.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/tests/bc-check-disabled/composer.json @@ -0,0 +1 @@ +{}