Skip to content

Commit b692957

Browse files
authored
Merge pull request #69 from networktocode/dga-github-action
Convert Travis to GHA
2 parents bf4c8c9 + 28c4032 commit b692957

File tree

3 files changed

+189
-66
lines changed

3 files changed

+189
-66
lines changed

.github/workflows/ci.yml

+186
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
---
2+
name: "CI"
3+
on:
4+
- "push"
5+
- "pull_request"
6+
jobs:
7+
black:
8+
runs-on: "ubuntu-20.04"
9+
env:
10+
INVOKE_LOCAL: "True"
11+
steps:
12+
- name: "Check out repository code"
13+
uses: "actions/checkout@v2"
14+
- name: "Setup environment"
15+
uses: "networktocode/gh-action-setup-poetry-environment@v1"
16+
- name: "Linting: black"
17+
run: "poetry run invoke black"
18+
bandit:
19+
runs-on: "ubuntu-20.04"
20+
env:
21+
INVOKE_LOCAL: "True"
22+
steps:
23+
- name: "Check out repository code"
24+
uses: "actions/checkout@v2"
25+
- name: "Setup environment"
26+
uses: "networktocode/gh-action-setup-poetry-environment@v1"
27+
- name: "Linting: bandit"
28+
run: "poetry run invoke bandit"
29+
needs:
30+
- "black"
31+
pydocstyle:
32+
runs-on: "ubuntu-20.04"
33+
env:
34+
INVOKE_LOCAL: "True"
35+
steps:
36+
- name: "Check out repository code"
37+
uses: "actions/checkout@v2"
38+
- name: "Setup environment"
39+
uses: "networktocode/gh-action-setup-poetry-environment@v1"
40+
- name: "Linting: pydocstyle"
41+
run: "poetry run invoke pydocstyle"
42+
needs:
43+
- "black"
44+
flake8:
45+
runs-on: "ubuntu-20.04"
46+
env:
47+
INVOKE_LOCAL: "True"
48+
steps:
49+
- name: "Check out repository code"
50+
uses: "actions/checkout@v2"
51+
- name: "Setup environment"
52+
uses: "networktocode/gh-action-setup-poetry-environment@v1"
53+
- name: "Linting: flake8"
54+
run: "poetry run invoke flake8"
55+
needs:
56+
- "black"
57+
mypy:
58+
runs-on: "ubuntu-20.04"
59+
env:
60+
INVOKE_LOCAL: "True"
61+
steps:
62+
- name: "Check out repository code"
63+
uses: "actions/checkout@v2"
64+
- name: "Setup environment"
65+
uses: "networktocode/gh-action-setup-poetry-environment@v1"
66+
- name: "Linting: flake8"
67+
run: "poetry run invoke mypy"
68+
needs:
69+
- "black"
70+
yamllint:
71+
runs-on: "ubuntu-20.04"
72+
env:
73+
INVOKE_LOCAL: "True"
74+
steps:
75+
- name: "Check out repository code"
76+
uses: "actions/checkout@v2"
77+
- name: "Setup environment"
78+
uses: "networktocode/gh-action-setup-poetry-environment@v1"
79+
- name: "Linting: yamllint"
80+
run: "poetry run invoke yamllint"
81+
needs:
82+
- "black"
83+
build:
84+
runs-on: "ubuntu-20.04"
85+
steps:
86+
- name: "Check out repository code"
87+
uses: "actions/checkout@v2"
88+
- name: "Setup environment"
89+
uses: "networktocode/gh-action-setup-poetry-environment@v1"
90+
- name: "Build Container"
91+
run: "poetry run invoke build"
92+
needs:
93+
- "bandit"
94+
- "pydocstyle"
95+
- "flake8"
96+
- "yamllint"
97+
- "mypy"
98+
pylint:
99+
runs-on: "ubuntu-20.04"
100+
steps:
101+
- name: "Check out repository code"
102+
uses: "actions/checkout@v2"
103+
- name: "Setup environment"
104+
uses: "networktocode/gh-action-setup-poetry-environment@v1"
105+
- name: "Build Container"
106+
run: "poetry run invoke build"
107+
- name: "Linting: Pylint"
108+
run: "poetry run invoke pylint"
109+
needs:
110+
- "build"
111+
unittest:
112+
strategy:
113+
fail-fast: true
114+
matrix:
115+
python-version: ["3.6", "3.7", "3.8", "3.9"]
116+
runs-on: "ubuntu-20.04"
117+
env:
118+
PYTHON_VER: "${{ matrix.python-version }}"
119+
steps:
120+
- name: "Check out repository code"
121+
uses: "actions/checkout@v2"
122+
- name: "Setup environment"
123+
uses: "networktocode/gh-action-setup-poetry-environment@v2"
124+
with:
125+
python-version: "${{ matrix.python-version }}"
126+
- name: "Run poetry Install"
127+
run: "poetry install"
128+
- name: "Run Tests"
129+
run: "poetry run invoke pytest --local"
130+
needs:
131+
- "pylint"
132+
publish_gh:
133+
name: "Publish to GitHub"
134+
runs-on: "ubuntu-20.04"
135+
if: "startsWith(github.ref, 'refs/tags/v')"
136+
steps:
137+
- name: "Check out repository code"
138+
uses: "actions/checkout@v2"
139+
- name: "Set up Python"
140+
uses: "actions/setup-python@v2"
141+
with:
142+
python-version: "3.9"
143+
- name: "Install Python Packages"
144+
run: "pip install poetry"
145+
- name: "Set env"
146+
run: "echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
147+
- name: "Run Poetry Version"
148+
run: "poetry version $RELEASE_VERSION"
149+
- name: "Run Poetry Build"
150+
run: "poetry build"
151+
- name: "Upload binaries to release"
152+
uses: "svenstaro/upload-release-action@v2"
153+
with:
154+
repo_token: "${{ secrets.NTC_GITHUB_TOKEN }}"
155+
file: "dist/*"
156+
tag: "${{ github.ref }}"
157+
overwrite: true
158+
file_glob: true
159+
needs:
160+
- "unittest"
161+
publish_pypi:
162+
name: "Push Package to PyPI"
163+
runs-on: "ubuntu-20.04"
164+
if: "startsWith(github.ref, 'refs/tags/v')"
165+
steps:
166+
- name: "Check out repository code"
167+
uses: "actions/checkout@v2"
168+
- name: "Set up Python"
169+
uses: "actions/setup-python@v2"
170+
with:
171+
python-version: "3.9"
172+
- name: "Install Python Packages"
173+
run: "pip install poetry"
174+
- name: "Set env"
175+
run: "echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
176+
- name: "Run Poetry Version"
177+
run: "poetry version $RELEASE_VERSION"
178+
- name: "Run Poetry Build"
179+
run: "poetry build"
180+
- name: "Push to PyPI"
181+
uses: "pypa/gh-action-pypi-publish@release/v1"
182+
with:
183+
user: "__token__"
184+
password: "${{ secrets.PYPI_API_TOKEN }}"
185+
needs:
186+
- "unittest"

.travis.yml

-63
This file was deleted.

tasks.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def run_cmd(context, exec_cmd, name=NAME, image_ver=IMAGE_VER, local=INVOKE_LOCA
8282

8383

8484
@task
85-
def build_image(
85+
def build(
8686
context, name=NAME, python_ver=PYTHON_VER, image_ver=IMAGE_VER, nocache=False, forcerm=False
8787
): # pylint: disable=too-many-arguments
8888
"""This will build an image with the provided name and python version.
@@ -123,7 +123,7 @@ def clean_image(context, name=NAME, image_ver=IMAGE_VER):
123123

124124

125125
@task
126-
def rebuild_image(context, name=NAME, python_ver=PYTHON_VER, image_ver=IMAGE_VER):
126+
def rebuild(context, name=NAME, python_ver=PYTHON_VER, image_ver=IMAGE_VER):
127127
"""This will clean the image and then rebuild image without using cache.
128128
129129
Args:
@@ -133,7 +133,7 @@ def rebuild_image(context, name=NAME, python_ver=PYTHON_VER, image_ver=IMAGE_VER
133133
image_ver (str): Define image version
134134
"""
135135
clean_image(context, name, image_ver)
136-
build_image(context, name, python_ver, image_ver)
136+
build(context, name, python_ver, image_ver)
137137

138138

139139
@task

0 commit comments

Comments
 (0)