Skip to content

Commit cf093cd

Browse files
Add github actions
1 parent 7a647e2 commit cf093cd

2 files changed

Lines changed: 143 additions & 0 deletions

File tree

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Code Quality & Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
env:
8+
PYTHON_VERSION: "3.11"
9+
10+
jobs:
11+
black:
12+
name: Black Formatting
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: ${{ env.PYTHON_VERSION }}
20+
- name: Cache pip
21+
uses: actions/cache@v4
22+
with:
23+
path: ~/.cache/pip
24+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -r requirements.txt
29+
- name: Check formatting with Black
30+
run: black . --check
31+
32+
isort:
33+
name: Import Sorting
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Set up Python
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ env.PYTHON_VERSION }}
41+
- name: Cache pip
42+
uses: actions/cache@v4
43+
with:
44+
path: ~/.cache/pip
45+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
46+
- name: Install dependencies
47+
run: |
48+
python -m pip install --upgrade pip
49+
pip install isort
50+
- name: Sort imports with isort
51+
run: isort . --check-only --diff
52+
53+
flake8:
54+
name: Flake8 Linting
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v4
58+
- name: Set up Python
59+
uses: actions/setup-python@v5
60+
with:
61+
python-version: ${{ env.PYTHON_VERSION }}
62+
- name: Cache pip
63+
uses: actions/cache@v4
64+
with:
65+
path: ~/.cache/pip
66+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
67+
- name: Install dependencies
68+
run: |
69+
python -m pip install --upgrade pip
70+
pip install flake8
71+
- name: Lint with flake8
72+
run: flake8 .
73+
74+
mypy:
75+
name: MyPy Type Checking
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/checkout@v4
79+
- name: Set up Python
80+
uses: actions/setup-python@v5
81+
with:
82+
python-version: ${{ env.PYTHON_VERSION }}
83+
- name: Cache pip
84+
uses: actions/cache@v4
85+
with:
86+
path: ~/.cache/pip
87+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
88+
- name: Install dependencies
89+
run: |
90+
python -m pip install --upgrade pip
91+
pip install -r requirements.txt
92+
- name: Type check with mypy
93+
run: mypy . --check-untyped-defs
94+
95+
tests:
96+
name: Run Tests
97+
runs-on: ubuntu-latest
98+
steps:
99+
- uses: actions/checkout@v4
100+
- name: Set up Python
101+
uses: actions/setup-python@v5
102+
with:
103+
python-version: ${{ env.PYTHON_VERSION }}
104+
- name: Cache pip
105+
uses: actions/cache@v4
106+
with:
107+
path: ~/.cache/pip
108+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
109+
- name: Install dependencies
110+
run: |
111+
python -m pip install --upgrade pip
112+
pip install -r requirements.txt
113+
pip install coverage
114+
- name: Run tests with coverage
115+
run: |
116+
export $(cat .env.dev.example | xargs)
117+
coverage run -m pytest tests/ -v
118+
coverage xml
119+
coverage report
120+
- name: Upload coverage reports
121+
uses: codecov/codecov-action@v3
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Notify Slack on Merge to Main
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
9+
jobs:
10+
notify:
11+
runs-on: ubuntu-latest
12+
if: github.event.pull_request.merged == true
13+
steps:
14+
- name: Send notification to Slack
15+
uses: slackapi/slack-github-action@v1.24.0
16+
with:
17+
payload: |
18+
{
19+
"text": ${{ toJSON(format('[Codeplain Client] PR <{0}|#{1}: {2}> was merged to main by `{3}`.', github.event.pull_request.html_url, github.event.pull_request.number, github.event.pull_request.title, github.actor)) }}
20+
}
21+
env:
22+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)