From 3a947bd6b627e96bc0a89005b7fb039809f8b764 Mon Sep 17 00:00:00 2001 From: Aidar Date: Mon, 8 Apr 2024 18:22:40 +0300 Subject: [PATCH] Update Github Actions (#27) --- .../{{ cookiecutter.package_name }}.yml | 118 +++++++++++++----- 1 file changed, 84 insertions(+), 34 deletions(-) diff --git a/{{ cookiecutter.project_name.lower().replace(' ', '-') }}/.github/workflows/{{ cookiecutter.package_name }}.yml b/{{ cookiecutter.project_name.lower().replace(' ', '-') }}/.github/workflows/{{ cookiecutter.package_name }}.yml index ed1c6d6..eef5ec8 100644 --- a/{{ cookiecutter.project_name.lower().replace(' ', '-') }}/.github/workflows/{{ cookiecutter.package_name }}.yml +++ b/{{ cookiecutter.project_name.lower().replace(' ', '-') }}/.github/workflows/{{ cookiecutter.package_name }}.yml @@ -1,4 +1,4 @@ -name: run-lint-tests +name: {{ cookiecutter.package_name }} on: push: @@ -11,37 +11,87 @@ jobs: lint: runs-on: ubuntu-latest steps: + - name: Check out repository + uses: actions/checkout@v4 - - name: Check out repository - uses: actions/checkout@v4 - - - name: Set up Python - id: setup-python - uses: actions/setup-python@v4 - with: - python-version: "{{ cookiecutter.python_version }}" - - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - version: 1.8.1 - virtualenvs-create: true - virtualenvs-in-project: true - installer-parallel: true - - - name: Load cache - id: cached-poetry-dependencies - uses: actions/cache@v3 - with: - path: .venv - key: {% raw %}venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}{% endraw %} - - - name: Install dependencies if cache does not exist - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-root - - - name: Run linters - run: make lint - - - name: Run tests - run: make test + - name: Set up Python + id: setup-python + uses: actions/setup-python@v5 + with: + python-version: "{{ cookiecutter.python_version }}" + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.8.1 + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + + - name: Load cache + id: cached-poetry-dependencies + uses: actions/cache@v4 + with: + path: .venv + key: {% raw %}venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}{% endraw %} + + - name: Install dependencies if cache does not exist + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + + - name: Run linters + run: make lint + + test: + runs-on: ubuntu-latest + permissions: write-all + steps: + + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python + id: setup-python + uses: actions/setup-python@v5 + with: + python-version: "{{ cookiecutter.python_version }}" + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.8.1 + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + + - name: Load cache + id: cached-poetry-dependencies + uses: actions/cache@v4 + with: + path: .venv + key: {% raw %}venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}{% endraw %} + + - name: Install dependencies if cache does not exist + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + + - name: Run tests + run: make test + + - name: Code Coverage Summary Report + uses: irongut/CodeCoverageSummary@v1.3.0 + with: + filename: reports/coverage.xml + badge: true + format: 'markdown' + output: 'both' + + - name: Add Coverage PR Comment + uses: marocchino/sticky-pull-request-comment@v2 + if: github.event_name == 'pull_request' + with: + recreate: true + path: code-coverage-results.md + + - name: Add Coverage Report to Job Summary + run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY