Skip to content

ci: adjust uv cache (#692) #498

ci: adjust uv cache (#692)

ci: adjust uv cache (#692) #498

Workflow file for this run

name: CI
on:
workflow_dispatch:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
env:
FORCE_COLOR: 3
jobs:
pre-commit:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: pre-commit/[email protected]
- name: Setup uv
uses: astral-sh/setup-uv@v3
- name: pylint
run: uvx nox -s pylint -- --output-format=github
tests:
name: Tests on 🐍 ${{ matrix.python-version }} ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.10", "3.13"]
os: [ubuntu-latest, windows-latest, macos-13]
include:
- python-version: 'pypy-3.8'
os: ubuntu-latest
- python-version: 'pypy-3.10'
os: ubuntu-latest
- python-version: '3.9'
os: ubuntu-latest
- python-version: '3.13'
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup uv (cached)
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-suffix: ${{ matrix.os }}-${{ matrix.python-version }}
cache-dependency-glob: "**/pyproject.toml"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
if: matrix.python-version != '3.13'
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Set up Python ${{ matrix.python-version }} (uv)
if: matrix.python-version == '3.13'
run: uv python install 3.13
- name: Add locale for locale test
if: runner.os == 'Linux' && matrix.python-version != '3.10'
run: sudo locale-gen fr_FR.UTF-8
- name: Install
run: |
uv venv --python ${{ matrix.python-version }}
uv pip install -e.[test] pytest-github-actions-annotate-failures
- name: Setup SSH tests
if: runner.os != 'Windows'
run: |
chmod 755 ~
mkdir -p ~/.ssh
chmod 755 ~/.ssh
echo "NoHostAuthenticationForLocalhost yes" >> ~/.ssh/config
echo "StrictHostKeyChecking no" >> ~/.ssh/config
ssh-keygen -q -f ~/.ssh/id_rsa -N ''
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keys
ls -la ~
ssh localhost -vvv "echo 'Worked!'"
- name: Test with pytest
run: uv run pytest --cov --run-optional-tests=ssh,sudo
- name: Upload coverage
run: uvx coveralls --service=github
env:
COVERALLS_PARALLEL: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: test-${{ matrix.os }}-${{ matrix.python-version }}
coverage:
needs: [tests]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install coveralls
run: pip install coveralls
- name: Coveralls Finished
run: coveralls --service=github --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}