Skip to content

Commit

Permalink
set default value of status input to false
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zmiklank committed Jan 23, 2024
1 parent 0fe61e3 commit e13ba48
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ 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. Default: true | true |
| `environment_settings` | Pass custom settings to the test environment. Default: {} | empty |
| `update_pull_request_status` | Action will update pull request status. | false |
| `environment_settings` | Pass custom settings to the test environment. | empty |
| `pr_head_sha` | SHA of the latest commit in PR. Used for setting commit statuses. | $(git rev-parse HEAD) |
| `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 |
Expand Down Expand Up @@ -100,6 +100,7 @@ jobs:
git_url: https://github.com/sclorg/sclorg-testing-farm
tmt_plan_regex: "centos"
pull_request_status_name: "CentOS 7"
update_pull_request_status: "true"
```
and as soon as the job is finished you will see the test results in the pull request status:
Expand Down Expand Up @@ -127,5 +128,4 @@ jobs:
api_key: ${{ secrets.TF_API_KEY }}
git_url: https://github.com/sclorg/sclorg-testing-farm
tmt_plan_regex: "centos"
update_pull_request_status: "false"
```
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ inputs:
required: false
default: ''
update_pull_request_status:
description: 'Action will update pull request status. Default: true'
description: 'Action will update pull request status. Default: false'
required: false
default: 'true'
default: 'false'
create_github_summary:
description: 'Action will create github summary. Possible options: "false", "true", "key=value"'
required: false
Expand Down
26 changes: 17 additions & 9 deletions tests/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
}
);

Expand All @@ -253,6 +249,8 @@ 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');
// Enable PR status update
vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'true');

// Mock Testing Farm API
vi.mocked(mocks.newRequest).mockImplementation(
Expand Down Expand Up @@ -332,6 +330,8 @@ 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');
// Enable PR status update
vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'true');

// Mock Testing Farm API
vi.mocked(mocks.newRequest).mockImplementation(
Expand Down Expand Up @@ -411,11 +411,15 @@ 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');
// Enable PR status update
vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'true');

// Override default inputs
// Action is waiting for testing farm to finish or until timeout is reached
// set timeout to 1 to trigger timeout error after 2 requests
vi.stubEnv('INPUT_TIMEOUT', '1');
// Enable PR status update
vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'true');

// Mock Testing Farm API
vi.mocked(mocks.newRequest).mockImplementation(
Expand Down Expand Up @@ -481,6 +485,8 @@ describe('Integration tests', () => {
// Override default inputs
// tf_scope - Defines the scope of Testing Farm. Possible options are public and private
vi.stubEnv('INPUT_TF_SCOPE', 'private');
// Enable PR status update
vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'true');

// Mock Testing Farm API
vi.mocked(mocks.newRequest).mockImplementation(
Expand Down Expand Up @@ -555,6 +561,8 @@ describe('Integration tests', () => {
// Override default inputs
// create_issue_comment - It creates a github issue Comment
vi.stubEnv('INPUT_CREATE_ISSUE_COMMENT', 'true');
// Enable PR status update
vi.stubEnv('INPUT_UPDATE_PULL_REQUEST_STATUS', 'true');

// Mock Testing Farm API
vi.mocked(mocks.newRequest).mockImplementation(
Expand Down

0 comments on commit e13ba48

Please sign in to comment.