Skip to content

Commit c48fe1d

Browse files
authored
Merge pull request #122 from laminas/revert-31-feature/xmllint
Revert "Use `XmlLint` against tool configurations (PHPUnit, PHPCS, Psalm)"
2 parents e5bc561 + edce8aa commit c48fe1d

File tree

31 files changed

+76
-93
lines changed

31 files changed

+76
-93
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
},
2121
"scripts": {
2222
"lint": "eslint src/ --ext .ts",
23-
"lint-fix": "eslint src/ --ext .ts --fix",
2423
"build": "tsc --build && webpack --mode=production"
2524
},
2625
"dependencies": {

src/action/github.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import * as core from '@actions/core';
21
import {Action} from '../action';
32
import {Output} from '../config/output';
43
import {Logger} from '../logging';
54

5+
/* eslint-disable-next-line import/no-commonjs, @typescript-eslint/no-var-requires */
6+
const core = require('@actions/core');
7+
68
export class Github implements Action {
79
publish(variable: string, output: Output): void {
810
core.setOutput(variable, JSON.stringify(output));

src/config/app.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export interface JobDefinition {
5454
composerDependencySet: ComposerDependencySet;
5555
ignorePhpPlatformRequirement: boolean;
5656
additionalComposerArguments: string[];
57-
beforeScript: string[];
5857
}
5958

6059
export interface Job {
@@ -151,8 +150,7 @@ function convertJobDefinitionFromFileToJobDefinition(
151150
job.extensions ?? config.phpExtensions,
152151
job.ini ?? config.phpIni,
153152
discoverIgnorePhpPlatformRequirementForJobByVersion(job, phpVersion, config),
154-
discoverAdditionalComposerArgumentsForCheck(job, config),
155-
job.before_script
153+
discoverAdditionalComposerArgumentsForCheck(job, config)
156154
);
157155
}
158156

@@ -163,8 +161,7 @@ function createJobDefinition(
163161
phpExtensions: string[],
164162
phpIniSettings: string[],
165163
ignorePlatformRequirements: boolean,
166-
additionalComposerArguments: string[],
167-
beforeScript: string[],
164+
additionalComposerArguments: string[]
168165
): JobDefinition {
169166
return {
170167
php : phpVersion,
@@ -173,8 +170,7 @@ function createJobDefinition(
173170
phpIni : phpIniSettings,
174171
composerDependencySet : composerDependencySet,
175172
ignorePhpPlatformRequirement : ignorePlatformRequirements,
176-
additionalComposerArguments : additionalComposerArguments,
177-
beforeScript : beforeScript,
173+
additionalComposerArguments : additionalComposerArguments
178174
};
179175
}
180176

@@ -287,15 +283,13 @@ function createJobsForTool(
287283
tool: Tool
288284
): JobFromTool[] {
289285
const jobs: JobFromTool[] = [];
290-
const beforeScript: string[] = tool.lintConfigCommand
291-
? tool.filesToCheck.map((file) => `${tool.lintConfigCommand} ${file}`)
292-
: [];
293286

294287
if (tool.executionType === ToolExecutionType.STATIC) {
295288
const lockedOrLatestDependencySet: ComposerDependencySet = config.lockedDependenciesExists
296289
? ComposerDependencySet.LOCKED
297290
: ComposerDependencySet.LATEST;
298291

292+
299293
return [
300294
createJob(
301295
tool.name,
@@ -306,8 +300,7 @@ function createJobsForTool(
306300
config.phpExtensions,
307301
config.phpIni,
308302
config.ignorePhpPlatformRequirements[config.minimumPhpVersion] ?? false,
309-
config.additionalComposerArguments,
310-
beforeScript,
303+
config.additionalComposerArguments
311304
),
312305
tool
313306
) as JobFromTool
@@ -325,8 +318,7 @@ function createJobsForTool(
325318
config.phpExtensions,
326319
config.phpIni,
327320
config.ignorePhpPlatformRequirements[config.minimumPhpVersion] ?? false,
328-
config.additionalComposerArguments,
329-
beforeScript,
321+
config.additionalComposerArguments
330322
),
331323
tool
332324
) as JobFromTool);
@@ -340,8 +332,7 @@ function createJobsForTool(
340332
config.phpExtensions,
341333
config.phpIni,
342334
config.ignorePhpPlatformRequirements[version] ?? false,
343-
config.additionalComposerArguments,
344-
beforeScript,
335+
config.additionalComposerArguments
345336
), tool) as JobFromTool,
346337

347338
createJob(tool.name, createJobDefinition(
@@ -351,8 +342,7 @@ function createJobsForTool(
351342
config.phpExtensions,
352343
config.phpIni,
353344
config.ignorePhpPlatformRequirements[version] ?? false,
354-
config.additionalComposerArguments,
355-
beforeScript,
345+
config.additionalComposerArguments
356346
), tool) as JobFromTool,
357347
));
358348
}
@@ -378,7 +368,6 @@ function createNoOpCheck(config: Config): Job {
378368
phpIni : [],
379369
ignorePhpPlatformRequirement : config.ignorePhpPlatformRequirements[config.stablePhpVersion] ?? false,
380370
additionalComposerArguments : config.additionalComposerArguments,
381-
beforeScript : [],
382371
}
383372
};
384373
}

src/config/input.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ export interface JobDefinitionFromFile {
7777
ignore_php_platform_requirement?: boolean;
7878
additional_composer_arguments: string[];
7979
command: string;
80-
before_script: string[];
8180
}
8281

8382
export type AnyComposerDependencySet = typeof WILDCARD_ALIAS;

src/config/output.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ export interface JobDefinitionForMatrix
1010
dependencies: ComposerDependencySet,
1111
ignore_platform_reqs_8: boolean, // eslint-disable-line camelcase
1212
ignore_php_platform_requirement: boolean, // eslint-disable-line camelcase
13-
additional_composer_arguments: Array<string>, // eslint-disable-line camelcase
14-
before_script: Array<string>, // eslint-disable-line camelcase
13+
additional_composer_arguments: Array<string> // eslint-disable-line camelcase
1514
}
1615

1716
export interface JobForMatrix {
@@ -48,9 +47,7 @@ export function createJobForMatrixFromJob(job: Job): JobForMatrix {
4847
/* eslint-disable-next-line camelcase */
4948
ignore_php_platform_requirement : job.job.ignorePhpPlatformRequirement,
5049
/* eslint-disable-next-line camelcase */
51-
additional_composer_arguments : job.job.additionalComposerArguments,
52-
/* eslint-disable-next-line camelcase */
53-
before_script : job.job.beforeScript,
50+
additional_composer_arguments : job.job.additionalComposerArguments
5451
}
5552
};
5653
}

src/tools.ts

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ export type Tool = {
2727
toolType: ToolType,
2828
name: string;
2929
command: string;
30-
filesToCheck: PathLike[],
31-
lintConfigCommand?: string,
30+
filesToCheck: PathLike[]
3231
}
3332

3433
function detectInfectionCommand(): string {
@@ -48,87 +47,85 @@ export default function createTools(config: Config): Array<Tool> {
4847
name : 'Documentation Linting',
4948
command : 'markdownlint doc/book/**/*.md',
5049
filesToCheck : [ 'doc/book/' ],
51-
toolType : ToolType.LINTER,
50+
toolType : ToolType.LINTER
5251
},
5352
{
5453
executionType : ToolExecutionType.STATIC,
5554
name : 'Documentation Linting',
5655
command : 'markdownlint docs/book/**/*.md',
5756
filesToCheck : [ 'docs/book/' ],
58-
toolType : ToolType.LINTER,
57+
toolType : ToolType.LINTER
5958
},
6059
{
6160
executionType : ToolExecutionType.STATIC,
6261
name : 'MkDocs Linting',
6362
command : 'yamllint -d relaxed --no-warnings mkdocs.yml',
6463
filesToCheck : [ 'mkdocs.yml' ],
65-
toolType : ToolType.LINTER,
64+
toolType : ToolType.LINTER
6665
},
6766
{
68-
executionType : ToolExecutionType.MATRIX,
69-
name : 'PHPUnit',
70-
command : './vendor/bin/phpunit',
71-
filesToCheck : [ 'phpunit.xml.dist', 'phpunit.xml' ],
72-
toolType : ToolType.CODE_CHECK,
73-
lintConfigCommand : 'xmllint --schema vendor/phpunit/phpunit/phpunit.xsd',
67+
executionType : ToolExecutionType.MATRIX,
68+
name : 'PHPUnit',
69+
command : './vendor/bin/phpunit',
70+
filesToCheck : [ 'phpunit.xml.dist', 'phpunit.xml' ],
71+
toolType : ToolType.CODE_CHECK
7472
},
7573
{
7674
executionType : ToolExecutionType.STATIC,
7775
name : 'Infection',
7876
command : detectInfectionCommand(),
7977
filesToCheck : [ 'infection.json', 'infection.json.dist' ],
80-
toolType : ToolType.CODE_CHECK,
78+
toolType : ToolType.CODE_CHECK
8179
},
8280
{
83-
executionType : ToolExecutionType.STATIC,
84-
name : 'PHPCodeSniffer',
85-
command : './vendor/bin/phpcs -q --report=checkstyle | cs2pr',
86-
filesToCheck : [ 'phpcs.xml', 'phpcs.xml.dist' ],
87-
toolType : ToolType.CODE_CHECK,
88-
lintConfigCommand : 'xmllint --schema vendor/squizlabs/php_codesniffer/phpcs.xsd',
81+
executionType : ToolExecutionType.STATIC,
82+
name : 'PHPCodeSniffer',
83+
command : './vendor/bin/phpcs -q --report=checkstyle | cs2pr',
84+
filesToCheck : [ 'phpcs.xml', 'phpcs.xml.dist' ],
85+
toolType : ToolType.CODE_CHECK
8986
},
9087
{
91-
executionType : ToolExecutionType.STATIC,
92-
name : 'Psalm',
93-
command : './vendor/bin/psalm --shepherd --stats --output-format=github --no-cache',
94-
filesToCheck : [ 'psalm.xml.dist', 'psalm.xml' ],
95-
toolType : ToolType.CODE_CHECK,
96-
lintConfigCommand : 'xmllint --schema vendor/vimeo/psalm/config.xsd',
88+
executionType : ToolExecutionType.STATIC,
89+
name : 'Psalm',
90+
command : './vendor/bin/psalm --shepherd --stats --output-format=github --no-cache',
91+
filesToCheck : [ 'psalm.xml.dist', 'psalm.xml' ],
92+
toolType : ToolType.CODE_CHECK
9793
},
9894
{
9995
executionType : ToolExecutionType.STATIC,
10096
name : 'Composer Require Checker',
10197
command : './vendor/bin/composer-require-checker check --config-file=composer-require-checker.json -n -v composer.json',
10298
filesToCheck : [ 'composer-require-checker.json' ],
103-
toolType : ToolType.CODE_CHECK,
99+
toolType : ToolType.CODE_CHECK
104100
},
105101
{
106102
executionType : ToolExecutionType.STATIC,
107103
name : 'PHPBench',
108104
command : './vendor/bin/phpbench run --revs=2 --iterations=2 --report=aggregate',
109105
filesToCheck : [ 'phpbench.json' ],
110-
toolType : ToolType.CODE_CHECK,
106+
toolType : ToolType.CODE_CHECK
111107
},
112108
{
113109
executionType : ToolExecutionType.STATIC,
114110
name : 'Codeception',
115111
command : './vendor/bin/codecept run',
116112
filesToCheck : [ 'codeception.yml.dist', 'codeception.yml' ],
117-
toolType : ToolType.CODE_CHECK,
113+
toolType : ToolType.CODE_CHECK
118114
}
119115
]
120116
// Remove all tools which do not need to run
121117
.filter((tool) =>
122118
(config.docLinting && tool.toolType === ToolType.LINTER)
123119
|| (config.codeChecks && tool.toolType === ToolType.CODE_CHECK))
124120
// Remove all tools which are not used by the project
125-
.map((tool) => removeNonExistentFilesToCheck(tool))
126-
.filter((tool) => tool.filesToCheck.length > 0);
121+
.filter((tool) => doesAnyFileExist(tool.filesToCheck));
127122
}
128123

129-
export function removeNonExistentFilesToCheck(tool: Tool): Tool {
130-
return {
131-
...tool,
132-
filesToCheck : tool.filesToCheck.filter((file) => fs.existsSync(file))
133-
};
124+
export function doesAnyFileExist(files: PathLike[]) {
125+
if (files.length === 0) {
126+
return true;
127+
}
128+
129+
return files
130+
.some((file) => fs.existsSync(file));
134131
}

tests/code-check-codeception-dist/matrix.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"include": [
33
{
44
"name": "Codeception [7.4, latest]",
5-
"job": "{\"command\":\"./vendor/bin/codecept run\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}",
5+
"job": "{\"command\":\"./vendor/bin/codecept run\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
66
"operatingSystem": "ubuntu-latest",
77
"action": "laminas/laminas-continuous-integration-action@v1"
88
}

tests/code-check-codeception-nodist/matrix.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"include": [
33
{
44
"name": "Codeception [7.4, latest]",
5-
"job": "{\"command\":\"./vendor/bin/codecept run\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}",
5+
"job": "{\"command\":\"./vendor/bin/codecept run\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
66
"operatingSystem": "ubuntu-latest",
77
"action": "laminas/laminas-continuous-integration-action@v1"
88
}

tests/code-check-composer-require-checker/matrix.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"include": [
33
{
44
"name": "Composer Require Checker [7.4, latest]",
5-
"job": "{\"command\":\"./vendor/bin/composer-require-checker check --config-file=composer-require-checker.json -n -v composer.json\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}",
5+
"job": "{\"command\":\"./vendor/bin/composer-require-checker check --config-file=composer-require-checker.json -n -v composer.json\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
66
"operatingSystem": "ubuntu-latest",
77
"action": "laminas/laminas-continuous-integration-action@v1"
88
}

tests/code-check-deprecated-exclusion-via-config/matrix.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"include": [
33
{
44
"name": "PHPUnit [7.4, lowest]",
5-
"job": "{\"command\":\"./vendor/bin/phpunit\",\"php\":\"7.4\",\"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\"]}",
5+
"job": "{\"command\":\"./vendor/bin/phpunit\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"lowest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
66
"operatingSystem": "ubuntu-latest",
77
"action": "laminas/laminas-continuous-integration-action@v1"
88
}

0 commit comments

Comments
 (0)