ci: fast linting and testing #500
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python Checks | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
lint-fast: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/[email protected] | |
with: | |
python-version: 3.9 | |
- name: Cache dependencies | |
uses: actions/[email protected] | |
id: cache | |
with: | |
path: ${{ env.pythonLocation }} | |
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements-dev.txt') }} | |
- name: Install pip dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: pip install -r requirements-dev.txt | |
- name: Lint | |
run: | | |
echo "::add-matcher::.github/pylama_matcher.json" | |
ruff --config tests/ruff.toml . | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
cache: pip | |
cache-dependency-path: requirements-dev.txt | |
- name: Install dependencies | |
run: | | |
python -m pip install --disable-pip-version-check wheel pip-tools | |
pip-sync requirements-dev.txt | |
python -m pip install --disable-pip-version-check --no-deps . | |
- name: Lint | |
run: | | |
echo "::add-matcher::.github/pylama_matcher.json" | |
ruff --config tests/ruff.toml . | |
autoformat: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
python -m pip install --disable-pip-version-check black==23.1.0 isort==5.12.0 | |
- name: Autoformatter | |
run: | | |
black --diff . | |
isort --version | |
isort --atomic --profile black --check-only . | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.10"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: pip | |
cache-dependency-path: requirements-dev.txt | |
- name: Install dependencies | |
run: | | |
python -m pip install --disable-pip-version-check -r requirements-dev.txt | |
python -m pip install --disable-pip-version-check . | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=curmonth::$(date +'%Y-%m')" | |
- name: Cache Model Files | |
id: cache-model-files | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/huggingface | |
~/.cache/clip | |
~/.cache/imaginairy | |
~/.cache/torch | |
key: ${{ steps.date.outputs.curmonth }}-b | |
- name: Test with pytest | |
timeout-minutes: 20 | |
run: | | |
pytest --durations=50 -v |