From 5f3014836ecb1e294e8cd3cb7d377c09167051a8 Mon Sep 17 00:00:00 2001 From: Zuzana Miklankova Date: Tue, 23 Jan 2024 09:50:34 +0100 Subject: [PATCH] set default value of status input to false The update_pull_request_status input is now set to false by default. This change is not backwards compatible. Users, who wish to have the status in the PR displayed need to specify this input explicitly in their yaml configuration file. Reason for this change is, that there are more possible triggers for TFaGA than Pull Request and Issue Comment and in those this setting is not applicable when set to true.o The tests have been adjusted so that only minimal test tests the configuration when the update_pull_request_status is disabled. The other tests test non-default behaviour when the PR update is enabled, as they did test until now. --- README.md | 2 +- action.yml | 2 +- tests/action.test.ts | 19 ++++++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c1d7288..1a08082 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ See [Testing Farm onboarding guide](https://docs.testing-farm.io/general/0.1/onb | `create_issue_comment` | If GitHub action will create a github issue comment | false | | `pull_request_status_name` | GitHub pull request status name | Fedora | | `debug` | Print debug logs when working with testing farm | true | -| `update_pull_request_status` | Action will update pull request status. | true | +| `update_pull_request_status` | Action will update pull request status. | false | | `environment_settings` | Pass custom settings to the test environment. | empty | | `create_github_summary` | Create summary of the Testing Farm as GiHub Action job. Possible options: "false", "true", "key=value" | true | | `timeout` | Timeout for the Testing Farm job in minutes. | 480 | diff --git a/action.yml b/action.yml index ed9d3b7..4e09fd7 100644 --- a/action.yml +++ b/action.yml @@ -50,7 +50,7 @@ inputs: update_pull_request_status: description: 'Action will update pull request status. Default: true' required: false - default: 'true' + default: 'false' create_github_summary: description: 'Action will create github summary. Possible options: "false", "true", "key=value"' required: false diff --git a/tests/action.test.ts b/tests/action.test.ts index 2ed01e0..9bc0faf 100644 --- a/tests/action.test.ts +++ b/tests/action.test.ts @@ -26,8 +26,8 @@ function setDefaultInputs() { vi.stubEnv('INPUT_VARIABLES', ''); // secrets - Secret environment variables for test env, separated by ; vi.stubEnv('INPUT_SECRETS', ''); - // update_pull_request_status - Action will update pull request status. Default: true - vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'true'); + // update_pull_request_status - Action will update pull request status. Default: false + vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'false'); // create_github_summary - Action will create github summary. Possible options: "false", "true", "key=value" vi.stubEnv('INPUT_CREATE_GITHUB_SUMMARY', 'true'); // arch - Define an architecture for testing environment. Default: x86_64 @@ -218,17 +218,13 @@ describe('Integration tests', () => { ); // First call to request PR details, next two calls for setting the status - expect(mocks.request).toHaveBeenCalledTimes(3); + expect(mocks.request).toHaveBeenCalledTimes(1); expect(mocks.request).toHaveBeenLastCalledWith( - 'POST /repos/{owner}/{repo}/statuses/{sha}', + 'GET /repos/{owner}/{repo}/pulls/{pull_number}', { - context: 'Testing Farm - Fedora', - description: 'Build finished - \\o/', owner: 'sclorg', + pull_number: 1, repo: 'testing-farm-as-github-action', - sha: 'd20d0c37d634a5303fa1e02edc9ea281897ba01a', - state: 'success', - target_url: 'https://artifacts.dev.testing-farm.io/1', } ); @@ -253,6 +249,7 @@ describe('Integration tests', () => { ); // tmt_plan_regex - A tmt plan regex which will be used for selecting plans. By default all plans are selected vi.stubEnv('INPUT_TMT_PLAN_REGEX', 'fedora'); + vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'true'); // Mock Testing Farm API vi.mocked(mocks.newRequest).mockImplementation( @@ -332,6 +329,7 @@ describe('Integration tests', () => { ); // tmt_plan_regex - A tmt plan regex which will be used for selecting plans. By default all plans are selected vi.stubEnv('INPUT_TMT_PLAN_REGEX', 'fedora'); + vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'true'); // Mock Testing Farm API vi.mocked(mocks.newRequest).mockImplementation( @@ -411,6 +409,7 @@ describe('Integration tests', () => { ); // tmt_plan_regex - A tmt plan regex which will be used for selecting plans. By default all plans are selected vi.stubEnv('INPUT_TMT_PLAN_REGEX', 'fedora'); + vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'true'); // Override default inputs // Action is waiting for testing farm to finish or until timeout is reached @@ -477,6 +476,7 @@ describe('Integration tests', () => { ); // tmt_plan_regex - A tmt plan regex which will be used for selecting plans. By default all plans are selected vi.stubEnv('INPUT_TMT_PLAN_REGEX', 'fedora'); + vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'true'); // Override default inputs // tf_scope - Defines the scope of Testing Farm. Possible options are public and private @@ -551,6 +551,7 @@ describe('Integration tests', () => { ); // tmt_plan_regex - A tmt plan regex which will be used for selecting plans. By default all plans are selected vi.stubEnv('INPUT_TMT_PLAN_REGEX', 'fedora'); + vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'true'); // Override default inputs // create_issue_comment - It creates a github issue Comment