Skip to content

Commit

Permalink
Merge pull request #124 from internalsystemerror/1.15.x
Browse files Browse the repository at this point in the history
Re-release `xmllint` now usage of `before_script` is fixed
  • Loading branch information
Gary Lockett committed Aug 22, 2022
2 parents 082c130 + 983f372 commit 84fdcac
Show file tree
Hide file tree
Showing 32 changed files with 296 additions and 394 deletions.
521 changes: 203 additions & 318 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"scripts": {
"lint": "eslint src/ --ext .ts",
"lint-fix": "eslint src/ --ext .ts --fix",
"build": "tsc --build && webpack --mode=production"
},
"dependencies": {
Expand Down
4 changes: 1 addition & 3 deletions src/action/github.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
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: 19 additions & 8 deletions src/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface JobDefinition {
composerDependencySet: ComposerDependencySet;
ignorePhpPlatformRequirement: boolean;
additionalComposerArguments: string[];
beforeScript: string[];
}

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

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

Expand Down Expand Up @@ -283,13 +287,15 @@ 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 @@ -300,7 +306,8 @@ function createJobsForTool(
config.phpExtensions,
config.phpIni,
config.ignorePhpPlatformRequirements[config.minimumPhpVersion] ?? false,
config.additionalComposerArguments
config.additionalComposerArguments,
beforeScript,
),
tool
) as JobFromTool
Expand All @@ -318,7 +325,8 @@ function createJobsForTool(
config.phpExtensions,
config.phpIni,
config.ignorePhpPlatformRequirements[config.minimumPhpVersion] ?? false,
config.additionalComposerArguments
config.additionalComposerArguments,
beforeScript,
),
tool
) as JobFromTool);
Expand All @@ -332,7 +340,8 @@ function createJobsForTool(
config.phpExtensions,
config.phpIni,
config.ignorePhpPlatformRequirements[version] ?? false,
config.additionalComposerArguments
config.additionalComposerArguments,
beforeScript,
), tool) as JobFromTool,

createJob(tool.name, createJobDefinition(
Expand All @@ -342,7 +351,8 @@ function createJobsForTool(
config.phpExtensions,
config.phpIni,
config.ignorePhpPlatformRequirements[version] ?? false,
config.additionalComposerArguments
config.additionalComposerArguments,
beforeScript,
), tool) as JobFromTool,
));
}
Expand All @@ -368,6 +378,7 @@ function createNoOpCheck(config: Config): Job {
phpIni : [],
ignorePhpPlatformRequirement : config.ignorePhpPlatformRequirements[config.stablePhpVersion] ?? false,
additionalComposerArguments : config.additionalComposerArguments,
beforeScript : [],
}
};
}
Expand Down
1 change: 1 addition & 0 deletions src/config/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ 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: 5 additions & 2 deletions src/config/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ 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
additional_composer_arguments: Array<string>, // eslint-disable-line camelcase
before_script: Array<string>, // eslint-disable-line camelcase
}

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

function detectInfectionCommand(): string {
Expand All @@ -47,85 +48,87 @@ 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
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.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
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 : '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 : '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 : '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
.filter((tool) => doesAnyFileExist(tool.filesToCheck));
.map((tool) => removeNonExistentFilesToCheck(tool))
.filter((tool) => tool.filesToCheck.length > 0);
}

export function doesAnyFileExist(files: PathLike[]) {
if (files.length === 0) {
return true;
}

return files
.some((file) => fs.existsSync(file));
export function removeNonExistentFilesToCheck(tool: Tool): Tool {
return {
...tool,
filesToCheck : tool.filesToCheck.filter((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\":[]}",
"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\":[]}",
"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\":[]}",
"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\":[]}",
"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\":[]}",
"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\":[]}",
"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\":[]}",
"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\"]}",
"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\":[]}",
"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\"]}",
"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\":[]}",
"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\":[]}",
"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\":[]}",
"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\":[]}",
"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\":[]}",
"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\":[]}",
"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\":[]}",
"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\":[]}",
"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\":[]}",
"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\":[]}",
"operatingSystem": "ubuntu-latest",
"action": "laminas/laminas-continuous-integration-action@v1"
}
Expand Down
Loading

0 comments on commit 84fdcac

Please sign in to comment.