Use poetry #1
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: lint-and-test | |
on: | |
pull_request: | |
branches: [main] | |
jobs: | |
lint-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.8.10" | |
- name: Cache Poetry install | |
uses: actions/cache@v2 | |
with: | |
path: ~/.local | |
key: poetry-1.8.3-0 | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.8.3 | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Cache Poetry dependencies | |
id: cache-poetry-deps | |
uses: actions/cache@v2 | |
with: | |
path: .venv | |
key: pydeps-${{ hashFiles('**/poetry.lock') }} | |
- run: poetry install --no-interaction --no-root | |
if: steps.cache-poetry-deps.outputs.cache-hit != 'true' | |
# --- Ruff | |
- name: ruff (lint) | |
id: ruff_lint | |
continue-on-error: true | |
run: | | |
poetry ruff --version | |
poetry ruff check . --verbose --diff | |
echo "ruff_lint_failed=$?" >> $GITHUB_ENV | |
- name: ruff (format) | |
id: ruff_format | |
continue-on-error: true | |
run: | | |
poetry ruff --version | |
poetry ruff format . --check --verbose --diff | |
echo "ruff_format_failed=$?" >> $GITHUB_ENV | |
# --- Pytest | |
- name: pytest | |
id: pytest | |
continue-on-error: true | |
run: | | |
poetry pytest --version | |
poetry pytest | |
echo "pytest_failed=$?" >> $GITHUB_ENV | |
# --- Pyright | |
- name: pyright | |
id: pyright | |
continue-on-error: true | |
run: | | |
poetry pyright --version | |
poetry pyright --project ./pyrightconfig.ci.json | |
echo "pyright_failed=$?" >> $GITHUB_ENV | |
# --- Main | |
- name: Test results | |
if: always() | |
run: | | |
# Print out test results | |
passed=() | |
failed=() | |
if [[ "${{ env.pytest_failed }}" != "0" ]]; then | |
failed+=("pytest") | |
else | |
passed+=("pytest") | |
fi | |
if [[ "${{ env.pyright_failed }}" != "0" ]]; then | |
failed+=("pyright") | |
else | |
passed+=("pyright") | |
fi | |
if [[ "${{ env.ruff_lint_failed }}" != "0" ]]; then | |
failed+=("ruff_lint") | |
else | |
passed+=("ruff_lint") | |
fi | |
if [[ "${{ env.ruff_format_failed }}" != "0" ]]; then | |
failed+=("ruff_format") | |
else | |
passed+=("ruff_format") | |
fi | |
if [ ${#passed[@]} -ne 0 ]; then | |
echo "✅ PASSED:" | |
for check in "${passed[@]}"; do | |
echo " - $check" | |
done | |
fi | |
echo "" | |
if [ ${#failed[@]} -ne 0 ]; then | |
echo "❌ FAILED:" | |
for check in "${failed[@]}"; do | |
echo " - $check" | |
done | |
else | |
echo "🚀🚀 ALL TESTS PASSED 🚀🚀" | |
fi | |
echo "" | |
echo "Click above jobs for details on each success/failure" | |
if [ ${#failed[@]} -ne 0 ]; then | |
exit 1 | |
fi |