Skip to content

Commit 5fa3460

Browse files
authored
Merge pull request #10 from StackStorm/gha
convert CI from CircleCI to GHA
2 parents 15ec23c + bc0912d commit 5fa3460

File tree

11 files changed

+100
-196
lines changed

11 files changed

+100
-196
lines changed

.circleci/config.yml

Lines changed: 5 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,16 @@
1-
---
21
version: 2
32

43
jobs:
5-
build_and_test_python27:
4+
circleci_is_disabled_job:
65
docker:
7-
- image: circleci/python:2.7
8-
- image: rabbitmq:3
9-
- image: mongo:3.4
10-
11-
working_directory: ~/repo
12-
13-
environment:
14-
VIRTUALENV_DIR: "~/virtualenv"
15-
# Don't install various StackStorm dependencies which are already
16-
# installed by CI again in the various check scripts
17-
ST2_INSTALL_DEPS: "0"
18-
19-
steps:
20-
- checkout
21-
- restore_cache:
22-
key: v1-dependency-cache-py27-{{ checksum "requirements.txt" }}
23-
- run:
24-
name: Download dependencies
25-
command: |
26-
git clone -b master git://github.com/stackstorm-exchange/ci.git ~/ci
27-
~/ci/.circle/dependencies
28-
- run:
29-
name: Run tests (Python 2.7)
30-
command: ~/ci/.circle/test
31-
- save_cache:
32-
key: v1-dependency-cache-py27-{{ checksum "requirements.txt" }}
33-
paths:
34-
- ~/.cache/pip
35-
- ~/.apt-cache
36-
# NOTE: We use virtualenv files from Python 2.7 step in "deploy" job so we
37-
# only persist paths from this job
38-
- persist_to_workspace:
39-
root: /
40-
paths:
41-
- home/circleci/ci
42-
- home/circleci/virtualenv
43-
- tmp/st2
44-
- home/circleci/repo
45-
- home/circleci/.gitconfig
46-
47-
# NOTE: Until we add "python_version" metadata attribute to pack.yaml and
48-
# explicitly call which packs work with Python 3.x, Python 3.x failures are
49-
# not considered fatal
50-
build_and_test_python36:
51-
docker:
52-
- image: circleci/python:3.6
53-
- image: rabbitmq:3
54-
- image: mongo:3.4
55-
56-
working_directory: ~/repo
57-
58-
environment:
59-
VIRTUALENV_DIR: "~/virtualenv"
60-
# Don't install various StackStorm dependencies which are already
61-
# installed by CI again in the various check scripts
62-
ST2_INSTALL_DEPS: "0"
63-
6+
- image: cimg/base:stable
647
steps:
65-
- checkout
66-
- restore_cache:
67-
key: v1-dependency-cache-py36-{{ checksum "requirements.txt" }}
688
- run:
69-
name: Download dependencies
70-
# NOTE: We don't want to use default "-e" option because this means
71-
# step will fail immediately on one of the commands failures and we
72-
# can't intercept the error and cause non-fatal exit in case pack
73-
# doesn't declare support for Python 3
749
shell: /bin/bash
75-
command: |
76-
git clone -b master git://github.com/stackstorm-exchange/ci.git ~/ci
77-
~/ci/.circle/dependencies ; ~/ci/.circle/exit_on_py3_checks $?
78-
- run:
79-
name: Run tests (Python 3.6)
80-
# NOTE: We don't want to use default "-e" option because this means
81-
# step will fail immediately on one of the commands failures and we
82-
# can't intercept the error and cause non-fatal exit in case pack
83-
# doesn't declare support for Python 3
84-
shell: /bin/bash
85-
command: ~/ci/.circle/test ; ~/ci/.circle/exit_on_py3_checks $?
86-
- save_cache:
87-
key: v1-dependency-cache-py36-{{ checksum "requirements.txt" }}
88-
paths:
89-
- ~/.cache/pip
90-
- ~/.apt-cache
91-
92-
deploy:
93-
docker:
94-
- image: circleci/python:2.7
95-
96-
working_directory: ~/repo
97-
98-
environment:
99-
VIRTUALENV_DIR: "~/virtualenv"
100-
101-
steps:
102-
- checkout
103-
- restore_cache:
104-
key: v1-dependency-cache-py27-{{ checksum "requirements.txt" }}
105-
- attach_workspace:
106-
at: /
107-
- run:
108-
name: Install dependencies
109-
command: sudo apt -y install gmic optipng
110-
- run:
111-
# NOTE: We try to retry the script up to 5 times if it fails. The command could fail due
112-
# to the race (e.g. we try to push changes to index, but index has been updated by some
113-
# other pack in the mean time)
114-
name: Update exchange.stackstorm.org
115-
command: ~/ci/.circle/retry_on_failure.sh ~/ci/.circle/deployment
10+
command: echo CircleCI disabled on StackStorm-Exchange
11611

11712
workflows:
11813
version: 2
119-
# Workflow which runs on each push
120-
build_test_deploy_on_push:
121-
jobs:
122-
- build_and_test_python27
123-
- build_and_test_python36
124-
- deploy:
125-
requires:
126-
- build_and_test_python27
127-
filters:
128-
branches:
129-
only: master
130-
build_test_weekly:
14+
circleci_is_disabled:
13115
jobs:
132-
- build_and_test_python27
133-
- build_and_test_python36
134-
# Workflow which runs nightly - note we don't perform deploy job on nightly
135-
# build
136-
triggers:
137-
# Run nightly build for the pack
138-
- schedule:
139-
# NOTE: We run it at 1 am UTC on every Sunday
140-
cron: "0 1 * * 0"
141-
filters:
142-
branches:
143-
only:
144-
- master
16+
- circleci_is_disabled_job
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
schedule:
7+
# NOTE: We run this weekly at 1 am UTC on every Sunday
8+
- cron: '0 1 * * 0'
9+
10+
jobs:
11+
# This is mirrored in the release workflow.
12+
build_and_test:
13+
name: 'Build and Test'
14+
uses: StackStorm-Exchange/ci/.github/workflows/pack-build_and_test.yaml@master
15+
with:
16+
enable-common-libs: true
17+
#apt-cache-version: v0
18+
#py-cache-version: v0

.github/workflows/release.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
# the default branch
7+
- master
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
# This mirrors build_and_test workflow
14+
build_and_test:
15+
name: 'Build and Test'
16+
uses: StackStorm-Exchange/ci/.github/workflows/pack-build_and_test.yaml@master
17+
with:
18+
enable-common-libs: true
19+
#apt-cache-version: v0
20+
#py-cache-version: v0
21+
22+
tag_release:
23+
needs: build_and_test
24+
name: Tag Release
25+
uses: StackStorm-Exchange/ci/.github/workflows/pack-tag_release.yaml@master

actions/assemble_message.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
from st2common.runners.base_action import Action
2424

2525

26-
__all__ = [
27-
'AssembleMessageAction'
28-
]
26+
__all__ = ["AssembleMessageAction"]
2927

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

@@ -36,29 +34,26 @@ def run(self, forum_posts, github_data, template_path):
3634
Build and return rendered text.
3735
"""
3836

39-
template_path = os.path.join(BASE_DIR, '../', template_path)
37+
template_path = os.path.join(BASE_DIR, "../", template_path)
4038
template_path = os.path.abspath(template_path)
4139

42-
with codecs.open(template_path, encoding='utf-8') as fp:
40+
with codecs.open(template_path, encoding="utf-8") as fp:
4341
template_data = fp.read()
4442

45-
template_context = {
46-
'github_data': github_data,
47-
'forum_posts': forum_posts
48-
}
43+
template_context = {"github_data": github_data, "forum_posts": forum_posts}
4944

5045
# Add all information to the template context and render the template
5146
env = Environment(trim_blocks=True, lstrip_blocks=True)
5247
rendered = env.from_string(template_data).render(template_context)
5348

5449
# Remove any Jinja and YAQL expressions to prevent them from trying to be rendered inside
5550
# the workflow
56-
rendered = rendered.replace('{%', '').replace('%}', '')
57-
rendered = rendered.replace('{{', '').replace('}}', '')
58-
rendered = rendered.replace('<%', '').replace('%>', '')
59-
rendered = rendered.replace('\\"', '"').replace("\'", "'")
51+
rendered = rendered.replace("{%", "").replace("%}", "")
52+
rendered = rendered.replace("{{", "").replace("}}", "")
53+
rendered = rendered.replace("<%", "").replace("%>", "")
54+
rendered = rendered.replace('\\"', '"').replace("'", "'")
6055

6156
# Also escape no-valid unicode escape sequences
62-
rendered = rendered.replace('\\', '')
57+
rendered = rendered.replace("\\", "")
6358

6459
return rendered

actions/get_forum_posts.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
from lib.utils import get_timedelta_object_from_delta_arg
1919
from lib.forum_posts import get_forum_posts
2020

21-
__all__ = [
22-
'GetForumPostsAction'
23-
]
21+
__all__ = ["GetForumPostsAction"]
2422

2523

2624
class GetForumPostsAction(Action):

actions/get_github_issues.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@
2121
from lib.utils import get_timedelta_object_from_delta_arg
2222
from lib.github_issues import get_issues_and_prs_for_user
2323

24-
__all__ = [
25-
'GetGithubIssuesAction'
26-
]
24+
__all__ = ["GetGithubIssuesAction"]
2725

2826

2927
class GetGithubIssuesAction(Action):
30-
#def run(self, token, username, delta):
28+
# def run(self, token, username, delta):
3129
def run(self, username, delta, token=None):
3230
time_delta = get_timedelta_object_from_delta_arg(delta)
33-
token = self.config['github_token']
31+
token = self.config["github_token"]
3432
github = Github(token)
3533

3634
# NOTE: We try to retrieve organization first, it that doesnt' work, we fall back to a user
@@ -41,5 +39,7 @@ def run(self, username, delta, token=None):
4139
except UnknownObjectException:
4240
github_user = github.get_user(username)
4341

44-
result = get_issues_and_prs_for_user(github_user=github_user, time_delta=time_delta)
42+
result = get_issues_and_prs_for_user(
43+
github_user=github_user, time_delta=time_delta
44+
)
4545
return result

actions/lib/forum_posts.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
import feedparser
77

8-
__all__ = [
9-
'get_forum_posts'
10-
]
8+
__all__ = ["get_forum_posts"]
119

1210

1311
def get_forum_posts(feed_url, delta=timedelta(days=1, minutes=10)):
@@ -16,27 +14,27 @@ def get_forum_posts(feed_url, delta=timedelta(days=1, minutes=10)):
1614
"""
1715
feed = feedparser.parse(feed_url)
1816

19-
filter_date = (datetime.utcnow() - delta)
17+
filter_date = datetime.utcnow() - delta
2018

2119
result = []
22-
for item in feed['items']:
23-
published_parsed = item.get('published_parsed', None)
20+
for item in feed["items"]:
21+
published_parsed = item.get("published_parsed", None)
2422

2523
if published_parsed:
2624
published_dt = datetime.fromtimestamp(time.mktime(published_parsed))
2725
else:
2826
published_dt = None
2927

3028
if published_dt and (published_dt > filter_date):
31-
item['published_dt'] = published_dt
29+
item["published_dt"] = published_dt
3230
result.append(item)
3331

3432
# Items are sorted in the oldest to newest order
35-
result = sorted(result, key=lambda x: x['published_dt'])
33+
result = sorted(result, key=lambda x: x["published_dt"])
3634

3735
# Remove complex types (datetime, etc)
3836
# TODO: Add escape Jinja filter which is available to Orquesta workflows
39-
keys_to_remove = ['published_dt', 'published_parsed', 'summary', 'summary_detail']
37+
keys_to_remove = ["published_dt", "published_parsed", "summary", "summary_detail"]
4038
for item in result:
4139
for key in keys_to_remove:
4240
if key in item:

0 commit comments

Comments
 (0)