added GitHub Action CI for formatting, linting and testing

This commit is contained in:
Jonas Depoix 2024-11-11 11:22:21 +01:00
parent d35cb58cce
commit 3c1acf3d9c
2 changed files with 56 additions and 0 deletions

46
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,46 @@
name: CI
on:
push:
branches: [ "master" ]
pull_request:
jobs:
static-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9
- name: Install dependencies
run: |
pip install poetry poe
poetry install --only dev
- name: Format
run: poe ci-format
- name: Lint
run: poe lint
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install poetry poe
poetry install --with test
- name: Run tests
run: |
poe ci-test

View File

@ -39,20 +39,30 @@ youtube_transcript_api = "youtube_transcript_api.__main__:main"
[tool.poe.tasks] [tool.poe.tasks]
test = "pytest youtube_transcript_api" test = "pytest youtube_transcript_api"
ci-test.shell = "coverage run -m unittest discover && coverage report -m --fail-under=100"
coverage.shell = "coverage run -m unittest discover && coverage report -m" coverage.shell = "coverage run -m unittest discover && coverage report -m"
format = "ruff format youtube_transcript_api" format = "ruff format youtube_transcript_api"
ci-format = "ruff format youtube_transcript_api --check"
lint = "ruff check youtube_transcript_api" lint = "ruff check youtube_transcript_api"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = ">=3.8,<3.13" python = ">=3.8,<3.13"
requests = "*" requests = "*"
[tool.poetry.group.test]
optional = true
[tool.poetry.group.test.dependencies] [tool.poetry.group.test.dependencies]
pytest = "^8.3.3" pytest = "^8.3.3"
coverage = "^7.6.1" coverage = "^7.6.1"
mock = "^5.1.0" mock = "^5.1.0"
httpretty = "^1.1.4" httpretty = "^1.1.4"
coveralls = "^4.0.1" coveralls = "^4.0.1"
[tool.poetry.group.dev]
optional = true
[tool.poetry.group.dev.dependencies]
ruff = "^0.6.8" ruff = "^0.6.8"
[tool.coverage.run] [tool.coverage.run]