Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CI #231

Merged
merged 6 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
name: Mocket's CI

on:

# Run on all push events.
push:

# Allow job to be triggered manually.
workflow_dispatch:
branches:
- main
pull_request:
types:
- opened
- synchronize
schedule:
# cron every week on monday
- cron: "0 0 * * 1"

# Cancel in-progress jobs when pushing to the same branch.
concurrency:
Expand All @@ -18,7 +22,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy3.10']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] # , 'pypy3.10'

steps:
- uses: actions/checkout@v3
Expand Down
42 changes: 18 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: check-yaml
args: ['--unsafe']
- id: check-json
- id: end-of-file-fixer
- id: trailing-whitespace
- id: no-commit-to-branch
- id: pretty-format-json
args: ['--autofix']

- repo: git@github.com:humitos/mirrors-autoflake.git
rev: v1.1
- id: forbid-crlf
- id: remove-crlf
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: autoflake
args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable']

- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
exclude: helm/
args: [ --unsafe ]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.4.3"
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 23.10.0
hooks:
- id: black
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
20 changes: 7 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
#!/usr/bin/make -f

install-dev-requirements:
pip install -U pip hatch
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv && uv pip install hatch

install-test-requirements:
pip install -U .[test]
uv pip install --editable .[test]

services-up:
docker compose up -d

services-down:
docker compose down --remove-orphans

test-python:
@echo "Running Python tests"
wait-for-it --service httpbin.local:443 --service localhost:6379 --timeout 5 -- pytest tests/ || exit 1
@echo ""

lint-python:
@echo "Linting Python files"
flake8 --ignore=E501,E731,W503 --exclude=.git,compat.py --per-file-ignores='mocket/async_mocket.py:E999' mocket
@echo ""

setup: develop
pre-commit install

develop: install-dev-requirements install-test-requirements

test: lint-python test-python
test:
@echo "Running Python tests"
export VIRTUAL_ENV=.venv; .venv/bin/wait-for-it --service httpbin.local:443 --service localhost:6379 --timeout 5 -- .venv/bin/pytest tests/ || exit 1
@echo ""

safetest:
export SKIP_TRUE_REDIS=1; export SKIP_TRUE_HTTP=1; make test
Expand Down
Loading