diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7034c68..a0b590e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,46 +4,96 @@ on: push: branches: - main + pull_request: + branches: + - "**" concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: - build: + lint-and-test: env: UV_CACHE_DIR: /tmp/.uv-cache runs-on: ubuntu-24.04 steps: - name: Checkout source code uses: actions/checkout@v6 + - name: Set up python id: setup-python uses: actions/setup-python@v6 with: python-version-file: ".python-version" + - name: Set up uv uses: astral-sh/setup-uv@v7 with: enable-cache: true version-file: "pyproject.toml" + - name: Install dependencies run: uv sync --all-extras --dev --frozen - - name: Test with pytest + + - name: Run ruff lint + run: uv run ruff check src tests + + - name: Run ruff format check + run: uv run ruff format --check src tests + + - name: Run mypy type check + run: uv run mypy src tests + + - name: Run bandit security check + run: uv run bandit -r src + + - name: Run pytest with coverage run: uv run pytest tests --cov=src + + - name: Minimize uv cache + run: uv cache prune --ci + + build: + needs: lint-and-test + env: + UV_CACHE_DIR: /tmp/.uv-cache + runs-on: ubuntu-24.04 + steps: + - name: Checkout source code + uses: actions/checkout@v6 + + - name: Set up python + id: setup-python + uses: actions/setup-python@v6 + with: + python-version-file: ".python-version" + + - name: Set up uv + uses: astral-sh/setup-uv@v7 + with: + enable-cache: true + version-file: "pyproject.toml" + + - name: Install dependencies + run: uv sync --all-extras --dev --frozen + - name: Build a wheel run: uv build + - name: Minimize uv cache run: uv cache prune --ci build-image: + needs: lint-and-test runs-on: ubuntu-24.04 - steps: - name: Checkout source code uses: actions/checkout@v6 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build docker image uses: docker/build-push-action@v6 with: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index c6f939b..0000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: pr - -on: - pull_request: - branches: - - "**" - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - build: - env: - UV_CACHE_DIR: /tmp/.uv-cache - runs-on: ubuntu-24.04 - steps: - - name: Checkout source code - uses: actions/checkout@v6 - - name: Set up python - id: setup-python - uses: actions/setup-python@v6 - with: - python-version-file: ".python-version" - - name: Set up uv - uses: astral-sh/setup-uv@v7 - with: - enable-cache: true - version-file: "pyproject.toml" - - name: Install dependencies - run: uv sync --all-extras --dev --frozen - - name: Test with pytest - run: uv run pytest tests --cov=src - - name: Build a wheel - run: uv build - - name: Minimize uv cache - run: uv cache prune --ci - - build-image: - runs-on: ubuntu-24.04 - - steps: - - name: Checkout source code - uses: actions/checkout@v6 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Build docker image - uses: docker/build-push-action@v6 - with: - context: . - push: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e663d8..55a8782 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,3 @@ -ci: - skip: [pytest] - default_language_version: python: python3.14 diff --git a/README.md b/README.md index 5dc24b0..a1056fe 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,79 @@ TOTAL 7 2 71% --- +## Validation + +To ensure all configurations are working correctly, you can run the following checks: + +### Linting and Formatting + +**Run ruff lint check:** +```bash +uv run ruff check src tests +``` + +**Run ruff format check:** +```bash +uv run ruff format --check src tests +``` + +**Run ruff format (to fix formatting issues):** +```bash +uv run ruff format src tests +``` + +### Type Checking + +**Run mypy type check:** +```bash +uv run mypy src tests +``` + +### Security Checking + +**Run bandit security check:** +```bash +uv run bandit -r src +``` + +### Testing + +**Run pytest:** +```bash +uv run pytest tests +``` + +**Run pytest with coverage:** +```bash +uv run pytest tests --cov=src +``` + +### Pre-commit Hooks + +**Run all pre-commit hooks:** +```bash +pre-commit run --all-files +``` + +### Docker + +**Build production image:** +```bash +docker build . -t my-python-application:latest +``` + +**Build development image:** +```bash +docker build . --target development -t my-python-application:dev +``` + +**Run the application:** +```bash +docker run -it --rm my-python-application:latest +``` + +--- + ## Docker ### Build diff --git a/pyproject.toml b/pyproject.toml index 21e08e0..0f0c7aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ dev = [ ] [tool.uv] -required-version = ">=0.9.30" +required-version = "==0.10.3" [tool.pytest.ini_options] addopts = "-vvv"