Skip to content

Commit

Permalink
Implement laminas#194: remove latest composer deps from default gen…
Browse files Browse the repository at this point in the history
…erated pipelines

This change removes `latest` from default composer dependencies in the generated CI matrix.

The rationale is that `latest` dependencies tend to break our builds, and we usually run @renovate-bot
or @dependabot on our repositories, keeping both `composer.json` and `composer.lock` fairly updated.

Because of this kind of disciplined approach, we can assume that `latest` dependencies are already
regularly tested by refreshing `composer.lock` regularly, and further testing with explicit
`composer update` is considered risky, because it moves into unexplored land, breaking builds that
are otherwise quite stable.

We also don't want to break builds by contributors, or builds that upgrade perfectly safe to upgrade
dependencies, just because a specific `latest` upstream dependency broke, and we didn't really touch
it.

The final objective is that CI can break, but only in commits that change `composer.json` and `composer.lock`,
and those are handled every day by automation.

Therefore, the default testing approach will cover `lowest` and `locked` dependencies, which both move
much less than `latest`, and don't cause instability.
  • Loading branch information
Ocramius committed Mar 3, 2023
1 parent 753ed73 commit e777fea
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
10 changes: 5 additions & 5 deletions laminas-ci.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"exclude": [
{
"name": "Codeception [8.2, latest]"
"name": "Codeception [8.2, lowest]"
}
],
"ignore_php_platform_requirements": {
Expand Down Expand Up @@ -281,7 +281,7 @@
"examples": [
[
{
"name": "Codeception [8.2, latest]"
"name": "Codeception [8.2, lowest]"
}
]
],
Expand All @@ -290,7 +290,7 @@
"title": "The job description to be excluded",
"examples": [
{
"name": "Codeception [8.2, latest]"
"name": "Codeception [8.2, lowest]"
}
],
"required": [
Expand All @@ -303,7 +303,7 @@
"description": "The name of the job to be excluded. Must be an exact match.",
"minLength": 1,
"examples": [
"Codeception [8.2, latest]"
"Codeception [8.2, lowest]"
]
}
},
Expand Down Expand Up @@ -368,7 +368,7 @@
"type": "string",
"enum": ["latest", "lowest", "locked", "*"],
"title": "The composer dependencies to be used",
"description": "The composer dependencies to be used. If the wildcard `*` is passed, a list of checks is created containing each `lowest` and `latest` composer dependencies.",
"description": "The composer dependencies to be used. If the wildcard `*` is passed, a list of checks is created containing each `lowest` and `locked` composer dependencies.",
"default": "locked"
},
"command": {
Expand Down
20 changes: 4 additions & 16 deletions src/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const ACTION = 'laminas/laminas-continuous-integration-action@v1';
export enum ComposerDependencySet {
LOWEST = 'lowest',
LOCKED = 'locked',
LATEST = 'latest',
}

export function gatherVersions(composerJson: ComposerJson): InstallablePhpVersionType[] {
Expand Down Expand Up @@ -111,10 +110,10 @@ function discoverPhpVersionsForJob(job: JobDefinitionFromFile, config: Config):

function discoverComposerDependencySetsForJob(job: JobDefinitionFromFile, config: Config): ComposerDependencySet[] {
const dependencySetFromConfig = job.dependencies
?? (config.lockedDependenciesExists ? ComposerDependencySet.LOCKED : ComposerDependencySet.LATEST);
?? (config.lockedDependenciesExists ? ComposerDependencySet.LOCKED : ComposerDependencySet.LOWEST);

if (isAnyComposerDependencySet(dependencySetFromConfig)) {
return [ ComposerDependencySet.LOWEST, ComposerDependencySet.LATEST ];
return [ ComposerDependencySet.LOWEST ];
}

return [ dependencySetFromConfig ];
Expand Down Expand Up @@ -295,7 +294,7 @@ function createJobsForTool(
if (tool.executionType === ToolExecutionType.STATIC) {
const lockedOrLatestDependencySet: ComposerDependencySet = config.lockedDependenciesExists
? ComposerDependencySet.LOCKED
: ComposerDependencySet.LATEST;
: ComposerDependencySet.LOWEST;

return [
createJob(
Expand Down Expand Up @@ -343,18 +342,7 @@ function createJobsForTool(
config.ignorePhpPlatformRequirements[version] ?? false,
config.additionalComposerArguments,
beforeScript,
), tool) as JobFromTool,

createJob(tool.name, createJobDefinition(
tool.command,
version,
ComposerDependencySet.LATEST,
config.phpExtensions,
config.phpIni,
config.ignorePhpPlatformRequirements[version] ?? false,
config.additionalComposerArguments,
beforeScript,
), tool) as JobFromTool,
), tool) as JobFromTool
));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"checks": [
{
"name": "Whatever Check",
"job": {
"php": "8.1",
"dependencies": "latest",
"command": "test"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"php": "~7.4.0 || ~8.0.0"
}
}
10 changes: 10 additions & 0 deletions tests/configuration-explicit-job-latest-dependency-set/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": [
{
"name": "Whatever Check [8.1, latest]",
"job": "{\"command\":\"test\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
]
}

0 comments on commit e777fea

Please sign in to comment.