Skip to content

Add GitHub Actions workflow for Python package#154

Open
AKB0700 wants to merge 2 commits intoDeepLcom:mainfrom
AKB0700:main
Open

Add GitHub Actions workflow for Python package#154
AKB0700 wants to merge 2 commits intoDeepLcom:mainfrom
AKB0700:main

Conversation

@AKB0700
Copy link

@AKB0700 AKB0700 commented Mar 2, 2026

This workflow installs Python dependencies, runs tests, and lints code with multiple Python versions.

This workflow installs Python dependencies, runs tests, and lints code with multiple Python versions.
Copilot AI review requested due to automatic review settings March 2, 2026 19:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new GitHub Actions workflow intended to run linting and tests for the Python package across multiple Python versions on pushes and pull requests to main.

Changes:

  • Introduces .github/workflows/python-package.yml with a Python version matrix (3.9–3.11).
  • Adds steps to install dependencies, run flake8, and run pytest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +35 to +37
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint command runs flake8 ., which will lint everything in the repo (including examples/, docs, etc.) and may diverge from existing CI behavior. The established workflow (.github/workflows/run_ci.yml) runs poetry run flake8 deepl tests; consider matching that scope here to avoid unexpected failures/noise.

Suggested change
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 deepl tests --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 deepl tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +10
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow triggers on the same events/branches as the existing .github/workflows/run_ci.yml workflow, so it will run in parallel and potentially duplicate work/CI time. Consider consolidating these checks into the existing workflow (e.g., add a pytest job there) or adjust triggers/job naming so responsibilities are clearly separated.

Suggested change
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +40
- 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: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

steps: list items are not indented under steps: (the - uses: lines are at the same indentation level). This makes the workflow YAML invalid and GitHub Actions will fail to parse it. Indent the step entries so they are children of steps:.

Suggested change
- 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: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- 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: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +31
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependency installation is effectively a no-op for this repo: it only installs flake8/pytest and then conditionally installs requirements.txt, but this repository uses pyproject.toml/poetry.lock (and has no requirements.txt). As a result, imports like requests won’t be installed and the pytest step is likely to fail. Consider installing via Poetry (consistent with .github/workflows/run_ci.yml) or otherwise installing the package + locked dependencies before lint/test.

Suggested change
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install poetry
poetry config virtualenvs.create false
poetry install --no-interaction --no-root
python -m pip install flake8 pytest

Copilot uses AI. Check for mistakes.
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses actions/setup-python@v3, which is quite old and may rely on deprecated Node runtimes in GitHub Actions. Update to a currently supported major version (e.g., @v5) to avoid workflow breakage as GitHub deprecates older Node versions.

Suggested change
uses: actions/setup-python@v3
uses: actions/setup-python@v5

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants