Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backlog-set-due-date script #44

Merged
merged 1 commit into from
Nov 30, 2020

Conversation

ilausuch
Copy link
Contributor

@ilausuch ilausuch commented Nov 20, 2020

This script sets the duedate to 14 days from the script's
execution time for tickets that are not low priority and
have not been assigned to anyone

Add dry_run mode. It uses a test json file as first parameter
to perform the tests and thus have predictable results

https://progress.opensuse.org/issues/73468

@ilausuch ilausuch force-pushed the add-backlog-set-due-date branch 2 times, most recently from 4a5232e to be7e32b Compare November 20, 2020 13:59
@ilausuch
Copy link
Contributor Author

ilausuch commented Nov 20, 2020

Example
id 78390 - High - 30 - 2020-11-20T05:56:02Z -> 2020-12-20T06:56:02Z id 78169 - High - 30 - 2020-11-18T08:40:55Z -> 2020-12-18T09:40:55Z id 77905 - Normal - 356 - 2020-11-15T07:59:14Z -> 2021-11-06T08:59:14Z id 77698 - Normal - 356 - 2020-11-11T09:51:22Z -> 2021-11-02T10:51:22Z id 76984 - Normal - 356 - 2020-11-04T16:10:15Z -> 2021-10-26T18:10:15Z id 76978 - Normal - 356 - 2020-11-04T14:11:46Z -> 2021-10-26T16:11:46Z id 75265 - Normal - 356 - 2020-10-25T13:44:15Z -> 2021-10-16T15:44:15Z id 75214 - Normal - 356 - 2020-10-23T18:25:45Z -> 2021-10-14T20:25:45Z id 75091 - Normal - 356 - 2020-10-22T10:05:24Z -> 2021-10-13T12:05:24Z id 73468 - High - 30 - 2020-10-17T22:01:35Z -> 2020-11-16T23:01:35Z id 73369 - Normal - 356 - 2020-10-14T11:13:01Z -> 2021-10-05T13:13:01Z id 73309 - Normal - 356 - 2020-10-13T21:41:51Z -> 2021-10-04T23:41:51Z id 73285 - Normal - 356 - 2020-10-13T10:27:39Z -> 2021-10-04T12:27:39Z id 71809 - Normal - 356 - 2020-09-24T08:46:28Z -> 2021-09-15T10:46:28Z id 71794 - Normal - 356 - 2020-09-24T07:25:49Z -> 2021-09-15T09:25:49Z id 71758 - Normal - 356 - 2020-09-23T17:34:55Z -> 2021-09-14T19:34:55Z id 70927 - Normal - 356 - 2020-09-03T23:53:10Z -> 2021-08-26T01:53:10Z id 70915 - Normal - 356 - 2020-09-03T13:22:30Z -> 2021-08-25T15:22:30Z id 70876 - Normal - 356 - 2020-09-02T15:48:01Z -> 2021-08-24T17:48:01Z id 70840 - Normal - 356 - 2020-09-02T09:20:00Z -> 2021-08-24T11:20:00Z id 70612 - Normal - 356 - 2020-08-27T14:16:53Z -> 2021-08-18T16:16:53Z id 69451 - Normal - 356 - 2020-07-30T07:51:46Z -> 2021-07-21T09:51:46Z id 69310 - High - 30 - 2020-07-24T10:18:02Z -> 2020-08-23T12:18:02Z id 68413 - Normal - 356 - 2020-06-24T20:17:12Z -> 2021-06-15T22:17:12Z

@ilausuch ilausuch force-pushed the add-backlog-set-due-date branch 2 times, most recently from 152874d to 4963b4b Compare November 20, 2020 17:48
backlog-set-due-date Outdated Show resolved Hide resolved
backlog-set-due-date Outdated Show resolved Hide resolved
issues.json Outdated Show resolved Hide resolved
backlog-set-due-date Outdated Show resolved Hide resolved
@ilausuch
Copy link
Contributor Author

Thanks @okurz for the review. Following your ideas:

  • I cleaned up the testing file
  • I based the due date on the start_date that I understand is the first time a ticket is assigned to someone

Right now the script is prepared for testing using the issues.json and doesn't uses the curl function

The results of the tests are

3 "Normal"	2020-11-01	 +365 	2021-11-01
4 "High"	2020-11-01	 +30 	2020-12-01
5 "Urgent"	2020-11-01	 +7 	2020-11-08
6 "Immediate"	2020-11-01	 +1 	2020-11-02

@ilausuch
Copy link
Contributor Author

Is this solution better now? If yes, I will clean up and start to implement the API update call

@okurz
Copy link
Member

okurz commented Nov 23, 2020

Please see #44 (comment) first. I think you can simplify a lot for now and not use the switch on prio at all for now.

Simple pseudo-code proposal:

for each issue
  if issue.assignee == null && issue.due_date == null
    issue.due_date = now() + 14d

@ilausuch
Copy link
Contributor Author

ilausuch commented Nov 23, 2020

Please see #44 (comment) first. I think you can simplify a lot for now and not use the switch on prio at all for now.

Simple pseudo-code proposal:

for each issue
  if issue.assignee == null && issue.due_date == null
    issue.due_date = now() + 14d

Ok, let's do that
Done, but please consider the WIP label. I mean, every commit it's only to have historic what is done in case we want to comeback to a previous version. Once we decide the final version then I'll squash and refactor the commit message correctly.
Now I adapted the test to have 3 cases, one of them (issue 1) match the conditions and will have the new due date.

backlog-set-due-date Outdated Show resolved Hide resolved
@ilausuch
Copy link
Contributor Author

Ok, I pushed a commit that has the shellcheck clean and should do the job. I didn't test this yet on real, but I tests the different parts using echos. If reviewers are ok, next step is to clean the commits and remove the test file to prepare to be merged.

Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the test file is a good idea to be used within an automatic integration test. At least please move the test file to "tests/". Then you can add a test for it. You mentioned "echo" already. This could be used for testing. I guess the easiest option is the same approach that we do for autoinst and openQA, e.g. a simple file like t/backlog-set-due-date.t using Test::Most. But it is ok for me if you see these automatic tests out of scope, just move the file then.

@ilausuch ilausuch changed the title [WIP] Add backlog-set-due-date script Add backlog-set-due-date script Nov 24, 2020
@ilausuch
Copy link
Contributor Author

I moved out the testing file and reserved it to the testing PR. But for testing purposes should the echos be maintained in this script? and also a parameter to initialize the script from a file instead of perform the curl? and also avoid the final curl?

@ilausuch ilausuch marked this pull request as ready for review November 24, 2020 10:01
@ilausuch
Copy link
Contributor Author

Also I added a new commit with testing options

Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it out now, two issues:

  1. Please phrase git commit message subject lines in imperative mood, i.e. "s/Added/Add/"
  2. This is setting the due date on too many tickets. E.g. "Blocked" ones, e.g. https://progress.opensuse.org/issues/69310 . This does not make sense because the assignee of a blocked ticket can't do anything about it, that's why it's "Blocked". We should exclude them or only select a passlist of status values where we want to set a due date. Also https://progress.opensuse.org/issues/80264 would have the due date set but that ticket does not have an assignee. My proposal had that mistake to look for issue.assignee == null when instead we want the opposite. And please keep in mind that I only wrote pseudo-code. I don't know if you an actually check for "null" in jq or anything

backlog-set-due-date Outdated Show resolved Hide resolved
@ilausuch
Copy link
Contributor Author

I tried it out now, two issues:

1. Please phrase git commit message subject lines in imperative mood, i.e. "s/Added/Add/"

2. This is setting the due date on too many tickets. E.g. "Blocked" ones, e.g. [progress.opensuse.org/issues/69310](https://progress.opensuse.org/issues/69310) . This does not make sense because the assignee of a blocked ticket can't do anything about it, that's why it's "Blocked". We should exclude them or only select a passlist of status values where we want to set a due date. Also [progress.opensuse.org/issues/80264](https://progress.opensuse.org/issues/80264) would have the due date set but that ticket does not have an assignee. My proposal had that mistake to look for `issue.assignee == null` when instead we want the opposite. And please keep in mind that I only wrote pseudo-code. I don't know if you an actually check for "null" in jq or anything

Working on that

@ilausuch ilausuch force-pushed the add-backlog-set-due-date branch 2 times, most recently from 0314a1a to c52fc74 Compare November 24, 2020 15:45
@ilausuch
Copy link
Contributor Author

Ok, now the commit includes the reviews comments from @kalikiana and @okurz. Also include the dry mode with the a testing file to have predictable results

backlog-set-due-date Outdated Show resolved Hide resolved
backlog-set-due-date Outdated Show resolved Hide resolved
Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please share some info on what you have tested after your recent changes. I see that you include "!=Blocked", does that exclude "Resolved" still?

@ilausuch
Copy link
Contributor Author

No that doesn't include resolved. I can add that but I didn't thought was necessary. However adding that

@ilausuch
Copy link
Contributor Author

ilausuch commented Nov 25, 2020

I added the Resolved exception too and changed the assignee by assigned_to. Let me know if there are more.

I run the test

dry_run=1 ./backlog-set-due-date issues.json

With the issues.json like this:

{
  "issues": [
    {
      "id": 1,
      "priority": {
        "name": "High"
      },
      "status": {
        "name": "In Progress"
      },
      "assigned_to": {},
      "due_date": null,
      "created_on": "2020-11-01T00:00:01Z"
    },
    {
      "id": 2,
      "priority": {
        "name": "Low"
      },
      "status": {
        "name": "In Progress"
      },
      "assigned_to": {},
      "due_date": null,
      "created_on": "2020-11-01T00:00:01Z"
    },
    {
      "id": 3,
      "priority": {
        "name": "High"
      },
      "status": {
        "name": "In Progress"
      },
      "due_date": "2020-11-14",
      "created_on": "2020-11-01T00:00:01Z"
    },
    {
      "id": 4,
      "priority": {
        "name": "High"
      },
      "status": {
        "name": "Blocked"
      },
      "assigned_to": {},
      "due_date": "2020-11-14",
      "created_on": "2020-11-01T00:00:01Z"
    },
    {
      "id": 5,
      "priority": {
        "name": "High"
      },
      "status": {
        "name": "Resolved"
      },
      "assigned_to": {},
      "due_date": "2020-11-14",
      "created_on": "2020-11-01T00:00:01Z"
    }
  ]
}

And the result output is

curl -v -H X-Redmine-API-Key:  -H Content-Type: application/json -X PUT -d {"issue": {"due_date": "2020-12-09", "notes": "Setting due date based on mean cycle time of SUSE QE Tools"}} https://progress.opensuse.org/issues/1.json

@ilausuch ilausuch force-pushed the add-backlog-set-due-date branch 2 times, most recently from 97018b2 to a65b1fa Compare November 25, 2020 15:52
@ilausuch
Copy link
Contributor Author

A new update with the suggestions of @kalikiana (from a chat)

I also would like to share a test with real data in dry_mode (without updating the tickets)

Updating ticket 80298, new due date setup to 2020-12-09
curl -v -H X-Redmine-API-Key:  -H Content-Type: application/json -X PUT -d {"issue": {"due_date": "2020-12-09", "notes": "Setting due date based on mean cycle time of SUSE QE Tools"}} https://progress.opensuse.org/issues/80298.json
Updating ticket 80268, new due date setup to 2020-12-09
curl -v -H X-Redmine-API-Key:  -H Content-Type: application/json -X PUT -d {"issue": {"due_date": "2020-12-09", "notes": "Setting due date based on mean cycle time of SUSE QE Tools"}} https://progress.opensuse.org/issues/80268.json
Updating ticket 80264, new due date setup to 2020-12-09
curl -v -H X-Redmine-API-Key:  -H Content-Type: application/json -X PUT -d {"issue": {"due_date": "2020-12-09", "notes": "Setting due date based on mean cycle time of SUSE QE Tools"}} https://progress.opensuse.org/issues/80264.json
Updating ticket 80118, new due date setup to 2020-12-09
curl -v -H X-Redmine-API-Key:  -H Content-Type: application/json -X PUT -d {"issue": {"due_date": "2020-12-09", "notes": "Setting due date based on mean cycle time of SUSE QE Tools"}} https://progress.opensuse.org/issues/80118.json
Updating ticket 77905, new due date setup to 2020-12-09
curl -v -H X-Redmine-API-Key:  -H Content-Type: application/json -X PUT -d {"issue": {"due_date": "2020-12-09", "notes": "Setting due date based on mean cycle time of SUSE QE Tools"}} https://progress.opensuse.org/issues/77905.json
Updating ticket 75265, new due date setup to 2020-12-09
curl -v -H X-Redmine-API-Key:  -H Content-Type: application/json -X PUT -d {"issue": {"due_date": "2020-12-09", "notes": "Setting due date based on mean cycle time of SUSE QE Tools"}} https://progress.opensuse.org/issues/75265.json
Updating ticket 73468, new due date setup to 2020-12-09
curl -v -H X-Redmine-API-Key:  -H Content-Type: application/json -X PUT -d {"issue": {"due_date": "2020-12-09", "notes": "Setting due date based on mean cycle time of SUSE QE Tools"}} https://progress.opensuse.org/issues/73468.json

@kalikiana kalikiana requested a review from okurz November 25, 2020 16:10
backlog-set-due-date Outdated Show resolved Hide resolved
This script sets the duedate to 14 days from the script's
execution time for tickets that are not low priority and
have not been assigned to anyone

Add dry_run mode. It uses a test json file as first parameter
to perform the tests and thus have predictable results

progress.opensuse.org/issues/73468
Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script looks good. Can you add it to github actions now?

I have called it locally and it set the due date on three tickets

all three tickets are correct. I have not checked if there should have been more tickets but that's ok.

@ilausuch
Copy link
Contributor Author

Don't we should merge this before?

@kalikiana kalikiana merged commit 16a17b9 into os-autoinst:master Nov 30, 2020
ilausuch added a commit to ilausuch/scripts that referenced this pull request Nov 30, 2020
In order to enable an action to the
backlog-set-due-date script introduced
in the PR os-autoinst#44 is needed this workflow
ilausuch added a commit to ilausuch/scripts that referenced this pull request Nov 30, 2020
In order to enable an action to the
backlog-set-due-date script introduced
in the PR os-autoinst#44 is needed this workflow
ilausuch added a commit to ilausuch/scripts that referenced this pull request Dec 1, 2020
In order to enable an action to the
backlog-set-due-date script introduced
in the PR os-autoinst#44 this PR modify the current
workflow for WIP-limits to include also
this script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants