Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 1.26.0 into 2.0.x #302

Merged
merged 19 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
afa73f6
feature: allow to exclude specific PHP versions and/or dependency sets
boesing Feb 8, 2023
d526f25
docs: describe how job exclusion works with the most recent changes
boesing Feb 8, 2023
5a7d64c
bugfix: use `job.tool.name` in case it is available
boesing Feb 8, 2023
226a4ff
qa: add debug logging on why a job might not be excluded
boesing Feb 8, 2023
5c3b655
docs: use `Composer` brand name where possible
boesing Feb 23, 2023
cfcdeb8
bugfix: we always have to check for the `job.name`
boesing May 5, 2024
9095f96
refactor: reduce the cognitive complexity of `app#isJobExcludedByConf…
boesing May 5, 2024
3c482c2
qa: add missing `test.env` files
boesing May 5, 2024
da9f358
qa: put `php` schema definition into dedicated `definition`
boesing May 5, 2024
5ff1be7
qa: add `before_script` section to the matrix output
boesing May 5, 2024
2fd95ad
qa: normalize PHP version for schema and also ensure that `stablePHP`…
boesing May 5, 2024
319a1b3
qa: target `stablePHP` to `installablePhpVersion` definition
boesing May 5, 2024
40699f0
bugfix: use `allOf` to merge `installablePhpVersion` enum values with…
boesing May 5, 2024
9f5c287
bugfix: use `anyOf` of `php` as just one of the `enum` values have to…
boesing May 5, 2024
7f557d2
bugfix: use `anyOf` to reference enum from `installablePhpVersion` an…
boesing May 5, 2024
4737d09
qa: use `@default` for `no-checks`
boesing May 5, 2024
64b9e8b
qa: remove `locked` dependency from expected matrix
boesing May 5, 2024
5c34e3c
Merge pull request #184 from boesing/feature/exclude-php-and-dependen…
boesing May 5, 2024
6222abf
Merge remote-tracking branch 'upstream/2.0.x' into 1.26.x-merge-up-in…
boesing May 5, 2024
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
35 changes: 31 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ The "job" element will have the following elements, but is not restricted to the
],
"dependencies": "(optional) dependencies to test against; one of lowest, locked, latest. default: locked",
"command": "(required) command to run to perform the check",
"ignore_platform_reqs_8": "(optional; deprecated) boolean; whether to add `--ignore-platform-req=php` to composer for PHP 8.0. default: true",
"ignore_php_platform_requirement": "(optional) boolean; whether to add `--ignore-platform-req=php` to composer for this job.",
"ignore_platform_reqs_8": "(optional; deprecated) boolean; whether to add `--ignore-platform-req=php` to Composer for PHP 8.0. default: true",
"ignore_php_platform_requirement": "(optional) boolean; whether to add `--ignore-platform-req=php` to Composer for this job.",
"additional_composer_arguments": [
"(optional) list of arguments to be passed to `composer install` and `composer update`"
]
Expand Down Expand Up @@ -200,18 +200,45 @@ The tool discovers checks first, then appends any `additional_checks` are concat

### Excluding specific jobs

The easiest way to exclude a single job is via the `name` parameter:
You can exclude specific jobs by using their names:

```json
{
"exclude": [
{
"name": "PHPUnit on PHP 8.0 with latest dependencies"
"name": "PHPUnit"
}
]
}
```

If you want to limit the exclusion to specific PHP versions, you can additionally add a PHP version:

```json
{
"exclude": [
{
"name": "PHPUnit",
"php": "8.0"
}
]
}
```

In case you only want to exclude jobs for specific Composer dependency sets, add `dependencies` to the `exclude` configuration:

```json
{
"exclude": [
{
"name": "PHPUnit",
"php": "8.0",
"dependencies": "latest"
}
]
}
```

## Testing matrix generation locally using Docker

To test matrix generation in a local checkout on your own machine, you can do the following:
Expand Down
77 changes: 60 additions & 17 deletions laminas-ci.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"exclude": [
{
"name": "Codeception [8.2, latest]"
},
{
"name": "Codeception",
"php": "8.2",
"dependencies": "latest"
}
],
"ignore_php_platform_requirements": {
Expand Down Expand Up @@ -243,6 +248,33 @@
}
],
"definitions": {
"installablePhpVersion": {
"type": "string",
"title": "Installable PHP versions from available from within the container.",
"enum": [
"8.0",
"8.1",
"8.2",
"8.3",
"@default"
]
},
"php": {
"title": "The PHP version",
"type": "string",
"anyOf": [
{
"$ref": "#/definitions/installablePhpVersion"
},
{
"enum": [
"*",
"@latest",
"@lowest"
]
}
]
},
"extensions": {
"type": "array",
"title": "A list of PHP extensions",
Expand Down Expand Up @@ -285,6 +317,11 @@
[
{
"name": "Codeception [8.2, latest]"
},
{
"name": "Codeception",
"php": "8.2",
"dependencies": "latest"
}
]
],
Expand All @@ -294,6 +331,11 @@
"examples": [
{
"name": "Codeception [8.2, latest]"
},
{
"name": "Codeception",
"php": "8.2",
"dependencies": "latest"
}
],
"required": [
Expand All @@ -306,8 +348,21 @@
"description": "The name of the job to be excluded. Must be an exact match.",
"minLength": 1,
"examples": [
"Codeception [8.2, latest]"
"Codeception [8.2, latest]",
"Codeception"
]
},
"php": {
"ref": "#/definitions/php",
"description": "The PHP version to to be excluded.",
"default": "*"
},
"dependencies": {
"type": "string",
"enum": ["latest", "lowest", "locked", "*"],
"title": "The composer dependencies to be excluded",
"description": "The composer dependencies to be excluded. If the wildcard `*` is passed, all dependencies are being excluded",
"default": "*"
}
},
"additionalProperties": false
Expand All @@ -331,13 +386,10 @@
}
},
"stablePHP": {
"type": "string",
"minLength": 1,
"$ref": "#/definitions/installablePhpVersion",
"title": "The PHP version to be used for stable checks",
"description": "This PHP version is used for all QA check jobs. The default depends on the `composer.json` of the project and usually reflects the minimum supported PHP version of that project.",
"examples": [
"8.0"
]
"default": "8.0"
},
"backwardCompatibilityCheck": {
"type": "boolean",
Expand All @@ -361,18 +413,9 @@
],
"properties": {
"php": {
"type": "string",
"title": "The php version",
"$ref": "#/definitions/php",
"description": "The PHP version to be used. If the wildcard `*` is passed, a list of checks is created containing *every* supported PHP version by the project and the matrix action.",
"enum": [
"8.0",
"8.1",
"8.2",
"8.3",
"*",
"@latest",
"@lowest"
]
"default": "*"
},
"dependencies": {
"type": "string",
Expand Down
89 changes: 85 additions & 4 deletions src/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,28 @@ import semver from 'semver';
import parseJsonFile from '../json';
import {isToolRunningContainerDefaultPhpVersion, Tool, ToolExecutionType} from '../tools';
import {Logger} from '../logging';
import {CURRENT_STABLE, INSTALLABLE_VERSIONS, InstallablePhpVersionType, isInstallableVersion} from './php';
import {
CONTAINER_DEFAULT_PHP_VERSION,
CURRENT_STABLE,
INSTALLABLE_VERSIONS,
InstallablePhpVersionType,
isInstallableVersion
} from './php';
import {ComposerJson} from './composer';
import {ConfigurationFromFile, isAdditionalChecksConfiguration, isAnyComposerDependencySet, isAnyPhpVersionType, isConfigurationContainingJobExclusions, isExplicitChecksConfiguration, isLatestPhpVersionType, isLowestPhpVersionType, JobDefinitionFromFile, JobFromFile, JobToExcludeFromFile} from './input';
import {
ConfigurationFromFile,
isAdditionalChecksConfiguration,
isAnyComposerDependencySet,
isAnyPhpVersionType,
isConfigurationContainingJobExclusions,
isExplicitChecksConfiguration,
isLatestPhpVersionType,
isLowestPhpVersionType,
JobDefinitionFromFile,
JobFromFile,
JobToExcludeFromFile,
WILDCARD_ALIAS
} from './input';

export const OPERATING_SYSTEM = 'ubuntu-latest';
export const ACTION = 'laminas/laminas-continuous-integration-action@v1';
Expand Down Expand Up @@ -242,12 +261,74 @@ function isJobExcludedByDeprecatedCommandName(job: Job, exclusions: JobToExclude
);
}

function isJobExcludedByName(job: Job, exclude: JobToExcludeFromFile): boolean {
if (job.name === exclude.name) {
return true;
}

if (isJobFromTool(job)) {
return job.tool.name === exclude.name;
}

return false;
}

function isJobExcludedByConfiguration(
job: Job,
exclude: JobToExcludeFromFile,
config: Config,
logger: Logger
): boolean {
if (!isJobExcludedByName(job, exclude)) {
return false;
}

const jobName = isJobFromTool(job) ? job.tool.name : job.name;

const phpVersionToExclude = exclude.php ?? WILDCARD_ALIAS;
const dependenciesToExclude = exclude.dependencies ?? WILDCARD_ALIAS;

if (!isAnyPhpVersionType(phpVersionToExclude)) {
const nonExcludedPhpVersionDebugMessage = `Job with name ${ jobName } is not matching exclusion rule`
+ ` with name ${ exclude.name } due to non-excluded php version.`;

if (isLowestPhpVersionType(phpVersionToExclude) && job.job.php !== config.minimumPhpVersion) {
logger.debug(nonExcludedPhpVersionDebugMessage);

return false;
}

if (isLatestPhpVersionType(phpVersionToExclude) && job.job.php !== config.latestPhpVersion) {
logger.debug(nonExcludedPhpVersionDebugMessage);

return false;
}

if (phpVersionToExclude !== job.job.php) {
logger.debug(nonExcludedPhpVersionDebugMessage);

return false;
}
}

if (!isAnyComposerDependencySet(dependenciesToExclude) && dependenciesToExclude !== job.job.composerDependencySet) {
logger.debug(
`Job with name ${ jobName } is not matching exclusion rule`
+ ` with name ${ exclude.name } due to non-excluded Composer dependencies.`
);

return false;
}

return true;
}

function isJobExcluded(job: Job, exclusions: JobToExcludeFromFile[], config: Config, logger: Logger): boolean {
if (exclusions.length === 0) {
return false;
}

if (exclusions.some((exclude) => job.name === exclude.name)) {
if (exclusions.some((exclude) => isJobExcludedByConfiguration(job, exclude, config, logger))) {
logger.info(`Job with name ${ job.name } is excluded due to application config.`);

return true;
Expand Down Expand Up @@ -385,7 +466,7 @@ function createNoOpCheck(config: Config): Job {
operatingSystem : OPERATING_SYSTEM,
action : ACTION,
job : {
php : config.stablePhpVersion,
php : CONTAINER_DEFAULT_PHP_VERSION,
phpExtensions : [],
command : '',
composerDependencySet : ComposerDependencySet.LOCKED,
Expand Down
4 changes: 3 additions & 1 deletion src/config/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import {ComposerDependencySet, IgnorePhpPlatformRequirements} from './app';

export interface JobToExcludeFromFile {
name: string;
php?: InstallablePhpVersionType,
dependencies?: ComposerDependencySet,
}

export interface ConfigurationFromFile {
extensions?: string[];
ini?: string[];
ignore_php_platform_requirements?: IgnorePhpPlatformRequirements;
stablePHP?: string;
stablePHP?: InstallablePhpVersionType;
additional_composer_arguments?: string[];
backwardCompatibilityCheck?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"exclude": [
{
"name": "PHPUnit",
"php": "8.1",
"dependencies": "latest"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"php": "~8.0.0 || ~8.1.0 || ~8.2.0"
}
}
34 changes: 34 additions & 0 deletions tests/configuration-exclude-php-dependency-combination/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"include": [
{
"name": "PHPUnit [8.0, lowest]",
"job": "{\"command\":\"./vendor/bin/phpunit\",\"php\":\"8.0\",\"extensions\":[],\"ini\":[],\"dependencies\":\"lowest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[\"xmllint --schema vendor/phpunit/phpunit/phpunit.xsd phpunit.xml.dist\"]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
},
{
"name": "PHPUnit [8.0, latest]",
"job": "{\"command\":\"./vendor/bin/phpunit\",\"php\":\"8.0\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[\"xmllint --schema vendor/phpunit/phpunit/phpunit.xsd phpunit.xml.dist\"]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
},
{
"name": "PHPUnit [8.1, lowest]",
"job": "{\"command\":\"./vendor/bin/phpunit\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[],\"dependencies\":\"lowest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[\"xmllint --schema vendor/phpunit/phpunit/phpunit.xsd phpunit.xml.dist\"]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
},
{
"name": "PHPUnit [8.2, lowest]",
"job": "{\"command\":\"./vendor/bin/phpunit\",\"php\":\"8.2\",\"extensions\":[],\"ini\":[],\"dependencies\":\"lowest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[\"xmllint --schema vendor/phpunit/phpunit/phpunit.xsd phpunit.xml.dist\"]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
},
{
"name": "PHPUnit [8.2, latest]",
"job": "{\"command\":\"./vendor/bin/phpunit\",\"php\":\"8.2\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[\"xmllint --schema vendor/phpunit/phpunit/phpunit.xsd phpunit.xml.dist\"]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" ?>
<dummy/>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"exclude": [
{
"name": "PHPUnit",
"php": "8.1"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"php": "~8.0.0 || ~8.1.0 || ~8.2.0"
}
}
Loading
Loading