From a15a998ee166befabde0978a310a116f7f9a7212 Mon Sep 17 00:00:00 2001 From: Aleksandr Penskoi Date: Sun, 24 Dec 2023 22:23:24 +0100 Subject: [PATCH] Update CI description in the report example. --- Dockerfiles/python-tools.Dockerfile | 16 ------- python/README.md | 68 +++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 30 deletions(-) delete mode 100644 Dockerfiles/python-tools.Dockerfile diff --git a/Dockerfiles/python-tools.Dockerfile b/Dockerfiles/python-tools.Dockerfile deleted file mode 100644 index cd47593..0000000 --- a/Dockerfiles/python-tools.Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM python:3.12-slim - -ENV PYTHONUNBUFFERED=1 \ - PIP_NO_CACHE_DIR=off \ - POETRY_VERSION=1.6.1 - -WORKDIR /code -COPY src/brainfuck/poetry.lock src/brainfuck/pyproject.toml /code - -RUN pip install --no-cache-dir --progress-bar off "poetry==$POETRY_VERSION" - -RUN poetry config virtualenvs.create false \ - && poetry install --no-cache --no-interaction --no-ansi - -# docker buildx build --push --platform linux/arm64,linux/amd64 --tag ryukzak/python-tools -f src/Dockerfiles/python-tools.Dockerfile . -# docker run -it ryukzak/python-tools /bin/sh diff --git a/python/README.md b/python/README.md index f0e3c4d..59f9183 100644 --- a/python/README.md +++ b/python/README.md @@ -276,26 +276,66 @@ comment ::= <+-.,[]"> - через golden tests, конфигурация которых лежит в папке [golden](./golden) (требуются по заданию). - через unittest (приведён как **устаревший** пример). -CI: +CI при помощи Github Action: ``` yaml -lab3-example: - stage: test - image: - name: ryukzak/python-tools - entrypoint: [""] - script: - - cd src/brainfuck - - poetry install - - coverage run -m pytest --verbose - - find . -type f -name "*.py" | xargs -t coverage report - - ruff format --check . - - ruff check . +defaults: + run: + working-directory: ./python + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install poetry + poetry install + + - name: Run tests and collect coverage + run: | + poetry run coverage run -m pytest . + poetry run coverage report -m + env: + CI: true + + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install poetry + poetry install + + - name: Check code formatting with Ruff + run: poetry run ruff format --check . + + - name: Run Ruff linters + run: poetry run ruff check . ``` где: -- `ryukzak/python-tools` -- docker образ содержит все необходимые для проверки утилиты. Подробнее: [Dockerfile](/src/Dockerfiles/python-tools.Dockerfile) - `poetry` -- управления зависимостями для языка программирования Python. - `coverage` -- формирование отчёта об уровне покрытия исходного кода. - `pytest` -- утилита для запуска тестов.