Luke Tainton 13097b36fb
Some checks failed
Security / sonarqube (push) Failing after 36s
Security / snyk (push) Successful in 1m1s
fix(lint): Fix linting issues (#487)
This pull request focuses on improving the documentation and readability of the Webex meme bot application by adding docstrings and minor formatting adjustments. Here's a breakdown of the changes:

*   **Docstrings:**
    *   Added module-level docstrings to `app/close.py`, `app/img.py`, and `app/main.py` providing a high-level overview of the purpose of each module.
    *   Added docstrings to classes (`ExitCommand`, `MakeMemeCommand`, `MakeMemeCallback`) describing their role.
    *   Added docstrings to methods within those classes (`__init__`, `pre_execute`, `execute`, `post_execute`) explaining their functionality, arguments, and return values where applicable. The `get_templates` and `format_meme_string` functions in `app/img.py` have been documented as well.
*   **Formatting:**
    *   Added a line break before the return type annotation in function definitions (e.g., `def execute(...) -> Response:`).
    *   Added the disable comment `# pylint: disable=line-too-long` to a line in `app/meme.py` to disable pylint for that line.
    *   Added the disable comment `# pylint: disable=unused-argument` to the `pre_execute`, `execute`, and `post_execute` methods to disable pylint checks about unused arguments. This is because these methods are part of an interface and must have the same signature even if some arguments are unused.
*   **Variable Naming:**
    *   Renamed the `vars` dictionary to `env_vars` in `tests/test_config.py` for better clarity.
*   **Test Update:**
    *   Added a docstring to the `test_config` function in `tests/test_config.py` to explain its functionality.
*   **Imports Update:**
    *   Updated imports in `tests/test_config.py` to disable pylint for wrong-import-position errors using `# pylint: disable=wrong-import-position`.

In essence, these changes enhance the maintainability and understandability of the codebase through comprehensive documentation and minor code style improvements.

Reviewed-on: #487
2025-06-06 19:39:11 +02:00

96 lines
2.6 KiB
YAML

name: CI
on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened
jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- name: Run Hadolint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile
output-file: hadolint.out
format: sonarqube
no-fail: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install dependencies
run: uv sync
# - name: Lint
# run: |
# uv run pylint --fail-under=8 --recursive=yes --output-format=parseable --output=lintreport.txt app/ tests/
# cat lintreport.txt
- name: Lint
run: |
uv run pylint --fail-under=8 --recursive=yes --output-format=parseable app/ tests/
- name: Unit Test
run: |
uv run coverage run -m pytest -v --junitxml=testresults.xml
uv run coverage xml
sed -i 's@${{ gitea.workspace }}@/github/workspace@g' coverage.xml
- name: Minimize uv cache
run: uv cache prune --ci
- name: Set up environment for Snyk
run: |
uv pip freeze > requirements.txt
mv pyproject.toml pyproject.toml.bak
mv uv.lock uv.lock.bak
- name: Snyk SAST Scan
uses: snyk/actions/python@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
# command: snyk
args: snyk code test #--all-projects --exclude=.archive
# - name: SonarQube Scan
# uses: SonarSource/sonarqube-scan-action@v5.2.0
# env:
# SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST_URL }}
# SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
# - name: Snyk Vulnerability Scan
# uses: snyk/actions/python@master
# continue-on-error: true # Sometimes vulns aren't immediately fixable
# env:
# SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
# with:
# command: snyk
# args: test --all-projects
- name: Reverse set up environment for Snyk
run: |
rm -f requirements.txt
mv pyproject.toml.bak pyproject.toml
mv uv.lock.bak uv.lock