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

feat: set Asana to milestone based on PR milestone #44

Merged
merged 27 commits into from
Sep 6, 2022

Conversation

federico-po
Copy link
Contributor

@federico-po federico-po commented Aug 24, 2022

Summary

This PR sets the milestone in the asana tasks' linked in the PR.

Once a PR has at least one Asana task linked, and a milestone is set to the PR, the automation will run and will try to set the same milestone in the task that in the PR.

e.g. (covered by tests):

  1. A PR with no Asana task is set with a new milestone -> the automation does nothing.
  2. A PR with one Asana task linked is set with a new milestone -> the automation will search for the milestone in Asana and will set the milestone in the task.
  3. (same as above) but the milestone is not found in Asana -> does nothing.
  4. Multiple tasks are found in the PR and a milestone is set -> for all of them try to set the milestone
  5. A PR has one or multiple tasks linked, a milestone is set but the tasks already have a milestone set -> the automation overrides the milestone.

Note:
The automation will assume that:

  • Milestone field in Asana is interpreted by the automation by Target Release Version field.
    • This can be overwritten by setting asana_milestone_field_name in the GitHub action.
  • Milestones in GH are highlighted by numbers (e.g. v1.0.0 === V1.0.0 === foo1.0.0)
    • This can be overwritten by setting gh_milestone_regex in the GH action.
  • Milestones in Asana are highlighted by numbers (e.g. v1.0.0 === V1.0.0 === foo1.0.0)
    • This can be overwritten by setting asana_milestone_regex in the GH action.

Closes: this Asana task.

Test Plan

  • Checkout this branch locally and create a new branch
  • Add a dummy change in asana-actions-workflow (a console.log for example)
  • Commit and push changes
  • Create an asana task for testing purposes
  • Create a PR from your branch to federico/link-asana-milestone
    • Copy-paste the asana task link after the Closes: prefix.
  • After your PR is created, wait for a few seconds and the automation should have:
    • Pushed a comment in the task with the PR
    • Updated PR description with the comment
  • Assign a milestone to the PR
    • Ensure the milestone matches with asana task (e.g. v22.08.11)
  • Wait for a few seconds and the task should update with the milestone
  • Finally, merge the PR and the task should mark as completed.

DEMO

Further Comments

Ok GH actions are a bit tricky. Milestoned and Demilestoned are triggered at the same time when you switch from Milestone X to Y, so they get overwritten each other and usually the tasks end up with null (empty milestone). I added a delay of 15 secs for milestoning the task. This ensures that milestoning tasks await for some secs until demilestone happened (in case it's a re-milestoning)

@federico-po federico-po force-pushed the federico/link-asana-milestone branch from 0987417 to 7113822 Compare August 24, 2022 03:41
@federico-po federico-po force-pushed the federico/link-asana-milestone branch from 08d8ed9 to cbef573 Compare August 24, 2022 03:45
@federico-po federico-po force-pushed the federico/link-asana-milestone branch from 8a95be3 to e0e7c1f Compare August 24, 2022 03:49
@federico-po federico-po requested a review from dooglio August 24, 2022 03:53
@federico-po federico-po self-assigned this Aug 24, 2022
@federico-po federico-po force-pushed the federico/link-asana-milestone branch 2 times, most recently from 1999f82 to 8d7ec84 Compare August 24, 2022 19:17
.github/workflows/asana-link.yml Show resolved Hide resolved
asana-actions-workflow.js Outdated Show resolved Hide resolved
@federico-po
Copy link
Contributor Author

@dooglio Thanks for the suggestion, amigo! Updated and tested.

I created a release 4.3.1 for this feature, which is a pre-release (not yet published to the market place).

@dooglio
Copy link

dooglio commented Aug 26, 2022

@federico-po I'm interested to see how it goes in testing!

@federico-po
Copy link
Contributor Author

Definitely! Feel free to follow the test plan and also I added a DEMO video (originally created for Josh so please skip the first 2 mins 😝 )

@dooglio
Copy link

dooglio commented Sep 2, 2022

See this PR:
#51

federico-po and others added 4 commits September 5, 2022 12:24
…#51)

* chore: remove node_modules
* build: add @vercel/ncc for packaging
* build: add .nvmrc
* build: move supporting js files into `src`
* build: add `build` step and package dist release
* build: switch to node16
* build: add husky pre-commit hook to run build
Co-authored-by: Federico Ponce de Leon <[email protected]>
Copy link

@dooglio dooglio left a comment

Choose a reason for hiding this comment

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

tACK

@dooglio dooglio modified the milestone: v22.08.11 Sep 5, 2022
@federico-po federico-po merged commit 6b8f8fd into main Sep 6, 2022
@federico-po federico-po deleted the federico/link-asana-milestone branch September 6, 2022 00:41
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.

2 participants