From 3c1acf3d9cd0b4642399034eb1801e4beededc76 Mon Sep 17 00:00:00 2001 From: Jonas Depoix Date: Mon, 11 Nov 2024 11:22:21 +0100 Subject: [PATCH] added GitHub Action CI for formatting, linting and testing --- .github/workflows/ci.yml | 46 ++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 10 +++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..65d0a18 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index ff53bf9..069c50f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,20 +39,30 @@ youtube_transcript_api = "youtube_transcript_api.__main__:main" [tool.poe.tasks] 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" format = "ruff format youtube_transcript_api" +ci-format = "ruff format youtube_transcript_api --check" lint = "ruff check youtube_transcript_api" [tool.poetry.dependencies] python = ">=3.8,<3.13" requests = "*" +[tool.poetry.group.test] +optional = true + [tool.poetry.group.test.dependencies] pytest = "^8.3.3" coverage = "^7.6.1" mock = "^5.1.0" httpretty = "^1.1.4" coveralls = "^4.0.1" + +[tool.poetry.group.dev] +optional = true + +[tool.poetry.group.dev.dependencies] ruff = "^0.6.8" [tool.coverage.run]