Skip to content
Closed
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
87 changes: 87 additions & 0 deletions src/config/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
});
10 changes: 9 additions & 1 deletion src/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
Comment on lines +32 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this information shouldn’t be included here, as the action is not only used in our packages but is intended to be used generally and independently.
Regardless of that, the API tools are no longer relevant.


export enum ComposerDependencySet {
LOWEST = 'lowest',
Expand Down Expand Up @@ -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,
Expand All @@ -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,
};
}
Expand Down
1 change: 1 addition & 0 deletions tests/bc-check-disabled/.laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"backwardCompatibilityCheck": false}
1 change: 1 addition & 0 deletions tests/bc-check-disabled/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading