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

Synchronize some Tracker story edits back to the linked GitHub issue #1

Merged
merged 4 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add a Tracker webhook listener
- This commit is work in progress towards reflecting some Tracker
  story edits back to the linked GitHub issue.
- Refactor the tracker import endpoint into its own package.
- Add a way to pass GitHub and Tracker API tokens into the app
  via the ytt templates.
- Add a new endpoint which implements the Tracker webhook spec.
- When the new Tracker webhook listener is called, check to see
  if any of the incoming story change events are stories that
  are linked to a GitHub issue.
- Includes unit tests for the new Tracker webhook.
  • Loading branch information
cfryanr committed Jan 27, 2021
commit 91e9069f092005ec3c7994af1c47463eadd95abc
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ This field contains a convenient hyperlink to open the linked GitHub issue
in your browser.

The user story can then be edited as usual.
Changes to the user story are not reflected in the corresponding GitHub issue.
Additional changes to the GitHub issue are not reflected in the Tracker user story.
Certain changes to the user story will be reflected back to the corresponding GitHub issue.

If the user story is deleted, and the integration panel is refreshed,
then the issue will reappear in the integration panel.
Expand Down Expand Up @@ -106,7 +107,8 @@ scope of this document.
curl https://issues2stories.your-zone.com/tracker_import
```

1. Add the integration to the Tracker project. Integrations -> Add an Integration -> Other.
1. Add the integration to the Tracker project.
In the project, navigate to "Integrations -> Add an Integration -> Other".
Use the following settings:

- Project: Choose the project
Expand All @@ -117,6 +119,12 @@ scope of this document.
- Import API URL: `https://issues2stories.your-zone.com/tracker_import`
- Enabled: Checked

1. Add the webhook to the Tracker project.
In the project, navigate to "More -> Webhooks".
Use the following settings to add a webhook:

- URL: https://issues2stories.your-zone.com/tracker_activity

1. In your Tracker project, click on "issues2stories" (with the jigsaw puzzle icon)
button in the left-hand side navigation. The panel will appear and should show
a list of all open issues from your GitHub repository.
22 changes: 22 additions & 0 deletions deploy/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ metadata:
labels:
name: issues2stories
---
apiVersion: v1
kind: Secret
metadata:
name: api-tokens
namespace: issues2stories
labels:
app: issues2stories
type: Opaque
stringData:
tracker: #@ data.values.tracker_token
github: #@ data.values.github_token
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -33,6 +45,16 @@ spec:
value: #@ data.values.github_org
- name: GITHUB_REPO
value: #@ data.values.github_repo
- name: TRACKER_API_TOKEN
valueFrom:
secretKeyRef:
name: api-tokens
key: tracker
- name: GITHUB_API_TOKEN
valueFrom:
secretKeyRef:
name: api-tokens
key: github
---
apiVersion: v1
kind: Service
Expand Down
15 changes: 15 additions & 0 deletions deploy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@ domain_name:

#! e.g. "issues2stories-external-load-balancer-ingress-ip"
ingress_global_static_ip_name:

#! Tracker API token. The user account who owns this token must
#! have at least read-only access to your Tracker project.
#! The webhook will use this token whenever it hears about
#! a changed Tracker user story to call the Tracker API to get
#! more details about the story.
#! e.g. "1c11aef11aef1f11111111111111111111111111"
tracker_token:

#! GitHub personal access token. The user account who owns this token must
#! have write access to your GitHub project, and the token must be created
#! with at least "full repo" access permission. This token will be used to
#! make API calls to read and edit GitHub issues in your GitHub project.
#! e.g. "1c11aef11aef1f11111111111111111111111111"
github_token:
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
module issues2stories

go 1.15

require (
github.com/stretchr/testify v1.6.1
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"kind": "story_create_activity",
"guid": "2453999_5703",
"project_version": 5703,
"message": "Ryan Richard added this feature",
"highlight": "added",
"changes": [
{
"kind": "story",
"change_type": "create",
"id": 176650922,
"new_values": {
"id": 176650922,
"project_id": 2453999,
"name": "Test story... please ignore",
"story_type": "feature",
"current_state": "unscheduled",
"requested_by_id": 3344177,
"owner_ids": [
],
"label_ids": [
],
"follower_ids": [
],
"created_at": 1611623067000,
"updated_at": 1611623067000,
"before_id": 176518978,
"after_id": 175402743,
"blocked_story_ids": [
],
"labels": [
]
},
"name": "Test story... please ignore",
"story_type": "feature"
}
],
"primary_resources": [
{
"kind": "story",
"id": 176650922,
"name": "Test story... please ignore",
"story_type": "feature",
"url": "https://www.pivotaltracker.com/story/show/176650922"
}
],
"secondary_resources": [
],
"project": {
"kind": "project",
"id": 2453999,
"name": "Example Project"
},
"performed_by": {
"kind": "person",
"id": 3344177,
"name": "Ryan Richard",
"initials": "RR"
},
"occurred_at": 1611623067000
}
140 changes: 140 additions & 0 deletions internal/trackeractivity/testdata/edit_add_label_to_story.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"kind": "story_update_activity",
"guid": "2453999_5710",
"project_version": 5710,
"message": "Ryan Richard edited this bug",
"highlight": "edited",
"changes": [
{
"kind": "label",
"change_type": "update",
"id": 22689375,
"original_values": {
"counts": {
"number_of_zero_point_stories_by_state": {
"accepted": 1,
"started": 0,
"finished": 0,
"unstarted": 0,
"planned": 0,
"delivered": 0,
"unscheduled": 0,
"rejected": 0,
"kind": "counts_by_story_state"
},
"sum_of_story_estimates_by_state": {
"accepted": 0,
"started": 0,
"finished": 0,
"unstarted": 0,
"planned": 0,
"delivered": 0,
"unscheduled": 0,
"rejected": 0,
"kind": "counts_by_story_state"
},
"number_of_stories_by_state": {
"accepted": 1,
"started": 0,
"finished": 0,
"unstarted": 0,
"planned": 0,
"delivered": 0,
"unscheduled": 0,
"rejected": 0,
"kind": "counts_by_story_state"
},
"kind": "story_counts"
}
},
"new_values": {
"counts": {
"number_of_zero_point_stories_by_state": {
"accepted": 1,
"started": 0,
"finished": 0,
"unstarted": 0,
"planned": 0,
"delivered": 0,
"unscheduled": 1,
"rejected": 0,
"kind": "counts_by_story_state"
},
"sum_of_story_estimates_by_state": {
"accepted": 0,
"started": 0,
"finished": 0,
"unstarted": 0,
"planned": 0,
"delivered": 0,
"unscheduled": 0,
"rejected": 0,
"kind": "counts_by_story_state"
},
"number_of_stories_by_state": {
"accepted": 1,
"started": 0,
"finished": 0,
"unstarted": 0,
"planned": 0,
"delivered": 0,
"unscheduled": 1,
"rejected": 0,
"kind": "counts_by_story_state"
},
"kind": "story_counts"
}
},
"name": "good-first-issue"
},
{
"kind": "story",
"change_type": "update",
"id": 176650922,
"original_values": {
"label_ids": [

],
"updated_at": 1611623762000,
"labels": [

]
},
"new_values": {
"label_ids": [
22689375
],
"updated_at": 1611623836000,
"labels": [
"good-first-issue"
]
},
"name": "Test story... please ignore",
"story_type": "bug"
}
],
"primary_resources": [
{
"kind": "story",
"id": 176650922,
"name": "Test story... please ignore",
"story_type": "bug",
"url": "https://www.pivotaltracker.com/story/show/176650922"
}
],
"secondary_resources": [

],
"project": {
"kind": "project",
"id": 2453999,
"name": "Example Project"
},
"performed_by": {
"kind": "person",
"id": 3344177,
"name": "Ryan Richard",
"initials": "RR"
},
"occurred_at": 1611623836000
}
Loading