Skip to content

Commit

Permalink
Merge pull request #229 from laminas/1.23.x-merge-up-into-2.0.x_DB0FJrod
Browse files Browse the repository at this point in the history
Merge release 1.23.0 into 2.0.x
  • Loading branch information
boesing authored Jul 11, 2023
2 parents 753ed73 + 6f09954 commit 71ae677
Show file tree
Hide file tree
Showing 59 changed files with 1,423 additions and 957 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"node/no-unpublished-import": ["error", {
"allowModules": ["@cfworker/json-schema"]
"allowModules": ["@cfworker/json-schema", "dotenv"]
}],
"no-process-exit": "off",
"no-sync": "off",
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ jobs:
id: matrix_generation
env:
PROJECT_NAME_TO_TEST: ${{ matrix.projectName }}
run: cd tests/${PROJECT_NAME_TO_TEST} && docker run -i --entrypoint "/action/main.js" -v $(realpath .):/github/workspace -w=/github/workspace ${TEST_TAG} $(test -r diff && cat diff || echo -n "")
run: |
cd tests/${PROJECT_NAME_TO_TEST} && \
docker run \
-i \
--entrypoint "/action/main.js" \
-v $(realpath .):/github/workspace \
--env-file=test.env \
-w=/github/workspace \
${TEST_TAG} $(test -r diff && cat diff || echo -n "")
- name: "Output generated matrix"
uses: sergeysova/jq-action@v2
Expand Down Expand Up @@ -128,7 +136,7 @@ jobs:
- uses: "actions/setup-node@v3"
with:
check-latest: true
node-version: 19
node-version: 20
- name: "Install node modules"
run: "npm ci"
- name: Run ESLint
Expand All @@ -141,7 +149,7 @@ jobs:
- uses: "actions/setup-node@v3"
with:
check-latest: true
node-version: 19
node-version: 20
- name: "Install node modules"
run: "npm ci"
- name: Run Jest
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:19.7.0-alpine as compiler
FROM node:20.3.1-alpine as compiler

RUN mkdir -p /usr/local/source
WORKDIR /usr/local/source
Expand All @@ -10,7 +10,7 @@ COPY ./src ./src
RUN npm run build


FROM node:19.7.0-alpine
FROM node:20.3.1-alpine
LABEL "repository"="http://github.com/laminas/laminas-ci-matrix-action"
LABEL "homepage"="http://github.com/laminas/laminas-ci-matrix-action"
LABEL "maintainer"="https://github.com/laminas/technical-steering-committee/"
Expand Down
25 changes: 17 additions & 8 deletions laminas-ci.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
"stablePHP": {
"$ref": "#/definitions/stablePHP"
},
"backwardCompatibilityCheck": {
"$ref": "#/definitions/backwardCompatibilityCheck"
},
"additional_checks": {
"type": "array",
"title": "A list of additional checks to be executed",
Expand Down Expand Up @@ -328,14 +331,20 @@
}
},
"stablePHP": {
"type": "string",
"minLength": 1,
"title": "The PHP version to be used for stable checks",
"description": "This PHP version is used for all QA check jobs. The default depends on the `composer.json` of the project and usually reflects the minimum supported PHP version of that project.",
"examples": [
"8.0"
]
},
"type": "string",
"minLength": 1,
"title": "The PHP version to be used for stable checks",
"description": "This PHP version is used for all QA check jobs. The default depends on the `composer.json` of the project and usually reflects the minimum supported PHP version of that project.",
"examples": [
"8.0"
]
},
"backwardCompatibilityCheck": {
"type": "boolean",
"title": "Flag to enable/disable backwards compatibility check",
"description": "This flag enables/disables backwards compatibility check using roave/backward-compatibility-check.",
"default": false
},
"job": {
"type": "object",
"title": "The job to be executed",
Expand Down
2,152 changes: 1,227 additions & 925 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"test": "jest --logHeapUsage"
},
"engines": {
"npm": "^9.2.0",
"node": "^19.3.0"
"npm": "^9.6.0",
"node": "^20.2.0"
},
"dependencies": {
"@actions/core": "^1.10.0",
Expand All @@ -19,10 +19,11 @@
},
"devDependencies": {
"@types/jest": "^29.2.0",
"@types/node": "^18.11.7",
"@types/node": "^20.0.0",
"@types/webpack": "^5.28.0",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"dotenv": "^16.3.1",
"eslint": "^8.26.0",
"eslint-config-incredible": "^2.4.2",
"eslint-import-resolver-typescript": "^3.5.2",
Expand All @@ -32,7 +33,7 @@
"source-map-loader": "^4.0.1",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"typescript": "~4.9.0",
"typescript": "~5.1.0",
"webpack": "^5.74.0",
"webpack-cli": "^5.0.0"
}
Expand Down
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class App {
];

const docLintingRegularExpressions: RegExp[] = [
/(^mkdocs.yml|docs?\/book\/.*\.md$)/
/(^mkdocs.yml|docs?\/book\/.*\.md|README.md$)/
];

diff.forEach(
Expand Down
45 changes: 44 additions & 1 deletion src/config/app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import {PathLike} from 'fs';
import {configDotenv} from 'dotenv';
import createConfig, {gatherVersions} from './app';

beforeEach(() => {
jest.resetModules();

// Clean enviroment to avoid side-effects
process.env = {};
});

describe('config/app', () => {
describe('gatherVersions()', () => {
test.each`
Expand All @@ -16,7 +24,7 @@ describe('config/app', () => {
${'~8.1'} | ${[ '8.1' ]}
${'~8.1.0'} | ${[ '8.1' ]}
${'~8.1.12'} | ${[ '8.1' ]}
${'^7.4 || ~8.0.0 || ~8.1.12'} | ${[ '8.0', '8.1' ]}
${'^8.0 || ~8.0.0 || ~8.1.12'} | ${[ '8.0', '8.1', '8.2' ]}
${'<=8.1.0'} | ${[ '8.0', '8.1' ]}
`('for "$constraint" === $expected', ({constraint, expected}) => {
expect(gatherVersions({require: {php: constraint}})).toEqual(expected);
Expand All @@ -25,6 +33,7 @@ describe('config/app', () => {

describe('createConfig()', () => {
const phpIniFromConfigurationPath: PathLike = 'tests/php-ini-from-configuration';
const roaveBackwardCompatibilityPath: PathLike = 'tests/code-check-roave-backward-compatibility';

it('should return valid config', () => {
expect(createConfig(
Expand All @@ -47,7 +56,41 @@ describe('config/app', () => {
phpIni : [ 'error_reporting=E_ALL' ],
ignorePhpPlatformRequirements : {},
additionalComposerArguments : [],
backwardCompatibilityCheck : false,
baseReference : null,
});
});

it('should detect GITHUB_BASE_REF', () => {
const environment = process.env;

configDotenv({path: `${roaveBackwardCompatibilityPath}/test.env`});

expect(createConfig(
{
codeChecks : true,
docLinting : true,
},
`${roaveBackwardCompatibilityPath}/composer.json`,
`${roaveBackwardCompatibilityPath}/composer.lock`,
`${roaveBackwardCompatibilityPath}/.laminas-ci.json`
)).toEqual({
codeChecks : true,
docLinting : true,
versions : [],
stablePhpVersion : '8.0',
minimumPhpVersion : '8.0',
latestPhpVersion : '8.0',
lockedDependenciesExists : false,
phpExtensions : [],
phpIni : [],
ignorePhpPlatformRequirements : {},
additionalComposerArguments : [],
backwardCompatibilityCheck : true,
baseReference : '1111222233334444aaaabbbbccccdddd',
});

process.env = environment;
});
});
});
25 changes: 20 additions & 5 deletions src/config/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs, {PathLike} from 'fs';
import semver from 'semver';
import parseJsonFile from '../json';
import {Tool, ToolExecutionType} from '../tools';
import {isToolRunningContainerDefaultPhpVersion, Tool, ToolExecutionType} from '../tools';
import {Logger} from '../logging';
import {CURRENT_STABLE, INSTALLABLE_VERSIONS, InstallablePhpVersionType, isInstallableVersion} from './php';
import {ComposerJson} from './composer';
Expand All @@ -22,8 +22,8 @@ export function gatherVersions(composerJson: ComposerJson): InstallablePhpVersio
}

const composerPhpVersion: string = (composerJson.require?.php ?? '')
.replace(/,\s/, ' ')
.replace(/(\d+)\.(\d+)\.([1-9]+)/g, '$1.$2.0');
.replaceAll(/,\s/g, ' ')
.replaceAll(/(\d+)\.(\d+)\.([1-9]+)/g, '$1.$2.0');

if (composerPhpVersion === '') {
return [];
Expand Down Expand Up @@ -85,6 +85,8 @@ export interface Config {
readonly phpIni: string[];
readonly ignorePhpPlatformRequirements: IgnorePhpPlatformRequirements;
readonly additionalComposerArguments: string[];
readonly backwardCompatibilityCheck: boolean;
readonly baseReference: string|null;
}
export interface Requirements {
readonly codeChecks: boolean;
Expand Down Expand Up @@ -283,6 +285,17 @@ function createJob(
return createdJob;
}

function detectPhpVersionForTool(
tool: Tool,
config: Config
): InstallablePhpVersionType {
if (isToolRunningContainerDefaultPhpVersion(tool)) {
return tool.php;
}

return config.minimumPhpVersion;
}

function createJobsForTool(
config: Config,
tool: Tool
Expand All @@ -302,7 +315,7 @@ function createJobsForTool(
tool.name,
createJobDefinition(
tool.command,
config.minimumPhpVersion,
detectPhpVersionForTool(tool, config),
lockedOrLatestDependencySet,
config.phpExtensions,
config.phpIni,
Expand Down Expand Up @@ -449,7 +462,7 @@ export default function createConfig(
if (phpVersionsSupportedByProject.length > 0) {
minimumPHPVersion = phpVersionsSupportedByProject[0] as InstallablePhpVersionType;
maximumPHPVersion =
phpVersionsSupportedByProject[phpVersionsSupportedByProject.length - 1] as InstallablePhpVersionType;
phpVersionsSupportedByProject.at(-1) as InstallablePhpVersionType;
}

configurationFromFile.extensions?.forEach((extension) => phpExtensions = phpExtensions.add(extension));
Expand All @@ -466,6 +479,8 @@ export default function createConfig(
lockedDependenciesExists : fs.existsSync(composerLockJsonFileName),
ignorePhpPlatformRequirements : configurationFromFile.ignore_php_platform_requirements ?? {},
additionalComposerArguments : [ ... new Set(configurationFromFile.additional_composer_arguments ?? []) ],
backwardCompatibilityCheck : configurationFromFile.backwardCompatibilityCheck ?? false,
baseReference : process.env.GITHUB_BASE_REF ?? null,
};
}

Expand Down
1 change: 1 addition & 0 deletions src/config/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ConfigurationFromFile {
ignore_php_platform_requirements?: IgnorePhpPlatformRequirements;
stablePHP?: string;
additional_composer_arguments?: string[];
backwardCompatibilityCheck?: boolean;
}

export interface JobExclusionsFromFile {
Expand Down
4 changes: 3 additions & 1 deletion src/config/php.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const PHP_81 = '8.1';
export const PHP_82 = '8.2';

export const CURRENT_STABLE = PHP_80;
export const CONTAINER_DEFAULT_PHP_VERSION = '@default';

/**
* NOTE: Please keep this list ordered as the ordering is used to detect the minimum supported version of a project
Expand All @@ -11,7 +12,8 @@ export const CURRENT_STABLE = PHP_80;
export const INSTALLABLE_VERSIONS = [
PHP_80,
PHP_81,
PHP_82
PHP_82,
CONTAINER_DEFAULT_PHP_VERSION,
] as const;

export type InstallablePhpVersionType = typeof INSTALLABLE_VERSIONS[number];
Expand Down
Loading

0 comments on commit 71ae677

Please sign in to comment.