Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7dd4654
Add new action which retrieves new forum posts from
Kami Jan 31, 2019
8c3a41d
Update st2 rule to include forum posts.
Kami Jan 31, 2019
3c24fdc
Use value from config.
Kami Jan 31, 2019
efbd9b5
Read default message template from file.
Kami Jan 31, 2019
c0a9f40
body is not required since we use a default value inside an action.
Kami Jan 31, 2019
6f99867
Fix unicode issue.
Kami Jan 31, 2019
82fd7da
Fix syntax.
Kami Jan 31, 2019
71ba893
Fix syntax.
Kami Jan 31, 2019
55e2b52
Update action and workflow so we have a single action which retrieves
Kami Jan 31, 2019
e893f89
Fix syntax error.
Kami Jan 31, 2019
78ad180
Remove debug code.
Kami Jan 31, 2019
2ee87ef
Fix workflow, change rule name.
Kami Jan 31, 2019
9c0c058
Update affected code, add some logging.
Kami Jan 31, 2019
18a69b1
Use unicode bullet, also include stats for StackStorm-Exchange org.
Kami Jan 31, 2019
ef7ba49
Update code so it works with templates which contain unicode.
Kami Jan 31, 2019
dfd6c0f
Update formatting.
Kami Jan 31, 2019
8136e6b
Initial split of one massive actions in three more smaller and re-usable
Kami Feb 4, 2019
121c6aa
More progress on new workflow.
Kami Feb 4, 2019
a193154
Also remove published_parsed key.
Kami Feb 4, 2019
8495a19
Add quotes, fix signature.
Kami Feb 4, 2019
f390d9b
Finish the workflow.
Kami Feb 4, 2019
e230308
Update rules, rename action.
Kami Feb 4, 2019
d2480bd
Fix message formatting in the Jinja template.
Kami Feb 4, 2019
f6975af
For explicitness sake, change config option name from token to
Kami Feb 5, 2019
eaa869c
Update template.
Kami Feb 5, 2019
e917901
Use temporary workaround until we deploy new version of st2 to cicd.
Kami Feb 5, 2019
64290f4
Temporary workaround until new version of st2 is deployed to cicd.
Kami Feb 5, 2019
51b2e86
Bump pack version.
Kami Feb 5, 2019
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
53 changes: 53 additions & 0 deletions actions/assemble_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import codecs


from jinja2 import Environment

from st2common.runners.base_action import Action


__all__ = [
'AssembleMessageAction'
]

BASE_DIR = os.path.dirname(os.path.abspath(__file__))


class AssembleMessageAction(Action):
def run(self, forum_posts, github_data, template_path):
"""
Build and return rendered text.
"""

template_path = os.path.join(BASE_DIR, '../', template_path)
template_path = os.path.abspath(template_path)

with codecs.open(template_path, encoding='utf-8') as fp:
template_data = fp.read()

template_context = {
'github_data': github_data,
'forum_posts': forum_posts
}

# Add all information to the template context and render the template
env = Environment(trim_blocks=True, lstrip_blocks=True)
rendered = env.from_string(template_data).render(template_context)
return rendered
20 changes: 20 additions & 0 deletions actions/assemble_message.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: assemble_message
pack: st2community
description: Retrieve various daily summary (new issues and PRs in all the repos, new forum posts, etc.) and assemble summary text.
runner_type: python-script
entry_point: assemble_message.py
enabled: true
parameters:
forum_posts:
type: array
items:
type: "object"
github_data:
type: array
items:
type: "object"
template_path:
description: "Path to the Jinja template file for the Slack message (relative to the pack directory)."
type: "string"
default: "etc/message_template.j2"
23 changes: 0 additions & 23 deletions actions/build-and-message.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions actions/build-text.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions actions/build_text.py

This file was deleted.

30 changes: 30 additions & 0 deletions actions/get_forum_posts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from st2common.runners.base_action import Action

from lib.utils import get_timedelta_object_from_delta_arg
from lib.forum_posts import get_forum_posts

__all__ = [
'GetForumPostsAction'
]


class GetForumPostsAction(Action):
def run(self, feed_url, delta):
time_delta = get_timedelta_object_from_delta_arg(delta)
result = get_forum_posts(feed_url=feed_url, delta=time_delta)
return result
23 changes: 23 additions & 0 deletions actions/get_forum_posts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: get_forum_posts
pack: st2community
description: Retrieve recent forum posts.
runner_type: python-script
entry_point: get_forum_posts.py
enabled: true
parameters:
feed_url:
description: "Forum RSS feed URL."
type: string
required: true
# TODO: Temporary workaround until version with fix in https://github.com/StackStorm/st2/pull/4531
# is deployed to cicd
default: "https://forum.stackstorm.com/latest.rss"
#default: "{{ config_context.forum_feed_url }}"
delta:
description: "Time period to retrieve forum posts for."
type: object
required: true
default:
days: 1
minutes: 10
36 changes: 36 additions & 0 deletions actions/get_github_issues.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from github import Github

from st2common.runners.base_action import Action

from lib.utils import get_timedelta_object_from_delta_arg
from lib.github_issues import get_issues_and_prs_for_user

__all__ = [
'GetGithubIssuesAction'
]


class GetGithubIssuesAction(Action):
#def run(self, token, username, delta):
def run(self, username, delta, token=None):
time_delta = get_timedelta_object_from_delta_arg(delta)
token = self.config['github_token']
github = Github(token)
github_user = github.get_user(username)
result = get_issues_and_prs_for_user(github_user=github_user, time_delta=time_delta)
return result
26 changes: 26 additions & 0 deletions actions/get_github_issues.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: get_github_issues
pack: st2community
description: Retrieve recent Github issues and pull requests.
runner_type: python-script
entry_point: get_github_issues.py
enabled: true
parameters:
token:
description: "Github token used to authenticate."
type: string
secret: true
# TODO: Uncomment when new version of st2 is deployed to cicd
#required: false
#default: "{{ config_context.github_token }}"
username:
description: "Username of the Github user / organization to retrieve issues for."
type: string
required: true
delta:
description: "Time period to retrieve issuesfor."
type: object
required: true
default:
days: 1
minutes: 10
84 changes: 0 additions & 84 deletions actions/lib/community.py

This file was deleted.

Loading