Skip to content

Commit

Permalink
Merge pull request #122 from laminas/revert-31-feature/xmllint
Browse files Browse the repository at this point in the history
Revert "Use `XmlLint` against tool configurations (PHPUnit, PHPCS, Psalm)"
  • Loading branch information
Ocramius authored Aug 19, 2022
2 parents e5bc561 + edce8aa commit c48fe1d
Show file tree
Hide file tree
Showing 31 changed files with 76 additions and 93 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
},
"scripts": {
"lint": "eslint src/ --ext .ts",
"lint-fix": "eslint src/ --ext .ts --fix",
"build": "tsc --build && webpack --mode=production"
},
"dependencies": {
Expand Down
4 changes: 3 additions & 1 deletion src/action/github.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import * as core from '@actions/core';
import {Action} from '../action';
import {Output} from '../config/output';
import {Logger} from '../logging';

/* eslint-disable-next-line import/no-commonjs, @typescript-eslint/no-var-requires */
const core = require('@actions/core');

export class Github implements Action {
publish(variable: string, output: Output): void {
core.setOutput(variable, JSON.stringify(output));
Expand Down
27 changes: 8 additions & 19 deletions src/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export interface JobDefinition {
composerDependencySet: ComposerDependencySet;
ignorePhpPlatformRequirement: boolean;
additionalComposerArguments: string[];
beforeScript: string[];
}

export interface Job {
Expand Down Expand Up @@ -151,8 +150,7 @@ function convertJobDefinitionFromFileToJobDefinition(
job.extensions ?? config.phpExtensions,
job.ini ?? config.phpIni,
discoverIgnorePhpPlatformRequirementForJobByVersion(job, phpVersion, config),
discoverAdditionalComposerArgumentsForCheck(job, config),
job.before_script
discoverAdditionalComposerArgumentsForCheck(job, config)
);
}

Expand All @@ -163,8 +161,7 @@ function createJobDefinition(
phpExtensions: string[],
phpIniSettings: string[],
ignorePlatformRequirements: boolean,
additionalComposerArguments: string[],
beforeScript: string[],
additionalComposerArguments: string[]
): JobDefinition {
return {
php : phpVersion,
Expand All @@ -173,8 +170,7 @@ function createJobDefinition(
phpIni : phpIniSettings,
composerDependencySet : composerDependencySet,
ignorePhpPlatformRequirement : ignorePlatformRequirements,
additionalComposerArguments : additionalComposerArguments,
beforeScript : beforeScript,
additionalComposerArguments : additionalComposerArguments
};
}

Expand Down Expand Up @@ -287,15 +283,13 @@ function createJobsForTool(
tool: Tool
): JobFromTool[] {
const jobs: JobFromTool[] = [];
const beforeScript: string[] = tool.lintConfigCommand
? tool.filesToCheck.map((file) => `${tool.lintConfigCommand} ${file}`)
: [];

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


return [
createJob(
tool.name,
Expand All @@ -306,8 +300,7 @@ function createJobsForTool(
config.phpExtensions,
config.phpIni,
config.ignorePhpPlatformRequirements[config.minimumPhpVersion] ?? false,
config.additionalComposerArguments,
beforeScript,
config.additionalComposerArguments
),
tool
) as JobFromTool
Expand All @@ -325,8 +318,7 @@ function createJobsForTool(
config.phpExtensions,
config.phpIni,
config.ignorePhpPlatformRequirements[config.minimumPhpVersion] ?? false,
config.additionalComposerArguments,
beforeScript,
config.additionalComposerArguments
),
tool
) as JobFromTool);
Expand All @@ -340,8 +332,7 @@ function createJobsForTool(
config.phpExtensions,
config.phpIni,
config.ignorePhpPlatformRequirements[version] ?? false,
config.additionalComposerArguments,
beforeScript,
config.additionalComposerArguments
), tool) as JobFromTool,

createJob(tool.name, createJobDefinition(
Expand All @@ -351,8 +342,7 @@ function createJobsForTool(
config.phpExtensions,
config.phpIni,
config.ignorePhpPlatformRequirements[version] ?? false,
config.additionalComposerArguments,
beforeScript,
config.additionalComposerArguments
), tool) as JobFromTool,
));
}
Expand All @@ -378,7 +368,6 @@ function createNoOpCheck(config: Config): Job {
phpIni : [],
ignorePhpPlatformRequirement : config.ignorePhpPlatformRequirements[config.stablePhpVersion] ?? false,
additionalComposerArguments : config.additionalComposerArguments,
beforeScript : [],
}
};
}
Expand Down
1 change: 0 additions & 1 deletion src/config/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export interface JobDefinitionFromFile {
ignore_php_platform_requirement?: boolean;
additional_composer_arguments: string[];
command: string;
before_script: string[];
}

export type AnyComposerDependencySet = typeof WILDCARD_ALIAS;
Expand Down
7 changes: 2 additions & 5 deletions src/config/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ export interface JobDefinitionForMatrix
dependencies: ComposerDependencySet,
ignore_platform_reqs_8: boolean, // eslint-disable-line camelcase
ignore_php_platform_requirement: boolean, // eslint-disable-line camelcase
additional_composer_arguments: Array<string>, // eslint-disable-line camelcase
before_script: Array<string>, // eslint-disable-line camelcase
additional_composer_arguments: Array<string> // eslint-disable-line camelcase
}

export interface JobForMatrix {
Expand Down Expand Up @@ -48,9 +47,7 @@ export function createJobForMatrixFromJob(job: Job): JobForMatrix {
/* eslint-disable-next-line camelcase */
ignore_php_platform_requirement : job.job.ignorePhpPlatformRequirement,
/* eslint-disable-next-line camelcase */
additional_composer_arguments : job.job.additionalComposerArguments,
/* eslint-disable-next-line camelcase */
before_script : job.job.beforeScript,
additional_composer_arguments : job.job.additionalComposerArguments
}
};
}
65 changes: 31 additions & 34 deletions src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export type Tool = {
toolType: ToolType,
name: string;
command: string;
filesToCheck: PathLike[],
lintConfigCommand?: string,
filesToCheck: PathLike[]
}

function detectInfectionCommand(): string {
Expand All @@ -48,87 +47,85 @@ export default function createTools(config: Config): Array<Tool> {
name : 'Documentation Linting',
command : 'markdownlint doc/book/**/*.md',
filesToCheck : [ 'doc/book/' ],
toolType : ToolType.LINTER,
toolType : ToolType.LINTER
},
{
executionType : ToolExecutionType.STATIC,
name : 'Documentation Linting',
command : 'markdownlint docs/book/**/*.md',
filesToCheck : [ 'docs/book/' ],
toolType : ToolType.LINTER,
toolType : ToolType.LINTER
},
{
executionType : ToolExecutionType.STATIC,
name : 'MkDocs Linting',
command : 'yamllint -d relaxed --no-warnings mkdocs.yml',
filesToCheck : [ 'mkdocs.yml' ],
toolType : ToolType.LINTER,
toolType : ToolType.LINTER
},
{
executionType : ToolExecutionType.MATRIX,
name : 'PHPUnit',
command : './vendor/bin/phpunit',
filesToCheck : [ 'phpunit.xml.dist', 'phpunit.xml' ],
toolType : ToolType.CODE_CHECK,
lintConfigCommand : 'xmllint --schema vendor/phpunit/phpunit/phpunit.xsd',
executionType : ToolExecutionType.MATRIX,
name : 'PHPUnit',
command : './vendor/bin/phpunit',
filesToCheck : [ 'phpunit.xml.dist', 'phpunit.xml' ],
toolType : ToolType.CODE_CHECK
},
{
executionType : ToolExecutionType.STATIC,
name : 'Infection',
command : detectInfectionCommand(),
filesToCheck : [ 'infection.json', 'infection.json.dist' ],
toolType : ToolType.CODE_CHECK,
toolType : ToolType.CODE_CHECK
},
{
executionType : ToolExecutionType.STATIC,
name : 'PHPCodeSniffer',
command : './vendor/bin/phpcs -q --report=checkstyle | cs2pr',
filesToCheck : [ 'phpcs.xml', 'phpcs.xml.dist' ],
toolType : ToolType.CODE_CHECK,
lintConfigCommand : 'xmllint --schema vendor/squizlabs/php_codesniffer/phpcs.xsd',
executionType : ToolExecutionType.STATIC,
name : 'PHPCodeSniffer',
command : './vendor/bin/phpcs -q --report=checkstyle | cs2pr',
filesToCheck : [ 'phpcs.xml', 'phpcs.xml.dist' ],
toolType : ToolType.CODE_CHECK
},
{
executionType : ToolExecutionType.STATIC,
name : 'Psalm',
command : './vendor/bin/psalm --shepherd --stats --output-format=github --no-cache',
filesToCheck : [ 'psalm.xml.dist', 'psalm.xml' ],
toolType : ToolType.CODE_CHECK,
lintConfigCommand : 'xmllint --schema vendor/vimeo/psalm/config.xsd',
executionType : ToolExecutionType.STATIC,
name : 'Psalm',
command : './vendor/bin/psalm --shepherd --stats --output-format=github --no-cache',
filesToCheck : [ 'psalm.xml.dist', 'psalm.xml' ],
toolType : ToolType.CODE_CHECK
},
{
executionType : ToolExecutionType.STATIC,
name : 'Composer Require Checker',
command : './vendor/bin/composer-require-checker check --config-file=composer-require-checker.json -n -v composer.json',
filesToCheck : [ 'composer-require-checker.json' ],
toolType : ToolType.CODE_CHECK,
toolType : ToolType.CODE_CHECK
},
{
executionType : ToolExecutionType.STATIC,
name : 'PHPBench',
command : './vendor/bin/phpbench run --revs=2 --iterations=2 --report=aggregate',
filesToCheck : [ 'phpbench.json' ],
toolType : ToolType.CODE_CHECK,
toolType : ToolType.CODE_CHECK
},
{
executionType : ToolExecutionType.STATIC,
name : 'Codeception',
command : './vendor/bin/codecept run',
filesToCheck : [ 'codeception.yml.dist', 'codeception.yml' ],
toolType : ToolType.CODE_CHECK,
toolType : ToolType.CODE_CHECK
}
]
// Remove all tools which do not need to run
.filter((tool) =>
(config.docLinting && tool.toolType === ToolType.LINTER)
|| (config.codeChecks && tool.toolType === ToolType.CODE_CHECK))
// Remove all tools which are not used by the project
.map((tool) => removeNonExistentFilesToCheck(tool))
.filter((tool) => tool.filesToCheck.length > 0);
.filter((tool) => doesAnyFileExist(tool.filesToCheck));
}

export function removeNonExistentFilesToCheck(tool: Tool): Tool {
return {
...tool,
filesToCheck : tool.filesToCheck.filter((file) => fs.existsSync(file))
};
export function doesAnyFileExist(files: PathLike[]) {
if (files.length === 0) {
return true;
}

return files
.some((file) => fs.existsSync(file));
}
2 changes: 1 addition & 1 deletion tests/code-check-codeception-dist/matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"include": [
{
"name": "Codeception [7.4, latest]",
"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\":[]}",
"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\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
Expand Down
2 changes: 1 addition & 1 deletion tests/code-check-codeception-nodist/matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"include": [
{
"name": "Codeception [7.4, latest]",
"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\":[]}",
"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\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
Expand Down
2 changes: 1 addition & 1 deletion tests/code-check-composer-require-checker/matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"include": [
{
"name": "Composer Require Checker [7.4, latest]",
"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\":[]}",
"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\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"include": [
{
"name": "PHPUnit [7.4, lowest]",
"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\"]}",
"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\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
Expand Down
2 changes: 1 addition & 1 deletion tests/code-check-exclusion-via-config/matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"include": [
{
"name": "PHPUnit [7.4, lowest]",
"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\"]}",
"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\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
Expand Down
2 changes: 1 addition & 1 deletion tests/code-check-infection-dist/matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"include": [
{
"name": "Infection [7.4, latest]",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/infection\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/infection\",\"php\":\"7.4\",\"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"
}
Expand Down
2 changes: 1 addition & 1 deletion tests/code-check-infection-nodist/matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"include": [
{
"name": "Infection [7.4, latest]",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/infection\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/infection\",\"php\":\"7.4\",\"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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"include": [
{
"name": "Infection [8.1, latest]",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/roave-infection-static-analysis-plugin\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/roave-infection-static-analysis-plugin\",\"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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"include": [
{
"name": "Infection [8.1, latest]",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/roave-infection-static-analysis-plugin\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/roave-infection-static-analysis-plugin\",\"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"
}
Expand Down
2 changes: 1 addition & 1 deletion tests/code-check-locked-dependencies/matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"include": [
{
"name": "Infection [7.4, locked]",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/infection\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}",
"job": "{\"command\":\"phpdbg -qrr ./vendor/bin/infection\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
Expand Down
Loading

0 comments on commit c48fe1d

Please sign in to comment.