Skip to content

Merge pull request #4 from dotlambda/patch-1 #13

Merge pull request #4 from dotlambda/patch-1

Merge pull request #4 from dotlambda/patch-1 #13

Workflow file for this run

---
name: CI
on:
pull_request:
branches:
- dev
- master
push:
branches:
- dev
- master
env:
CACHE_VERSION: 1
DEFAULT_PYTHON: "3.12"
PRE_COMMIT_CACHE: ~/.cache/pre-commit
UV_CACHE_DIR: /tmp/uv-cache
jobs:
info:
name: Collect information & changes data
outputs:
pre-commit_cache_key: ${{ steps.generate_pre-commit_cache_key.outputs.key }}
python_cache_key: ${{ steps.generate_python_cache_key.outputs.key }}
requirements: ${{ steps.core.outputs.requirements }}
python_versions: ${{ steps.info.outputs.python_versions }}
runs-on: ubuntu-22.04
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
- name: Generate partial Python venv restore key
id: generate_python_cache_key
run: |
echo key=venv-${{ env.CACHE_VERSION }}-${{
hashFiles('requirements_test.txt') }} >> $GITHUB_OUTPUT
- name: Generate partial pre-commit restore key
id: generate_pre-commit_cache_key
run: >-
echo "key=pre-commit-${{ env.CACHE_VERSION }}-${{
hashFiles('.pre-commit-config.yaml') }}" >> $GITHUB_OUTPUT
pre-commit:
name: Prepare pre-commit base
runs-on: ubuntu-22.04
needs:
- info
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
- name: Restore base Python virtual environment
id: cache-venv
uses: actions/[email protected]
with:
path: venv
key: >-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{
needs.info.outputs.pre-commit_cache_key }}
- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
python -m venv venv
. venv/bin/activate
python --version
pip install "$(grep '^uv' < requirements_test.txt)"
uv pip install "$(cat requirements_test.txt | grep pre-commit)"
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/[email protected]
with:
path: ${{ env.PRE_COMMIT_CACHE }}
lookup-only: true
key: >-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
needs.info.outputs.pre-commit_cache_key }}
- name: Install pre-commit dependencies
if: steps.cache-precommit.outputs.cache-hit != 'true'
run: |
. venv/bin/activate
pre-commit install-hooks
lint-ruff-format:
name: Check ruff-format
runs-on: ubuntu-22.04
needs:
- info
- pre-commit
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/[email protected]
id: python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
- name: Restore base Python virtual environment
id: cache-venv
uses: actions/cache/[email protected]
with:
path: venv
fail-on-cache-miss: true
key: >-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{
needs.info.outputs.pre-commit_cache_key }}
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/cache/[email protected]
with:
path: ${{ env.PRE_COMMIT_CACHE }}
fail-on-cache-miss: true
key: >-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
needs.info.outputs.pre-commit_cache_key }}
- name: Run ruff-format
run: |
. venv/bin/activate
pre-commit run --hook-stage manual ruff-format --all-files --show-diff-on-failure
env:
RUFF_OUTPUT_FORMAT: github
test:
name: Tests
runs-on: ubuntu-latest
needs:
- lint-ruff-format
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- run: |
python -m venv venv
venv/bin/pip install -r requirements_test.txt
venv/bin/py.test tests/
coverage:
name: Test Coverage
runs-on: ubuntu-latest
needs:
- test
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
architecture: x64
- run: |
python -m venv venv
venv/bin/pip install -r requirements_test.txt
venv/bin/py.test \
-s \
--verbose \
--cov-report term-missing \
--cov-report xml \
--cov=pyseventeentrack tests
- uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}