Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit ca4cac4

Browse files
committed
Add check code action
1 parent cf7f3ec commit ca4cac4

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

.github/workflows/check_code.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Check Code
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
static-analysis:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
with:
11+
fetch-depth: 0
12+
- name: Set up Python 3.9
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: 3.9
16+
17+
- uses: snok/[email protected]
18+
with:
19+
virtualenvs-create: true
20+
virtualenvs-in-project: true
21+
22+
- name: Cache Dependencies
23+
uses: actions/cache@v2
24+
id: cache-dependencies
25+
with:
26+
path: .venv
27+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
28+
29+
- name: Install Dependencies if cache doesn't hit
30+
if: steps.cache-dependencies.cache-hit != 'true'
31+
run: poetry install
32+
33+
- name: Check Code Styles
34+
run: poetry run invoke check-code-style
35+
36+
- name: Check Types
37+
run: poetry run invoke check-types

tasks.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,41 @@
1+
# pyright: reportUnknownMemberType=false
2+
13
import toml
4+
from colorama import Fore
5+
from colorama import init as init_colorama
26
from invoke import Context, task
37
from invoke.exceptions import UnexpectedExit
48

59
import monkey_patch_invoke as _
610

711

12+
@task
13+
def check_code_style(context: Context) -> None:
14+
"""Runs static analysis."""
15+
PROJECT_PATH = 'twitter_video_tools'
16+
init_colorama()
17+
18+
print(f'{Fore.MAGENTA}==========Check Code Styles with `yapf`=========={Fore.RESET}')
19+
context.run(f'yapf --diff --recursive --parallel {PROJECT_PATH}', pty=True)
20+
print(f'{Fore.GREEN}Yapf: Success{Fore.RESET}')
21+
22+
print(f'\n{Fore.MAGENTA}==========Check Code Styles with `pylint`=========={Fore.GREEN}')
23+
context.run(f'pylint {PROJECT_PATH}', pty=True)
24+
25+
26+
@task
27+
def check_types(context: Context) -> None:
28+
"""Runs static analysis."""
29+
PROJECT_PATH = 'twitter_video_tools'
30+
init_colorama()
31+
32+
print(f'{Fore.CYAN}==========Check typings with `pyright`=========={Fore.RESET}')
33+
context.run(f'pyright {PROJECT_PATH}', pty=True)
34+
35+
print(f'\n{Fore.CYAN}==========Check typings with `mypy`=========={Fore.RESET}')
36+
context.run(f'mypy {PROJECT_PATH}', pty=True)
37+
38+
839
@task
940
def test(context: Context) -> None:
1041
"""Run tests."""

0 commit comments

Comments
 (0)