Skip to content

Commit 84fdcac

Browse files
author
Gary Lockett
authored
Merge pull request #124 from internalsystemerror/1.15.x
Re-release `xmllint` now usage of `before_script` is fixed
2 parents 082c130 + 983f372 commit 84fdcac

File tree

32 files changed

+296
-394
lines changed

32 files changed

+296
-394
lines changed

package-lock.json

Lines changed: 203 additions & 318 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

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

src/action/github.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1+
import * as core from '@actions/core';
12
import {Action} from '../action';
23
import {Output} from '../config/output';
34
import {Logger} from '../logging';
45

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

src/config/app.ts

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

5960
export interface Job {
@@ -150,7 +151,8 @@ function convertJobDefinitionFromFileToJobDefinition(
150151
job.extensions ?? config.phpExtensions,
151152
job.ini ?? config.phpIni,
152153
discoverIgnorePhpPlatformRequirementForJobByVersion(job, phpVersion, config),
153-
discoverAdditionalComposerArgumentsForCheck(job, config)
154+
discoverAdditionalComposerArgumentsForCheck(job, config),
155+
job.before_script
154156
);
155157
}
156158

@@ -161,7 +163,8 @@ function createJobDefinition(
161163
phpExtensions: string[],
162164
phpIniSettings: string[],
163165
ignorePlatformRequirements: boolean,
164-
additionalComposerArguments: string[]
166+
additionalComposerArguments: string[],
167+
beforeScript: string[],
165168
): JobDefinition {
166169
return {
167170
php : phpVersion,
@@ -170,7 +173,8 @@ function createJobDefinition(
170173
phpIni : phpIniSettings,
171174
composerDependencySet : composerDependencySet,
172175
ignorePhpPlatformRequirement : ignorePlatformRequirements,
173-
additionalComposerArguments : additionalComposerArguments
176+
additionalComposerArguments : additionalComposerArguments,
177+
beforeScript : beforeScript,
174178
};
175179
}
176180

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

287294
if (tool.executionType === ToolExecutionType.STATIC) {
288295
const lockedOrLatestDependencySet: ComposerDependencySet = config.lockedDependenciesExists
289296
? ComposerDependencySet.LOCKED
290297
: ComposerDependencySet.LATEST;
291298

292-
293299
return [
294300
createJob(
295301
tool.name,
@@ -300,7 +306,8 @@ function createJobsForTool(
300306
config.phpExtensions,
301307
config.phpIni,
302308
config.ignorePhpPlatformRequirements[config.minimumPhpVersion] ?? false,
303-
config.additionalComposerArguments
309+
config.additionalComposerArguments,
310+
beforeScript,
304311
),
305312
tool
306313
) as JobFromTool
@@ -318,7 +325,8 @@ function createJobsForTool(
318325
config.phpExtensions,
319326
config.phpIni,
320327
config.ignorePhpPlatformRequirements[config.minimumPhpVersion] ?? false,
321-
config.additionalComposerArguments
328+
config.additionalComposerArguments,
329+
beforeScript,
322330
),
323331
tool
324332
) as JobFromTool);
@@ -332,7 +340,8 @@ function createJobsForTool(
332340
config.phpExtensions,
333341
config.phpIni,
334342
config.ignorePhpPlatformRequirements[version] ?? false,
335-
config.additionalComposerArguments
343+
config.additionalComposerArguments,
344+
beforeScript,
336345
), tool) as JobFromTool,
337346

338347
createJob(tool.name, createJobDefinition(
@@ -342,7 +351,8 @@ function createJobsForTool(
342351
config.phpExtensions,
343352
config.phpIni,
344353
config.ignorePhpPlatformRequirements[version] ?? false,
345-
config.additionalComposerArguments
354+
config.additionalComposerArguments,
355+
beforeScript,
346356
), tool) as JobFromTool,
347357
));
348358
}
@@ -368,6 +378,7 @@ function createNoOpCheck(config: Config): Job {
368378
phpIni : [],
369379
ignorePhpPlatformRequirement : config.ignorePhpPlatformRequirements[config.stablePhpVersion] ?? false,
370380
additionalComposerArguments : config.additionalComposerArguments,
381+
beforeScript : [],
371382
}
372383
};
373384
}

src/config/input.ts

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

8283
export type AnyComposerDependencySet = typeof WILDCARD_ALIAS;

src/config/output.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ 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
13+
additional_composer_arguments: Array<string>, // eslint-disable-line camelcase
14+
before_script: Array<string>, // eslint-disable-line camelcase
1415
}
1516

1617
export interface JobForMatrix {
@@ -47,7 +48,9 @@ export function createJobForMatrixFromJob(job: Job): JobForMatrix {
4748
/* eslint-disable-next-line camelcase */
4849
ignore_php_platform_requirement : job.job.ignorePhpPlatformRequirement,
4950
/* eslint-disable-next-line camelcase */
50-
additional_composer_arguments : job.job.additionalComposerArguments
51+
additional_composer_arguments : job.job.additionalComposerArguments,
52+
/* eslint-disable-next-line camelcase */
53+
before_script : job.job.beforeScript,
5154
}
5255
};
5356
}

src/tools.ts

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

3334
function detectInfectionCommand(): string {
@@ -47,85 +48,87 @@ export default function createTools(config: Config): Array<Tool> {
4748
name : 'Documentation Linting',
4849
command : 'markdownlint doc/book/**/*.md',
4950
filesToCheck : [ 'doc/book/' ],
50-
toolType : ToolType.LINTER
51+
toolType : ToolType.LINTER,
5152
},
5253
{
5354
executionType : ToolExecutionType.STATIC,
5455
name : 'Documentation Linting',
5556
command : 'markdownlint docs/book/**/*.md',
5657
filesToCheck : [ 'docs/book/' ],
57-
toolType : ToolType.LINTER
58+
toolType : ToolType.LINTER,
5859
},
5960
{
6061
executionType : ToolExecutionType.STATIC,
6162
name : 'MkDocs Linting',
6263
command : 'yamllint -d relaxed --no-warnings mkdocs.yml',
6364
filesToCheck : [ 'mkdocs.yml' ],
64-
toolType : ToolType.LINTER
65+
toolType : ToolType.LINTER,
6566
},
6667
{
67-
executionType : ToolExecutionType.MATRIX,
68-
name : 'PHPUnit',
69-
command : './vendor/bin/phpunit',
70-
filesToCheck : [ 'phpunit.xml.dist', 'phpunit.xml' ],
71-
toolType : ToolType.CODE_CHECK
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',
7274
},
7375
{
7476
executionType : ToolExecutionType.STATIC,
7577
name : 'Infection',
7678
command : detectInfectionCommand(),
7779
filesToCheck : [ 'infection.json', 'infection.json.dist' ],
78-
toolType : ToolType.CODE_CHECK
80+
toolType : ToolType.CODE_CHECK,
7981
},
8082
{
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
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',
8689
},
8790
{
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
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',
9397
},
9498
{
9599
executionType : ToolExecutionType.STATIC,
96100
name : 'Composer Require Checker',
97101
command : './vendor/bin/composer-require-checker check --config-file=composer-require-checker.json -n -v composer.json',
98102
filesToCheck : [ 'composer-require-checker.json' ],
99-
toolType : ToolType.CODE_CHECK
103+
toolType : ToolType.CODE_CHECK,
100104
},
101105
{
102106
executionType : ToolExecutionType.STATIC,
103107
name : 'PHPBench',
104108
command : './vendor/bin/phpbench run --revs=2 --iterations=2 --report=aggregate',
105109
filesToCheck : [ 'phpbench.json' ],
106-
toolType : ToolType.CODE_CHECK
110+
toolType : ToolType.CODE_CHECK,
107111
},
108112
{
109113
executionType : ToolExecutionType.STATIC,
110114
name : 'Codeception',
111115
command : './vendor/bin/codecept run',
112116
filesToCheck : [ 'codeception.yml.dist', 'codeception.yml' ],
113-
toolType : ToolType.CODE_CHECK
117+
toolType : ToolType.CODE_CHECK,
114118
}
115119
]
116120
// Remove all tools which do not need to run
117121
.filter((tool) =>
118122
(config.docLinting && tool.toolType === ToolType.LINTER)
119123
|| (config.codeChecks && tool.toolType === ToolType.CODE_CHECK))
120124
// Remove all tools which are not used by the project
121-
.filter((tool) => doesAnyFileExist(tool.filesToCheck));
125+
.map((tool) => removeNonExistentFilesToCheck(tool))
126+
.filter((tool) => tool.filesToCheck.length > 0);
122127
}
123128

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));
129+
export function removeNonExistentFilesToCheck(tool: Tool): Tool {
130+
return {
131+
...tool,
132+
filesToCheck : tool.filesToCheck.filter((file) => fs.existsSync(file))
133+
};
131134
}

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\":[]}",
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\":[]}",
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\":[]}",
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\":[]}",
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\":[]}",
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\":[]}",
66
"operatingSystem": "ubuntu-latest",
77
"action": "laminas/laminas-continuous-integration-action@v1"
88
}

0 commit comments

Comments
 (0)