From 47abcbde9efdc54a5f4f104d6ae00daa8a298894 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 3 Sep 2022 15:16:56 +0200 Subject: [PATCH 1/9] Verify BC breakages on pull requests, by comparing PR against base branch --- .github/workflows/continuous-integration.yml | 10 +- src/action.ts | 1 + src/action/github.ts | 12 + src/app.ts | 2 +- src/tools.ts | 40 ++- tests/code-check-codeception-dist/test.env | 0 tests/code-check-codeception-nodist/test.env | 0 .../test.env | 0 .../test.env | 0 .../code-check-exclusion-via-config/test.env | 0 tests/code-check-infection-dist/test.env | 0 tests/code-check-infection-nodist/test.env | 0 .../test.env | 0 .../test.env | 0 tests/code-check-locked-dependencies/test.env | 0 tests/code-check-phpbench/test.env | 0 tests/code-check-phpcs-dist/test.env | 0 tests/code-check-phpcs-nodist/test.env | 0 .../test.env | 0 tests/code-check-phpunit-dist/test.env | 0 tests/code-check-phpunit-nodist/test.env | 0 tests/code-check-psalm-dist/test.env | 0 tests/code-check-psalm-nodist/test.env | 0 .../.laminas-ci.json | 3 + .../GITHUB_EVENT_CONTENTS.json | 328 ++++++++++++++++++ .../composer.json | 1 + .../matrix.json | 10 + .../test.env | 2 + .../.laminas-ci.json | 3 + .../GITHUB_EVENT_CONTENTS.json | 3 + .../composer.json | 1 + .../matrix.json | 10 + .../test.env | 2 + .../test.env | 0 .../test.env | 0 .../test.env | 0 .../test.env | 0 .../test.env | 0 tests/doc-linting-doc-book/test.env | 0 tests/doc-linting-docs-book/test.env | 0 tests/doc-linting-mkdocs/test.env | 0 .../test.env | 0 tests/extensions-from-composer-json/test.env | 0 tests/no-checks-due-to-diff/test.env | 0 tests/no-checks/test.env | 0 tests/php-ini-from-configuration/test.env | 0 46 files changed, 419 insertions(+), 9 deletions(-) create mode 100644 tests/code-check-codeception-dist/test.env create mode 100644 tests/code-check-codeception-nodist/test.env create mode 100644 tests/code-check-composer-require-checker/test.env create mode 100644 tests/code-check-deprecated-exclusion-via-config/test.env create mode 100644 tests/code-check-exclusion-via-config/test.env create mode 100644 tests/code-check-infection-dist/test.env create mode 100644 tests/code-check-infection-nodist/test.env create mode 100644 tests/code-check-infection-roave-static-analysis-plugin-dist/test.env create mode 100644 tests/code-check-infection-roave-static-analysis-plugin-nodist/test.env create mode 100644 tests/code-check-locked-dependencies/test.env create mode 100644 tests/code-check-phpbench/test.env create mode 100644 tests/code-check-phpcs-dist/test.env create mode 100644 tests/code-check-phpcs-nodist/test.env create mode 100644 tests/code-check-phpunit-dist-due-to-laminas-ci-json-change/test.env create mode 100644 tests/code-check-phpunit-dist/test.env create mode 100644 tests/code-check-phpunit-nodist/test.env create mode 100644 tests/code-check-psalm-dist/test.env create mode 100644 tests/code-check-psalm-nodist/test.env create mode 100644 tests/code-check-roave-backward-compatibility-check-on-pr/.laminas-ci.json create mode 100644 tests/code-check-roave-backward-compatibility-check-on-pr/GITHUB_EVENT_CONTENTS.json create mode 100644 tests/code-check-roave-backward-compatibility-check-on-pr/composer.json create mode 100644 tests/code-check-roave-backward-compatibility-check-on-pr/matrix.json create mode 100644 tests/code-check-roave-backward-compatibility-check-on-pr/test.env create mode 100644 tests/code-check-roave-backward-compatibility-check-on-push/.laminas-ci.json create mode 100644 tests/code-check-roave-backward-compatibility-check-on-push/GITHUB_EVENT_CONTENTS.json create mode 100644 tests/code-check-roave-backward-compatibility-check-on-push/composer.json create mode 100644 tests/code-check-roave-backward-compatibility-check-on-push/matrix.json create mode 100644 tests/code-check-roave-backward-compatibility-check-on-push/test.env create mode 100644 tests/code-checks-without-linting-due-to-diff/test.env create mode 100644 tests/configuration-additional-job-latest-php-version/test.env create mode 100644 tests/configuration-additional-job-lowest-php-version/test.env create mode 100644 tests/configuration-explicit-job-wildcard-dependency-set/test.env create mode 100644 tests/configuration-explicit-job-wildcard-php/test.env create mode 100644 tests/doc-linting-doc-book/test.env create mode 100644 tests/doc-linting-docs-book/test.env create mode 100644 tests/doc-linting-mkdocs/test.env create mode 100644 tests/doc-linting-without-code-checks-due-diff/test.env create mode 100644 tests/extensions-from-composer-json/test.env create mode 100644 tests/no-checks-due-to-diff/test.env create mode 100644 tests/no-checks/test.env create mode 100644 tests/php-ini-from-configuration/test.env diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ce939e9b..735c5aa2 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -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 diff --git a/src/action.ts b/src/action.ts index 7f4ddf28..8478c091 100644 --- a/src/action.ts +++ b/src/action.ts @@ -8,4 +8,5 @@ export interface Action { publish(variable: string, output: Output): void; markFailed(reason: string): never; getLogger(): Logger; + getBaseBranchSha1(): string | null; } diff --git a/src/action/github.ts b/src/action/github.ts index 6808c5bf..e35f7a2e 100644 --- a/src/action/github.ts +++ b/src/action/github.ts @@ -1,4 +1,6 @@ import * as core from '@actions/core'; +import * as github from '@actions/github'; +import {PullRequest} from '@octokit/webhooks-definitions/schema'; import {Action} from '../action'; import {Output} from '../config/output'; import {Logger} from '../logging'; @@ -32,4 +34,14 @@ export class Github implements Action { } }; } + + getBaseBranchSha1(): string | null { + if (github.context.eventName !== 'pull_request') { + return null; + } + + const pullRequestPayload = github.context.payload as PullRequest; + + return pullRequestPayload.base.sha; + } } diff --git a/src/app.ts b/src/app.ts index 2e5b28b3..09c3b397 100644 --- a/src/app.ts +++ b/src/app.ts @@ -65,7 +65,7 @@ export class App { appConfig: Config ): [JobForMatrix, ...JobForMatrix[]] { const config = parseJsonFile(this.continousIntegrationConfigurationJsonFileName, true) as ConfigurationFromFile; - const tools = createTools(appConfig); + const tools = createTools(appConfig, this.action); this.logger.debug(`Tools detected: ${JSON.stringify(tools, null, SPACES_TO_INDENT_JSON)}`); const jobs: [Job, ...Job[]] = (new DefaultJobCreator(tools, this.logger)) diff --git a/src/tools.ts b/src/tools.ts index 2178b7a9..5e35b128 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -1,7 +1,8 @@ -import fs, { PathLike } from 'fs'; -import { Config } from './config/app'; -import { ComposerJson } from './config/composer'; +import fs, {PathLike} from 'fs'; +import {Config} from './config/app'; +import {ComposerJson} from './config/composer'; import parseJsonFile from './json'; +import {Action} from './action'; export enum ToolExecutionType { /** @@ -41,8 +42,26 @@ function detectInfectionCommand(): string { return 'phpdbg -qrr ./vendor/bin/infection'; } -export default function createTools(config: Config): Array { - return [ +function backwardCompatibilityCheckTool(action: Action): Tool | null { + const baseSha1 = action.getBaseBranchSha1(); + + if (baseSha1 === null) { + return null; + } + + return { + // @TODO need to `git fetch baseSha1` from source repo! + executionType : ToolExecutionType.STATIC, + name : 'Backward Compatibility Check', + command : `roave-backward-compatibility-check check --from="${ baseSha1 }" --install-development-dependencies`, + filesToCheck : [ 'composer.json' ], + toolType : ToolType.CODE_CHECK, + } as Tool; +} + +export default function createTools(config: Config, action: Action): Array { + const bcTool = backwardCompatibilityCheckTool(action); + const tools = [ { executionType : ToolExecutionType.STATIC, name : 'Documentation Linting', @@ -129,8 +148,15 @@ export default function createTools(config: Config): Array { command : './vendor/bin/php-cs-fixer fix -v --diff --dry-run', filesToCheck : [ '.php-cs-fixer.php', '.php-cs-fixer.dist.php' ], toolType : ToolType.CODE_CHECK, - } - ] + }, + ] as Tool[]; + + if (bcTool !== null) { + const bcToolToAdd = bcTool as Tool; + tools.push(bcToolToAdd); + } + + return tools // Remove all tools which do not need to run .filter((tool) => (config.docLinting && tool.toolType === ToolType.LINTER) diff --git a/tests/code-check-codeception-dist/test.env b/tests/code-check-codeception-dist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-codeception-nodist/test.env b/tests/code-check-codeception-nodist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-composer-require-checker/test.env b/tests/code-check-composer-require-checker/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-deprecated-exclusion-via-config/test.env b/tests/code-check-deprecated-exclusion-via-config/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-exclusion-via-config/test.env b/tests/code-check-exclusion-via-config/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-infection-dist/test.env b/tests/code-check-infection-dist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-infection-nodist/test.env b/tests/code-check-infection-nodist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-infection-roave-static-analysis-plugin-dist/test.env b/tests/code-check-infection-roave-static-analysis-plugin-dist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-infection-roave-static-analysis-plugin-nodist/test.env b/tests/code-check-infection-roave-static-analysis-plugin-nodist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-locked-dependencies/test.env b/tests/code-check-locked-dependencies/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-phpbench/test.env b/tests/code-check-phpbench/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-phpcs-dist/test.env b/tests/code-check-phpcs-dist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-phpcs-nodist/test.env b/tests/code-check-phpcs-nodist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-phpunit-dist-due-to-laminas-ci-json-change/test.env b/tests/code-check-phpunit-dist-due-to-laminas-ci-json-change/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-phpunit-dist/test.env b/tests/code-check-phpunit-dist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-phpunit-nodist/test.env b/tests/code-check-phpunit-nodist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-psalm-dist/test.env b/tests/code-check-psalm-dist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-psalm-nodist/test.env b/tests/code-check-psalm-nodist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-roave-backward-compatibility-check-on-pr/.laminas-ci.json b/tests/code-check-roave-backward-compatibility-check-on-pr/.laminas-ci.json new file mode 100644 index 00000000..a912e7b6 --- /dev/null +++ b/tests/code-check-roave-backward-compatibility-check-on-pr/.laminas-ci.json @@ -0,0 +1,3 @@ +{ + "stablePHP": "7.4" +} diff --git a/tests/code-check-roave-backward-compatibility-check-on-pr/GITHUB_EVENT_CONTENTS.json b/tests/code-check-roave-backward-compatibility-check-on-pr/GITHUB_EVENT_CONTENTS.json new file mode 100644 index 00000000..88950802 --- /dev/null +++ b/tests/code-check-roave-backward-compatibility-check-on-pr/GITHUB_EVENT_CONTENTS.json @@ -0,0 +1,328 @@ +{ + "url": "https://example.com/", + "id": 123, + "node_id": "dunno", + "html_url": "https://example.com/", + "diff_url": "https://example.com/", + "patch_url": "https://example.com/", + "issue_url": "https://example.com/", + "number": 123, + "state": "closed", + "locked": false, + "title": "A pull request", + "user": { + "login": "username", + "id": 123, + "node_id": "https://example.com/", + "avatar_url": "https://example.com", + "gravatar_id": "abc", + "url": "https://example.com", + "html_url": "https://example.com", + "followers_url": "https://example.com", + "following_url": "https://example.com", + "gists_url": "https://example.com", + "starred_url": "https://example.com", + "subscriptions_url": "https://example.com", + "organizations_url": "https://example.com", + "repos_url": "https://example.com", + "events_url": "https://example.com", + "received_events_url": "https://example.com", + "type": "User", + "site_admin": false + }, + "body": "a body", + "created_at": "2022-09-03", + "updated_at": "2022-09-03", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": null, + "assignee": null, + "assignees": null, + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": null, + "commits_url": "https://example.com/", + "review_comments_url": "https://example.com/", + "review_comment_url": "https://example.com/", + "comments_url": "https://example.com/", + "statuses_url": "https://example.com/", + "head": { + "label": "head label", + "ref": "some-ref", + "sha": "5555666677778888aaaabbbbccccdddd", + "user": { + "login": "username", + "id": 123, + "node_id": "https://example.com/", + "avatar_url": "https://example.com", + "gravatar_id": "abc", + "url": "https://example.com", + "html_url": "https://example.com", + "followers_url": "https://example.com", + "following_url": "https://example.com", + "gists_url": "https://example.com", + "starred_url": "https://example.com", + "subscriptions_url": "https://example.com", + "organizations_url": "https://example.com", + "repos_url": "https://example.com", + "events_url": "https://example.com", + "received_events_url": "https://example.com", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 123, + "node_id": "abc", + "name": "foo/bar", + "full_name": "FooBar", + "private": false, + "owner": { + "login": "username", + "id": 123, + "node_id": "https://example.com/", + "avatar_url": "https://example.com", + "gravatar_id": "abc", + "url": "https://example.com", + "html_url": "https://example.com", + "followers_url": "https://example.com", + "following_url": "https://example.com", + "gists_url": "https://example.com", + "starred_url": "https://example.com", + "subscriptions_url": "https://example.com", + "organizations_url": "https://example.com", + "repos_url": "https://example.com", + "events_url": "https://example.com", + "received_events_url": "https://example.com", + "type": "User", + "site_admin": false + }, + "html_url": "https://example.com/", + "description": null, + "fork": false, + "url": "https://example.com/", + "forks_url": "https://example.com/", + "keys_url": "https://example.com/", + "collaborators_url": "https://example.com/", + "teams_url": "https://example.com/", + "hooks_url": "https://example.com/", + "issue_events_url": "https://example.com/", + "events_url": "https://example.com/", + "assignees_url": "https://example.com/", + "branches_url": "https://example.com/", + "tags_url": "https://example.com/", + "blobs_url": "https://example.com/", + "git_tags_url": "https://example.com/", + "git_refs_url": "https://example.com/", + "trees_url": "https://example.com/", + "statuses_url": "https://example.com/", + "languages_url": "https://example.com/", + "stargazers_url": "https://example.com/", + "contributors_url": "https://example.com/", + "subscribers_url": "https://example.com/", + "subscription_url": "https://example.com/", + "commits_url": "https://example.com/", + "git_commits_url": "https://example.com/", + "comments_url": "https://example.com/", + "issue_comment_url": "https://example.com/", + "contents_url": "https://example.com/", + "compare_url": "https://example.com/", + "merges_url": "https://example.com/", + "archive_url": "https://example.com/", + "downloads_url": "https://example.com/", + "issues_url": "https://example.com/", + "pulls_url": "https://example.com/", + "milestones_url": "https://example.com/", + "notifications_url": "https://example.com/", + "labels_url": "https://example.com/", + "releases_url": "https://example.com/", + "deployments_url": "https://example.com/", + "created_at": "2022-08-01", + "updated_at": "2022-08-15", + "pushed_at": "2022-08-15", + "git_url": "https://example.com/", + "ssh_url": "https://example.com/", + "clone_url": "https://example.com/", + "svn_url": "https://example.com/", + "homepage": null, + "size": 100, + "stargazers_count": 2, + "watchers_count": 1, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 1, + "mirror_url": null, + "archived": false, + "open_issues_count": 5, + "license": null, + "forks": 1, + "open_issues": 5, + "watchers": 1, + "default_branch": "foo" + } + }, + "base": { + "label": "head label", + "ref": "some-ref", + "sha": "1111222233334444aaaabbbbccccdddd", + "user": { + "login": "username", + "id": 123, + "node_id": "https://example.com/", + "avatar_url": "https://example.com", + "gravatar_id": "abc", + "url": "https://example.com", + "html_url": "https://example.com", + "followers_url": "https://example.com", + "following_url": "https://example.com", + "gists_url": "https://example.com", + "starred_url": "https://example.com", + "subscriptions_url": "https://example.com", + "organizations_url": "https://example.com", + "repos_url": "https://example.com", + "events_url": "https://example.com", + "received_events_url": "https://example.com", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 123, + "node_id": "abc", + "name": "foo/bar", + "full_name": "FooBar", + "private": false, + "owner": { + "login": "username", + "id": 123, + "node_id": "https://example.com/", + "avatar_url": "https://example.com", + "gravatar_id": "abc", + "url": "https://example.com", + "html_url": "https://example.com", + "followers_url": "https://example.com", + "following_url": "https://example.com", + "gists_url": "https://example.com", + "starred_url": "https://example.com", + "subscriptions_url": "https://example.com", + "organizations_url": "https://example.com", + "repos_url": "https://example.com", + "events_url": "https://example.com", + "received_events_url": "https://example.com", + "type": "User", + "site_admin": false + }, + "html_url": "https://example.com/", + "description": null, + "fork": false, + "url": "https://example.com/", + "forks_url": "https://example.com/", + "keys_url": "https://example.com/", + "collaborators_url": "https://example.com/", + "teams_url": "https://example.com/", + "hooks_url": "https://example.com/", + "issue_events_url": "https://example.com/", + "events_url": "https://example.com/", + "assignees_url": "https://example.com/", + "branches_url": "https://example.com/", + "tags_url": "https://example.com/", + "blobs_url": "https://example.com/", + "git_tags_url": "https://example.com/", + "git_refs_url": "https://example.com/", + "trees_url": "https://example.com/", + "statuses_url": "https://example.com/", + "languages_url": "https://example.com/", + "stargazers_url": "https://example.com/", + "contributors_url": "https://example.com/", + "subscribers_url": "https://example.com/", + "subscription_url": "https://example.com/", + "commits_url": "https://example.com/", + "git_commits_url": "https://example.com/", + "comments_url": "https://example.com/", + "issue_comment_url": "https://example.com/", + "contents_url": "https://example.com/", + "compare_url": "https://example.com/", + "merges_url": "https://example.com/", + "archive_url": "https://example.com/", + "downloads_url": "https://example.com/", + "issues_url": "https://example.com/", + "pulls_url": "https://example.com/", + "milestones_url": "https://example.com/", + "notifications_url": "https://example.com/", + "labels_url": "https://example.com/", + "releases_url": "https://example.com/", + "deployments_url": "https://example.com/", + "created_at": "2022-08-01", + "updated_at": "2022-08-15", + "pushed_at": "2022-08-15", + "git_url": "https://example.com/", + "ssh_url": "https://example.com/", + "clone_url": "https://example.com/", + "svn_url": "https://example.com/", + "homepage": null, + "size": 100, + "stargazers_count": 2, + "watchers_count": 1, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 1, + "mirror_url": null, + "archived": false, + "open_issues_count": 5, + "license": null, + "forks": 1, + "open_issues": 5, + "watchers": 1, + "default_branch": "foo" + } + }, + "_links": { + "self": { + "href": "https://example.com/" + }, + "html": { + "href": "https://example.com/" + }, + "issue": { + "href": "https://example.com/" + }, + "comments": { + "href": "https://example.com/" + }, + "review_comments": { + "href": "https://example.com/" + }, + "review_comment": { + "href": "https://example.com/" + }, + "commits": { + "href": "https://example.com/" + }, + "statuses": { + "href": "https://example.com/" + } + }, + "author_association": "NONE", + "auto_merge": null, + "active_lock_reason": null, + "draft": false, + "merged": null, + "mergeable": null, + "rebaseable": null, + "mergeable_state": "some_state", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": 0, + "commits": 1, + "additions": 10, + "deletions": 5, + "changed_files": 2 +} \ No newline at end of file diff --git a/tests/code-check-roave-backward-compatibility-check-on-pr/composer.json b/tests/code-check-roave-backward-compatibility-check-on-pr/composer.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/tests/code-check-roave-backward-compatibility-check-on-pr/composer.json @@ -0,0 +1 @@ +{} diff --git a/tests/code-check-roave-backward-compatibility-check-on-pr/matrix.json b/tests/code-check-roave-backward-compatibility-check-on-pr/matrix.json new file mode 100644 index 00000000..18397dba --- /dev/null +++ b/tests/code-check-roave-backward-compatibility-check-on-pr/matrix.json @@ -0,0 +1,10 @@ +{ + "include": [ + { + "name": "Backward Compatibility Check", + "job": "{\"command\":\"roave-backward-compatibility-check check --from=\\\"1111222233334444aaaabbbbccccdddd\\\" --install-development-dependencies\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[\"git fetch origin \\\"1111222233334444aaaabbbbccccdddd\\\"\"]}", + "operatingSystem": "ubuntu-latest", + "action": "laminas/laminas-continuous-integration-action@v1" + } + ] +} diff --git a/tests/code-check-roave-backward-compatibility-check-on-pr/test.env b/tests/code-check-roave-backward-compatibility-check-on-pr/test.env new file mode 100644 index 00000000..a37eb845 --- /dev/null +++ b/tests/code-check-roave-backward-compatibility-check-on-pr/test.env @@ -0,0 +1,2 @@ +GITHUB_EVENT_PATH=/github/workspace/GITHUB_EVENT_CONTENTS.json +GITHUB_EVENT_NAME=pull_request diff --git a/tests/code-check-roave-backward-compatibility-check-on-push/.laminas-ci.json b/tests/code-check-roave-backward-compatibility-check-on-push/.laminas-ci.json new file mode 100644 index 00000000..a912e7b6 --- /dev/null +++ b/tests/code-check-roave-backward-compatibility-check-on-push/.laminas-ci.json @@ -0,0 +1,3 @@ +{ + "stablePHP": "7.4" +} diff --git a/tests/code-check-roave-backward-compatibility-check-on-push/GITHUB_EVENT_CONTENTS.json b/tests/code-check-roave-backward-compatibility-check-on-push/GITHUB_EVENT_CONTENTS.json new file mode 100644 index 00000000..5e7edb7e --- /dev/null +++ b/tests/code-check-roave-backward-compatibility-check-on-push/GITHUB_EVENT_CONTENTS.json @@ -0,0 +1,3 @@ +{ + "doesn't": "matter" +} \ No newline at end of file diff --git a/tests/code-check-roave-backward-compatibility-check-on-push/composer.json b/tests/code-check-roave-backward-compatibility-check-on-push/composer.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/tests/code-check-roave-backward-compatibility-check-on-push/composer.json @@ -0,0 +1 @@ +{} diff --git a/tests/code-check-roave-backward-compatibility-check-on-push/matrix.json b/tests/code-check-roave-backward-compatibility-check-on-push/matrix.json new file mode 100644 index 00000000..18397dba --- /dev/null +++ b/tests/code-check-roave-backward-compatibility-check-on-push/matrix.json @@ -0,0 +1,10 @@ +{ + "include": [ + { + "name": "Backward Compatibility Check", + "job": "{\"command\":\"roave-backward-compatibility-check check --from=\\\"1111222233334444aaaabbbbccccdddd\\\" --install-development-dependencies\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[\"git fetch origin \\\"1111222233334444aaaabbbbccccdddd\\\"\"]}", + "operatingSystem": "ubuntu-latest", + "action": "laminas/laminas-continuous-integration-action@v1" + } + ] +} diff --git a/tests/code-check-roave-backward-compatibility-check-on-push/test.env b/tests/code-check-roave-backward-compatibility-check-on-push/test.env new file mode 100644 index 00000000..41ba94c8 --- /dev/null +++ b/tests/code-check-roave-backward-compatibility-check-on-push/test.env @@ -0,0 +1,2 @@ +GITHUB_EVENT_PATH=/github/workspace/GITHUB_EVENT_CONTENTS.json +GITHUB_EVENT_NAME=push diff --git a/tests/code-checks-without-linting-due-to-diff/test.env b/tests/code-checks-without-linting-due-to-diff/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/configuration-additional-job-latest-php-version/test.env b/tests/configuration-additional-job-latest-php-version/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/configuration-additional-job-lowest-php-version/test.env b/tests/configuration-additional-job-lowest-php-version/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/configuration-explicit-job-wildcard-dependency-set/test.env b/tests/configuration-explicit-job-wildcard-dependency-set/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/configuration-explicit-job-wildcard-php/test.env b/tests/configuration-explicit-job-wildcard-php/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/doc-linting-doc-book/test.env b/tests/doc-linting-doc-book/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/doc-linting-docs-book/test.env b/tests/doc-linting-docs-book/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/doc-linting-mkdocs/test.env b/tests/doc-linting-mkdocs/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/doc-linting-without-code-checks-due-diff/test.env b/tests/doc-linting-without-code-checks-due-diff/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/extensions-from-composer-json/test.env b/tests/extensions-from-composer-json/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/no-checks-due-to-diff/test.env b/tests/no-checks-due-to-diff/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/no-checks/test.env b/tests/no-checks/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/php-ini-from-configuration/test.env b/tests/php-ini-from-configuration/test.env new file mode 100644 index 00000000..e69de29b From 670fc449103e73cc4204a32343991aff68c4ab13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sun, 9 Jul 2023 16:38:07 +0200 Subject: [PATCH 2/9] refactoring: remove github event usage and instead target `GITHUB_BASE_REF` environment variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also introduces a new tool type `ToolRunningContainerDefaultPhpVersion`. This is used in case tools are pre-installed within the CI container as it is the case for `roave-backward-compatibility-check`. By having an option available for `backwardCompatibilityCheck`, projects can opt-in for these kind of checks. This flag will be enabled by-default with v2 and thus changes to opt-out. Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- laminas-ci.schema.json | 24 +- src/action.ts | 1 - src/action/github.ts | 12 - src/app.ts | 2 +- src/config/app.ts | 19 +- src/config/input.ts | 1 + src/config/php.ts | 4 +- src/tools.ts | 34 +- .../.laminas-ci.json | 3 - .../GITHUB_EVENT_CONTENTS.json | 328 ------------------ .../matrix.json | 10 - .../test.env | 2 - .../.laminas-ci.json | 3 - .../GITHUB_EVENT_CONTENTS.json | 3 - .../composer.json | 1 - .../matrix.json | 10 - .../test.env | 2 - .../.laminas-ci.json | 4 + .../composer.json | 0 .../matrix.json | 10 + .../test.env | 1 + 21 files changed, 73 insertions(+), 401 deletions(-) delete mode 100644 tests/code-check-roave-backward-compatibility-check-on-pr/.laminas-ci.json delete mode 100644 tests/code-check-roave-backward-compatibility-check-on-pr/GITHUB_EVENT_CONTENTS.json delete mode 100644 tests/code-check-roave-backward-compatibility-check-on-pr/matrix.json delete mode 100644 tests/code-check-roave-backward-compatibility-check-on-pr/test.env delete mode 100644 tests/code-check-roave-backward-compatibility-check-on-push/.laminas-ci.json delete mode 100644 tests/code-check-roave-backward-compatibility-check-on-push/GITHUB_EVENT_CONTENTS.json delete mode 100644 tests/code-check-roave-backward-compatibility-check-on-push/composer.json delete mode 100644 tests/code-check-roave-backward-compatibility-check-on-push/matrix.json delete mode 100644 tests/code-check-roave-backward-compatibility-check-on-push/test.env create mode 100644 tests/code-check-roave-backward-compatibility/.laminas-ci.json rename tests/{code-check-roave-backward-compatibility-check-on-pr => code-check-roave-backward-compatibility}/composer.json (100%) create mode 100644 tests/code-check-roave-backward-compatibility/matrix.json create mode 100644 tests/code-check-roave-backward-compatibility/test.env diff --git a/laminas-ci.schema.json b/laminas-ci.schema.json index 431cd217..b41cf158 100644 --- a/laminas-ci.schema.json +++ b/laminas-ci.schema.json @@ -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", @@ -328,14 +331,19 @@ } }, "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." + }, "job": { "type": "object", "title": "The job to be executed", diff --git a/src/action.ts b/src/action.ts index 8478c091..7f4ddf28 100644 --- a/src/action.ts +++ b/src/action.ts @@ -8,5 +8,4 @@ export interface Action { publish(variable: string, output: Output): void; markFailed(reason: string): never; getLogger(): Logger; - getBaseBranchSha1(): string | null; } diff --git a/src/action/github.ts b/src/action/github.ts index e35f7a2e..6808c5bf 100644 --- a/src/action/github.ts +++ b/src/action/github.ts @@ -1,6 +1,4 @@ import * as core from '@actions/core'; -import * as github from '@actions/github'; -import {PullRequest} from '@octokit/webhooks-definitions/schema'; import {Action} from '../action'; import {Output} from '../config/output'; import {Logger} from '../logging'; @@ -34,14 +32,4 @@ export class Github implements Action { } }; } - - getBaseBranchSha1(): string | null { - if (github.context.eventName !== 'pull_request') { - return null; - } - - const pullRequestPayload = github.context.payload as PullRequest; - - return pullRequestPayload.base.sha; - } } diff --git a/src/app.ts b/src/app.ts index 09c3b397..2e5b28b3 100644 --- a/src/app.ts +++ b/src/app.ts @@ -65,7 +65,7 @@ export class App { appConfig: Config ): [JobForMatrix, ...JobForMatrix[]] { const config = parseJsonFile(this.continousIntegrationConfigurationJsonFileName, true) as ConfigurationFromFile; - const tools = createTools(appConfig, this.action); + const tools = createTools(appConfig); this.logger.debug(`Tools detected: ${JSON.stringify(tools, null, SPACES_TO_INDENT_JSON)}`); const jobs: [Job, ...Job[]] = (new DefaultJobCreator(tools, this.logger)) diff --git a/src/config/app.ts b/src/config/app.ts index 3294c2fa..bf372397 100644 --- a/src/config/app.ts +++ b/src/config/app.ts @@ -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'; @@ -85,6 +85,8 @@ export interface Config { readonly phpIni: string[]; readonly ignorePhpPlatformRequirements: IgnorePhpPlatformRequirements; readonly additionalComposerArguments: string[]; + readonly backwardCompatibilityCheck: boolean; + readonly targetReference: string|null; } export interface Requirements { readonly codeChecks: boolean; @@ -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 @@ -302,7 +315,7 @@ function createJobsForTool( tool.name, createJobDefinition( tool.command, - config.minimumPhpVersion, + detectPhpVersionForTool(tool, config), lockedOrLatestDependencySet, config.phpExtensions, config.phpIni, @@ -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, + targetReference : process.env.GITHUB_BASE_REF ?? null, }; } diff --git a/src/config/input.ts b/src/config/input.ts index b606b1c5..b4f5e9b0 100644 --- a/src/config/input.ts +++ b/src/config/input.ts @@ -11,6 +11,7 @@ export interface ConfigurationFromFile { ignore_php_platform_requirements?: IgnorePhpPlatformRequirements; stablePHP?: string; additional_composer_arguments?: string[]; + backwardCompatibilityCheck?: boolean; } export interface JobExclusionsFromFile { diff --git a/src/config/php.ts b/src/config/php.ts index 04d5afe8..e75cfc37 100644 --- a/src/config/php.ts +++ b/src/config/php.ts @@ -9,6 +9,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 @@ -23,7 +24,8 @@ export const INSTALLABLE_VERSIONS = [ PHP_74, PHP_80, PHP_81, - PHP_82 + PHP_82, + CONTAINER_DEFAULT_PHP_VERSION, ] as const; export type InstallablePhpVersionType = typeof INSTALLABLE_VERSIONS[number]; diff --git a/src/tools.ts b/src/tools.ts index 5e35b128..fbfd932c 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -2,7 +2,7 @@ import fs, {PathLike} from 'fs'; import {Config} from './config/app'; import {ComposerJson} from './config/composer'; import parseJsonFile from './json'; -import {Action} from './action'; +import {CONTAINER_DEFAULT_PHP_VERSION} from './config/php'; export enum ToolExecutionType { /** @@ -32,6 +32,10 @@ export type Tool = { lintConfigCommand?: string, } +export type ToolRunningContainerDefaultPhpVersion = Tool & { + php: typeof CONTAINER_DEFAULT_PHP_VERSION, +} + function detectInfectionCommand(): string { const composerJson: ComposerJson = parseJsonFile('composer.json', true) as ComposerJson; @@ -42,10 +46,12 @@ function detectInfectionCommand(): string { return 'phpdbg -qrr ./vendor/bin/infection'; } -function backwardCompatibilityCheckTool(action: Action): Tool | null { - const baseSha1 = action.getBaseBranchSha1(); +function backwardCompatibilityCheckTool(config: Config): ToolRunningContainerDefaultPhpVersion | null { + if (!config.backwardCompatibilityCheck) { + return null; + } - if (baseSha1 === null) { + if (config.targetReference === null) { return null; } @@ -53,14 +59,14 @@ function backwardCompatibilityCheckTool(action: Action): Tool | null { // @TODO need to `git fetch baseSha1` from source repo! executionType : ToolExecutionType.STATIC, name : 'Backward Compatibility Check', - command : `roave-backward-compatibility-check check --from="${ baseSha1 }" --install-development-dependencies`, + command : `roave-backward-compatibility-check check --from="${ config.targetReference }" --install-development-dependencies`, filesToCheck : [ 'composer.json' ], toolType : ToolType.CODE_CHECK, - } as Tool; + php : CONTAINER_DEFAULT_PHP_VERSION, + } as ToolRunningContainerDefaultPhpVersion; } -export default function createTools(config: Config, action: Action): Array { - const bcTool = backwardCompatibilityCheckTool(action); +export default function createTools(config: Config): Array { const tools = [ { executionType : ToolExecutionType.STATIC, @@ -149,12 +155,8 @@ export default function createTools(config: Config, action: Action): Array filesToCheck : [ '.php-cs-fixer.php', '.php-cs-fixer.dist.php' ], toolType : ToolType.CODE_CHECK, }, - ] as Tool[]; - - if (bcTool !== null) { - const bcToolToAdd = bcTool as Tool; - tools.push(bcToolToAdd); - } + backwardCompatibilityCheckTool(config), + ].filter((tool) => tool !== null) as Tool[]; return tools // Remove all tools which do not need to run @@ -172,3 +174,7 @@ export function removeNonExistentFilesToCheck(tool: Tool): Tool { filesToCheck : tool.filesToCheck.filter((file) => fs.existsSync(file)) }; } + +export function isToolRunningContainerDefaultPhpVersion(tool: Tool): tool is ToolRunningContainerDefaultPhpVersion { + return (tool as ToolRunningContainerDefaultPhpVersion).php === CONTAINER_DEFAULT_PHP_VERSION; +} diff --git a/tests/code-check-roave-backward-compatibility-check-on-pr/.laminas-ci.json b/tests/code-check-roave-backward-compatibility-check-on-pr/.laminas-ci.json deleted file mode 100644 index a912e7b6..00000000 --- a/tests/code-check-roave-backward-compatibility-check-on-pr/.laminas-ci.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "stablePHP": "7.4" -} diff --git a/tests/code-check-roave-backward-compatibility-check-on-pr/GITHUB_EVENT_CONTENTS.json b/tests/code-check-roave-backward-compatibility-check-on-pr/GITHUB_EVENT_CONTENTS.json deleted file mode 100644 index 88950802..00000000 --- a/tests/code-check-roave-backward-compatibility-check-on-pr/GITHUB_EVENT_CONTENTS.json +++ /dev/null @@ -1,328 +0,0 @@ -{ - "url": "https://example.com/", - "id": 123, - "node_id": "dunno", - "html_url": "https://example.com/", - "diff_url": "https://example.com/", - "patch_url": "https://example.com/", - "issue_url": "https://example.com/", - "number": 123, - "state": "closed", - "locked": false, - "title": "A pull request", - "user": { - "login": "username", - "id": 123, - "node_id": "https://example.com/", - "avatar_url": "https://example.com", - "gravatar_id": "abc", - "url": "https://example.com", - "html_url": "https://example.com", - "followers_url": "https://example.com", - "following_url": "https://example.com", - "gists_url": "https://example.com", - "starred_url": "https://example.com", - "subscriptions_url": "https://example.com", - "organizations_url": "https://example.com", - "repos_url": "https://example.com", - "events_url": "https://example.com", - "received_events_url": "https://example.com", - "type": "User", - "site_admin": false - }, - "body": "a body", - "created_at": "2022-09-03", - "updated_at": "2022-09-03", - "closed_at": null, - "merged_at": null, - "merge_commit_sha": null, - "assignee": null, - "assignees": null, - "requested_reviewers": [], - "requested_teams": [], - "labels": [], - "milestone": null, - "commits_url": "https://example.com/", - "review_comments_url": "https://example.com/", - "review_comment_url": "https://example.com/", - "comments_url": "https://example.com/", - "statuses_url": "https://example.com/", - "head": { - "label": "head label", - "ref": "some-ref", - "sha": "5555666677778888aaaabbbbccccdddd", - "user": { - "login": "username", - "id": 123, - "node_id": "https://example.com/", - "avatar_url": "https://example.com", - "gravatar_id": "abc", - "url": "https://example.com", - "html_url": "https://example.com", - "followers_url": "https://example.com", - "following_url": "https://example.com", - "gists_url": "https://example.com", - "starred_url": "https://example.com", - "subscriptions_url": "https://example.com", - "organizations_url": "https://example.com", - "repos_url": "https://example.com", - "events_url": "https://example.com", - "received_events_url": "https://example.com", - "type": "User", - "site_admin": false - }, - "repo": { - "id": 123, - "node_id": "abc", - "name": "foo/bar", - "full_name": "FooBar", - "private": false, - "owner": { - "login": "username", - "id": 123, - "node_id": "https://example.com/", - "avatar_url": "https://example.com", - "gravatar_id": "abc", - "url": "https://example.com", - "html_url": "https://example.com", - "followers_url": "https://example.com", - "following_url": "https://example.com", - "gists_url": "https://example.com", - "starred_url": "https://example.com", - "subscriptions_url": "https://example.com", - "organizations_url": "https://example.com", - "repos_url": "https://example.com", - "events_url": "https://example.com", - "received_events_url": "https://example.com", - "type": "User", - "site_admin": false - }, - "html_url": "https://example.com/", - "description": null, - "fork": false, - "url": "https://example.com/", - "forks_url": "https://example.com/", - "keys_url": "https://example.com/", - "collaborators_url": "https://example.com/", - "teams_url": "https://example.com/", - "hooks_url": "https://example.com/", - "issue_events_url": "https://example.com/", - "events_url": "https://example.com/", - "assignees_url": "https://example.com/", - "branches_url": "https://example.com/", - "tags_url": "https://example.com/", - "blobs_url": "https://example.com/", - "git_tags_url": "https://example.com/", - "git_refs_url": "https://example.com/", - "trees_url": "https://example.com/", - "statuses_url": "https://example.com/", - "languages_url": "https://example.com/", - "stargazers_url": "https://example.com/", - "contributors_url": "https://example.com/", - "subscribers_url": "https://example.com/", - "subscription_url": "https://example.com/", - "commits_url": "https://example.com/", - "git_commits_url": "https://example.com/", - "comments_url": "https://example.com/", - "issue_comment_url": "https://example.com/", - "contents_url": "https://example.com/", - "compare_url": "https://example.com/", - "merges_url": "https://example.com/", - "archive_url": "https://example.com/", - "downloads_url": "https://example.com/", - "issues_url": "https://example.com/", - "pulls_url": "https://example.com/", - "milestones_url": "https://example.com/", - "notifications_url": "https://example.com/", - "labels_url": "https://example.com/", - "releases_url": "https://example.com/", - "deployments_url": "https://example.com/", - "created_at": "2022-08-01", - "updated_at": "2022-08-15", - "pushed_at": "2022-08-15", - "git_url": "https://example.com/", - "ssh_url": "https://example.com/", - "clone_url": "https://example.com/", - "svn_url": "https://example.com/", - "homepage": null, - "size": 100, - "stargazers_count": 2, - "watchers_count": 1, - "language": null, - "has_issues": true, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": true, - "forks_count": 1, - "mirror_url": null, - "archived": false, - "open_issues_count": 5, - "license": null, - "forks": 1, - "open_issues": 5, - "watchers": 1, - "default_branch": "foo" - } - }, - "base": { - "label": "head label", - "ref": "some-ref", - "sha": "1111222233334444aaaabbbbccccdddd", - "user": { - "login": "username", - "id": 123, - "node_id": "https://example.com/", - "avatar_url": "https://example.com", - "gravatar_id": "abc", - "url": "https://example.com", - "html_url": "https://example.com", - "followers_url": "https://example.com", - "following_url": "https://example.com", - "gists_url": "https://example.com", - "starred_url": "https://example.com", - "subscriptions_url": "https://example.com", - "organizations_url": "https://example.com", - "repos_url": "https://example.com", - "events_url": "https://example.com", - "received_events_url": "https://example.com", - "type": "User", - "site_admin": false - }, - "repo": { - "id": 123, - "node_id": "abc", - "name": "foo/bar", - "full_name": "FooBar", - "private": false, - "owner": { - "login": "username", - "id": 123, - "node_id": "https://example.com/", - "avatar_url": "https://example.com", - "gravatar_id": "abc", - "url": "https://example.com", - "html_url": "https://example.com", - "followers_url": "https://example.com", - "following_url": "https://example.com", - "gists_url": "https://example.com", - "starred_url": "https://example.com", - "subscriptions_url": "https://example.com", - "organizations_url": "https://example.com", - "repos_url": "https://example.com", - "events_url": "https://example.com", - "received_events_url": "https://example.com", - "type": "User", - "site_admin": false - }, - "html_url": "https://example.com/", - "description": null, - "fork": false, - "url": "https://example.com/", - "forks_url": "https://example.com/", - "keys_url": "https://example.com/", - "collaborators_url": "https://example.com/", - "teams_url": "https://example.com/", - "hooks_url": "https://example.com/", - "issue_events_url": "https://example.com/", - "events_url": "https://example.com/", - "assignees_url": "https://example.com/", - "branches_url": "https://example.com/", - "tags_url": "https://example.com/", - "blobs_url": "https://example.com/", - "git_tags_url": "https://example.com/", - "git_refs_url": "https://example.com/", - "trees_url": "https://example.com/", - "statuses_url": "https://example.com/", - "languages_url": "https://example.com/", - "stargazers_url": "https://example.com/", - "contributors_url": "https://example.com/", - "subscribers_url": "https://example.com/", - "subscription_url": "https://example.com/", - "commits_url": "https://example.com/", - "git_commits_url": "https://example.com/", - "comments_url": "https://example.com/", - "issue_comment_url": "https://example.com/", - "contents_url": "https://example.com/", - "compare_url": "https://example.com/", - "merges_url": "https://example.com/", - "archive_url": "https://example.com/", - "downloads_url": "https://example.com/", - "issues_url": "https://example.com/", - "pulls_url": "https://example.com/", - "milestones_url": "https://example.com/", - "notifications_url": "https://example.com/", - "labels_url": "https://example.com/", - "releases_url": "https://example.com/", - "deployments_url": "https://example.com/", - "created_at": "2022-08-01", - "updated_at": "2022-08-15", - "pushed_at": "2022-08-15", - "git_url": "https://example.com/", - "ssh_url": "https://example.com/", - "clone_url": "https://example.com/", - "svn_url": "https://example.com/", - "homepage": null, - "size": 100, - "stargazers_count": 2, - "watchers_count": 1, - "language": null, - "has_issues": true, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": true, - "forks_count": 1, - "mirror_url": null, - "archived": false, - "open_issues_count": 5, - "license": null, - "forks": 1, - "open_issues": 5, - "watchers": 1, - "default_branch": "foo" - } - }, - "_links": { - "self": { - "href": "https://example.com/" - }, - "html": { - "href": "https://example.com/" - }, - "issue": { - "href": "https://example.com/" - }, - "comments": { - "href": "https://example.com/" - }, - "review_comments": { - "href": "https://example.com/" - }, - "review_comment": { - "href": "https://example.com/" - }, - "commits": { - "href": "https://example.com/" - }, - "statuses": { - "href": "https://example.com/" - } - }, - "author_association": "NONE", - "auto_merge": null, - "active_lock_reason": null, - "draft": false, - "merged": null, - "mergeable": null, - "rebaseable": null, - "mergeable_state": "some_state", - "merged_by": null, - "comments": 0, - "review_comments": 0, - "maintainer_can_modify": 0, - "commits": 1, - "additions": 10, - "deletions": 5, - "changed_files": 2 -} \ No newline at end of file diff --git a/tests/code-check-roave-backward-compatibility-check-on-pr/matrix.json b/tests/code-check-roave-backward-compatibility-check-on-pr/matrix.json deleted file mode 100644 index 18397dba..00000000 --- a/tests/code-check-roave-backward-compatibility-check-on-pr/matrix.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "include": [ - { - "name": "Backward Compatibility Check", - "job": "{\"command\":\"roave-backward-compatibility-check check --from=\\\"1111222233334444aaaabbbbccccdddd\\\" --install-development-dependencies\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[\"git fetch origin \\\"1111222233334444aaaabbbbccccdddd\\\"\"]}", - "operatingSystem": "ubuntu-latest", - "action": "laminas/laminas-continuous-integration-action@v1" - } - ] -} diff --git a/tests/code-check-roave-backward-compatibility-check-on-pr/test.env b/tests/code-check-roave-backward-compatibility-check-on-pr/test.env deleted file mode 100644 index a37eb845..00000000 --- a/tests/code-check-roave-backward-compatibility-check-on-pr/test.env +++ /dev/null @@ -1,2 +0,0 @@ -GITHUB_EVENT_PATH=/github/workspace/GITHUB_EVENT_CONTENTS.json -GITHUB_EVENT_NAME=pull_request diff --git a/tests/code-check-roave-backward-compatibility-check-on-push/.laminas-ci.json b/tests/code-check-roave-backward-compatibility-check-on-push/.laminas-ci.json deleted file mode 100644 index a912e7b6..00000000 --- a/tests/code-check-roave-backward-compatibility-check-on-push/.laminas-ci.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "stablePHP": "7.4" -} diff --git a/tests/code-check-roave-backward-compatibility-check-on-push/GITHUB_EVENT_CONTENTS.json b/tests/code-check-roave-backward-compatibility-check-on-push/GITHUB_EVENT_CONTENTS.json deleted file mode 100644 index 5e7edb7e..00000000 --- a/tests/code-check-roave-backward-compatibility-check-on-push/GITHUB_EVENT_CONTENTS.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "doesn't": "matter" -} \ No newline at end of file diff --git a/tests/code-check-roave-backward-compatibility-check-on-push/composer.json b/tests/code-check-roave-backward-compatibility-check-on-push/composer.json deleted file mode 100644 index 0967ef42..00000000 --- a/tests/code-check-roave-backward-compatibility-check-on-push/composer.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/tests/code-check-roave-backward-compatibility-check-on-push/matrix.json b/tests/code-check-roave-backward-compatibility-check-on-push/matrix.json deleted file mode 100644 index 18397dba..00000000 --- a/tests/code-check-roave-backward-compatibility-check-on-push/matrix.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "include": [ - { - "name": "Backward Compatibility Check", - "job": "{\"command\":\"roave-backward-compatibility-check check --from=\\\"1111222233334444aaaabbbbccccdddd\\\" --install-development-dependencies\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[\"git fetch origin \\\"1111222233334444aaaabbbbccccdddd\\\"\"]}", - "operatingSystem": "ubuntu-latest", - "action": "laminas/laminas-continuous-integration-action@v1" - } - ] -} diff --git a/tests/code-check-roave-backward-compatibility-check-on-push/test.env b/tests/code-check-roave-backward-compatibility-check-on-push/test.env deleted file mode 100644 index 41ba94c8..00000000 --- a/tests/code-check-roave-backward-compatibility-check-on-push/test.env +++ /dev/null @@ -1,2 +0,0 @@ -GITHUB_EVENT_PATH=/github/workspace/GITHUB_EVENT_CONTENTS.json -GITHUB_EVENT_NAME=push diff --git a/tests/code-check-roave-backward-compatibility/.laminas-ci.json b/tests/code-check-roave-backward-compatibility/.laminas-ci.json new file mode 100644 index 00000000..cd9ccadc --- /dev/null +++ b/tests/code-check-roave-backward-compatibility/.laminas-ci.json @@ -0,0 +1,4 @@ +{ + "stablePHP": "7.4", + "backwardCompatibilityCheck": true +} diff --git a/tests/code-check-roave-backward-compatibility-check-on-pr/composer.json b/tests/code-check-roave-backward-compatibility/composer.json similarity index 100% rename from tests/code-check-roave-backward-compatibility-check-on-pr/composer.json rename to tests/code-check-roave-backward-compatibility/composer.json diff --git a/tests/code-check-roave-backward-compatibility/matrix.json b/tests/code-check-roave-backward-compatibility/matrix.json new file mode 100644 index 00000000..8ef19412 --- /dev/null +++ b/tests/code-check-roave-backward-compatibility/matrix.json @@ -0,0 +1,10 @@ +{ + "include": [ + { + "name": "Backward Compatibility Check [@default, latest]", + "job": "{\"command\":\"roave-backward-compatibility-check check --from=\\\"1111222233334444aaaabbbbccccdddd\\\" --install-development-dependencies\",\"php\":\"@default\",\"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" + } + ] +} diff --git a/tests/code-check-roave-backward-compatibility/test.env b/tests/code-check-roave-backward-compatibility/test.env new file mode 100644 index 00000000..256fb071 --- /dev/null +++ b/tests/code-check-roave-backward-compatibility/test.env @@ -0,0 +1 @@ +GITHUB_BASE_REF="1111222233334444aaaabbbbccccdddd" From bb25aedccf1b0259d9437224b984d465619f3a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sun, 9 Jul 2023 16:58:38 +0200 Subject: [PATCH 3/9] qa: add new configuration properties to test files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also adds a dedicated test for detecting the target reference from environment using `dotenv` Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- package-lock.json | 13 +++++++++++++ package.json | 1 + src/config/app.spec.ts | 35 +++++++++++++++++++++++++++++++++++ src/config/app.ts | 2 +- 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index d60d3bd4..4c5ad190 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@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", @@ -2983,6 +2984,18 @@ "node": ">=6.0.0" } }, + "node_modules/dotenv": { + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, "node_modules/electron-to-chromium": { "version": "1.4.438", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.438.tgz", diff --git a/package.json b/package.json index c1d99172..68bda69d 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@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", diff --git a/src/config/app.spec.ts b/src/config/app.spec.ts index fe862a9a..69f2a694 100644 --- a/src/config/app.spec.ts +++ b/src/config/app.spec.ts @@ -1,5 +1,6 @@ import {PathLike} from 'fs'; import createConfig, {gatherVersions} from './app'; +import {configDotenv} from "dotenv"; describe('config/app', () => { describe('gatherVersions()', () => { @@ -25,6 +26,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( @@ -47,7 +49,40 @@ describe('config/app', () => { phpIni : [ 'error_reporting=E_ALL' ], ignorePhpPlatformRequirements : {}, additionalComposerArguments : [], + backwardCompatibilityCheck : false, + targetReference : 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: '7.4', + minimumPhpVersion: '7.4', + latestPhpVersion: '7.4', + lockedDependenciesExists: false, + phpExtensions: [], + phpIni: [], + ignorePhpPlatformRequirements: {}, + additionalComposerArguments: [], + backwardCompatibilityCheck: true, + targetReference: "1111222233334444aaaabbbbccccdddd", + }); + + process.env = environment; + }); }); }); diff --git a/src/config/app.ts b/src/config/app.ts index bf372397..b920f691 100644 --- a/src/config/app.ts +++ b/src/config/app.ts @@ -480,7 +480,7 @@ export default function createConfig( ignorePhpPlatformRequirements : configurationFromFile.ignore_php_platform_requirements ?? {}, additionalComposerArguments : [ ... new Set(configurationFromFile.additional_composer_arguments ?? []) ], backwardCompatibilityCheck : configurationFromFile.backwardCompatibilityCheck ?? false, - targetReference : process.env.GITHUB_BASE_REF ?? null, + targetReference : process.env.GITHUB_BASE_REF ?? null, }; } From a70122d63a0d47b7bfd69625c851f17b356dce10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sun, 9 Jul 2023 17:00:50 +0200 Subject: [PATCH 4/9] qa: apply linter fixes and allow `dotenv` to be used as unpublished import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- .eslintrc.json | 2 +- src/config/app.spec.ts | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index edc7b57b..7c046d52 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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", diff --git a/src/config/app.spec.ts b/src/config/app.spec.ts index 69f2a694..ddad8cb3 100644 --- a/src/config/app.spec.ts +++ b/src/config/app.spec.ts @@ -1,6 +1,6 @@ import {PathLike} from 'fs'; +import {configDotenv} from 'dotenv'; import createConfig, {gatherVersions} from './app'; -import {configDotenv} from "dotenv"; describe('config/app', () => { describe('gatherVersions()', () => { @@ -56,30 +56,31 @@ describe('config/app', () => { it('should detect GITHUB_BASE_REF', () => { const environment = process.env; + configDotenv({path: `${roaveBackwardCompatibilityPath}/test.env`}); expect(createConfig( { - codeChecks: true, - docLinting: true, + codeChecks : true, + docLinting : true, }, `${roaveBackwardCompatibilityPath}/composer.json`, `${roaveBackwardCompatibilityPath}/composer.lock`, `${roaveBackwardCompatibilityPath}/.laminas-ci.json` )).toEqual({ - codeChecks: true, - docLinting: true, - versions: [], - stablePhpVersion: '7.4', - minimumPhpVersion: '7.4', - latestPhpVersion: '7.4', - lockedDependenciesExists: false, - phpExtensions: [], - phpIni: [], - ignorePhpPlatformRequirements: {}, - additionalComposerArguments: [], - backwardCompatibilityCheck: true, - targetReference: "1111222233334444aaaabbbbccccdddd", + codeChecks : true, + docLinting : true, + versions : [], + stablePhpVersion : '7.4', + minimumPhpVersion : '7.4', + latestPhpVersion : '7.4', + lockedDependenciesExists : false, + phpExtensions : [], + phpIni : [], + ignorePhpPlatformRequirements : {}, + additionalComposerArguments : [], + backwardCompatibilityCheck : true, + targetReference : '1111222233334444aaaabbbbccccdddd', }); process.env = environment; From 03e0ae88d0390208111e7b191764f0784a90ea74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sun, 9 Jul 2023 17:05:56 +0200 Subject: [PATCH 5/9] bugfix: do not surround `GITHUB_BASE_REF` with quotes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- tests/code-check-roave-backward-compatibility/test.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/code-check-roave-backward-compatibility/test.env b/tests/code-check-roave-backward-compatibility/test.env index 256fb071..a749c03b 100644 --- a/tests/code-check-roave-backward-compatibility/test.env +++ b/tests/code-check-roave-backward-compatibility/test.env @@ -1 +1 @@ -GITHUB_BASE_REF="1111222233334444aaaabbbbccccdddd" +GITHUB_BASE_REF=1111222233334444aaaabbbbccccdddd From e03a8490b952ad483d230578b910c6e04ad896a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sun, 9 Jul 2023 17:06:19 +0200 Subject: [PATCH 6/9] qa: ensure we always have a clean env when executing tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- src/config/app.spec.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/config/app.spec.ts b/src/config/app.spec.ts index ddad8cb3..f1023969 100644 --- a/src/config/app.spec.ts +++ b/src/config/app.spec.ts @@ -2,6 +2,13 @@ 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` From 8734c3d406137da810fd9e58bff846bab3e52694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sun, 9 Jul 2023 17:07:43 +0200 Subject: [PATCH 7/9] qa: add missing `test.env` files after rebase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- tests/code-check-phpcsfixer-php-dist/test.env | 0 tests/code-check-phpcsfixer-php/test.env | 0 tests/doc-linting-readme-due-diff/test.env | 0 tests/doc-linting-readme/test.env | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/code-check-phpcsfixer-php-dist/test.env create mode 100644 tests/code-check-phpcsfixer-php/test.env create mode 100644 tests/doc-linting-readme-due-diff/test.env create mode 100644 tests/doc-linting-readme/test.env diff --git a/tests/code-check-phpcsfixer-php-dist/test.env b/tests/code-check-phpcsfixer-php-dist/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/code-check-phpcsfixer-php/test.env b/tests/code-check-phpcsfixer-php/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/doc-linting-readme-due-diff/test.env b/tests/doc-linting-readme-due-diff/test.env new file mode 100644 index 00000000..e69de29b diff --git a/tests/doc-linting-readme/test.env b/tests/doc-linting-readme/test.env new file mode 100644 index 00000000..e69de29b From b32eebfb28c1654cc219444229fadc3e78e1ec87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Tue, 11 Jul 2023 18:09:04 +0200 Subject: [PATCH 8/9] docs: add default `false` to `backwardCompatibilityCheck` in `laminas-ci.schema.json` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- laminas-ci.schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/laminas-ci.schema.json b/laminas-ci.schema.json index b41cf158..45bad5e7 100644 --- a/laminas-ci.schema.json +++ b/laminas-ci.schema.json @@ -342,7 +342,8 @@ "backwardCompatibilityCheck": { "type": "boolean", "title": "Flag to enable/disable backwards compatibility check", - "description": "This flag enables/disables backwards compatibility check using roave/backward-compatibility-check." + "description": "This flag enables/disables backwards compatibility check using roave/backward-compatibility-check.", + "default": false }, "job": { "type": "object", From ef9f76fccb9ce3c8dd91cf38fb52bcff6f21a1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Tue, 11 Jul 2023 18:10:25 +0200 Subject: [PATCH 9/9] qa: rename `targetReference` to `baseReference` as it is more clear MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- src/config/app.spec.ts | 4 ++-- src/config/app.ts | 4 ++-- src/tools.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/config/app.spec.ts b/src/config/app.spec.ts index f1023969..a8a5ddc4 100644 --- a/src/config/app.spec.ts +++ b/src/config/app.spec.ts @@ -57,7 +57,7 @@ describe('config/app', () => { ignorePhpPlatformRequirements : {}, additionalComposerArguments : [], backwardCompatibilityCheck : false, - targetReference : null, + baseReference : null, }); }); @@ -87,7 +87,7 @@ describe('config/app', () => { ignorePhpPlatformRequirements : {}, additionalComposerArguments : [], backwardCompatibilityCheck : true, - targetReference : '1111222233334444aaaabbbbccccdddd', + baseReference : '1111222233334444aaaabbbbccccdddd', }); process.env = environment; diff --git a/src/config/app.ts b/src/config/app.ts index b920f691..9268ea0e 100644 --- a/src/config/app.ts +++ b/src/config/app.ts @@ -86,7 +86,7 @@ export interface Config { readonly ignorePhpPlatformRequirements: IgnorePhpPlatformRequirements; readonly additionalComposerArguments: string[]; readonly backwardCompatibilityCheck: boolean; - readonly targetReference: string|null; + readonly baseReference: string|null; } export interface Requirements { readonly codeChecks: boolean; @@ -480,7 +480,7 @@ export default function createConfig( ignorePhpPlatformRequirements : configurationFromFile.ignore_php_platform_requirements ?? {}, additionalComposerArguments : [ ... new Set(configurationFromFile.additional_composer_arguments ?? []) ], backwardCompatibilityCheck : configurationFromFile.backwardCompatibilityCheck ?? false, - targetReference : process.env.GITHUB_BASE_REF ?? null, + baseReference : process.env.GITHUB_BASE_REF ?? null, }; } diff --git a/src/tools.ts b/src/tools.ts index fbfd932c..4250a265 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -51,7 +51,7 @@ function backwardCompatibilityCheckTool(config: Config): ToolRunningContainerDef return null; } - if (config.targetReference === null) { + if (config.baseReference === null) { return null; } @@ -59,7 +59,7 @@ function backwardCompatibilityCheckTool(config: Config): ToolRunningContainerDef // @TODO need to `git fetch baseSha1` from source repo! executionType : ToolExecutionType.STATIC, name : 'Backward Compatibility Check', - command : `roave-backward-compatibility-check check --from="${ config.targetReference }" --install-development-dependencies`, + command : `roave-backward-compatibility-check check --from="${ config.baseReference }" --install-development-dependencies`, filesToCheck : [ 'composer.json' ], toolType : ToolType.CODE_CHECK, php : CONTAINER_DEFAULT_PHP_VERSION,