Skip to content

Commit 86e5fdf

Browse files
committed
feat: allow toggling whether or not to ignore platform reqs on PHP 8
Since the beginning of development on this action, we've used the `--ignore-platform-reqs` flag when installing dependencies on PHP 8. However, with more packages in the Composer ecosystem supporting PHP 8, we can often safely remove that option and still successfully install packages. To enable that behavior in a BC way, this patch adds the ability to provide an `ignore_platform_reqs_8` flag via configuration. By default, the value is `true`, but the configuration allows you to disable it. Actions working in conjunction with this one can thus opt-in to the configuration option to determine whether or not to toggle that Composer option. Signed-off-by: Matthew Weier O'Phinney <[email protected]>
1 parent 2f5d4f3 commit 86e5fdf

File tree

5 files changed

+38
-23
lines changed

5 files changed

+38
-23
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ In each case, it MUST have the structure as noted above:
150150
"e.g. 'memory_limit=-1'"
151151
],
152152
"dependencies": "dependencies to test against; one of lowest, locked, latest",
153+
"ignore_platform_reqs_on_8": "(boolean; OPTIONAL) Whether or not to ignore platform requirements on PHP 8; defaults to true",
153154
"command": "command to run to perform the check"
154155
}
155156
```
@@ -177,7 +178,8 @@ The syntax for the `additional_checks` key is as follows:
177178
],
178179
"ini": [
179180
"(array of strings; OPTIONAL) specific php.ini settings to use for this check only"
180-
]
181+
],
182+
"ignore_platform_reqs_on_8": "(boolean; OPTIONAL) Whether or not to ignore platform reqs when installing dependencies on PHP 8.0; defaults to true"
181183
}
182184
}
183185
]

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ core.info(`Using php extensions: ${JSON.stringify(config.extensions)}`);
2020
core.info(`Providing php.ini settings: ${JSON.stringify(config.php_ini)}`);
2121
core.info(`Dependency sets found: ${JSON.stringify(config.dependencies)}`);
2222
core.info(`Additional checks found: ${JSON.stringify(config.additional_checks)}`);
23+
core.info(`Ignore platform reqs on version 8: ${config.ignore_platform_reqs_8 ? "Yes" : "No"}`);
2324

2425
let matrix = {include: createJobs(config)};
2526

src/command.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
import { CURRENT_STABLE } from './config.js';
22

33
export class Command {
4-
command = '';
5-
php = CURRENT_STABLE;
6-
extensions = [];
7-
ini = [];
8-
dependencies = 'locked';
4+
command = '';
5+
php = CURRENT_STABLE;
6+
extensions = [];
7+
ini = [];
8+
dependencies = 'locked';
9+
ignore_platform_reqs_8 = true;
910

1011
/**
1112
* @param {String} command
1213
* @param {String} php
1314
* @param {Array<String>} extensions
1415
* @param {Array<String>} ini
1516
* @param {String} dependencies
17+
* @param {Boolean} ignore_platform_reqs_8
1618
*/
17-
constructor(command, php, extensions, ini, dependencies) {
18-
this.command = command;
19-
this.php = php;
20-
this.extensions = extensions;
21-
this.ini = ini;
22-
this.dependencies = dependencies;
19+
constructor(command, php, extensions, ini, dependencies, ignore_platform_reqs_8) {
20+
this.command = command;
21+
this.php = php;
22+
this.extensions = extensions;
23+
this.ini = ini;
24+
this.dependencies = dependencies;
25+
this.ignore_platform_reqs_8 = ignore_platform_reqs_8;
2326
}
2427

2528
toJSON() {
@@ -29,6 +32,7 @@ export class Command {
2932
extensions: this.extensions,
3033
ini: this.ini,
3134
dependencies: this.dependencies,
35+
ignore_platform_reqs_8: this.ignore_platform_reqs_8,
3236
};
3337
}
3438
};

src/config.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,17 @@ function gatherVersions (composerJson) {
5656
}
5757

5858
class Config {
59-
code_checks = true;
60-
doc_linting = true;
61-
versions = [];
62-
stable_version = CURRENT_STABLE;
63-
extensions = [];
64-
php_ini = ['memory_limit=-1'];
65-
dependencies = ['lowest', 'latest'];
66-
checks = [];
67-
exclude = [];
68-
additional_checks = [];
59+
code_checks = true;
60+
doc_linting = true;
61+
versions = [];
62+
stable_version = CURRENT_STABLE;
63+
extensions = [];
64+
php_ini = ['memory_limit = -1'];
65+
dependencies = ['lowest', 'latest'];
66+
checks = [];
67+
exclude = [];
68+
additional_checks = [];
69+
ignore_platform_reqs_8 = true;
6970

7071
/**
7172
* @param {Requirements} requirements
@@ -105,6 +106,10 @@ class Config {
105106
if (configuration.additional_checks !== undefined && Array.isArray(configuration.additional_checks)) {
106107
this.additional_checks = configuration.additional_checks;
107108
}
109+
110+
if (configuration.ignore_platform_reqs_8 !== undefined && typeof configuration.ignore_platform_reqs_8 === 'boolean') {
111+
this.ignore_platform_reqs_8 = configuration.ignore_platform_reqs_8;
112+
}
108113
}
109114
}
110115

src/create-jobs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const createQaJobs = function (command, config) {
3333
config.stable_version,
3434
config.extensions,
3535
config.php_ini,
36-
'locked'
36+
'locked',
37+
config.ignore_platform_reqs_8,
3738
))
3839
)];
3940
};
@@ -53,6 +54,7 @@ const createPHPUnitJob = function (version, deps, config) {
5354
config.extensions,
5455
config.php_ini,
5556
deps,
57+
config.ignore_platform_reqs_8,
5658
)),
5759
);
5860
};
@@ -70,6 +72,7 @@ const createNoOpJob = function (config) {
7072
[],
7173
[],
7274
'locked',
75+
config.ignore_platform_reqs_8,
7376
)),
7477
)];
7578
};

0 commit comments

Comments
 (0)