Skip to content
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
69 changes: 59 additions & 10 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,72 @@
# Copilot Instructions

- [x] Verify that the copilot-instructions.md file in the .github directory is created.
## Project Overview

- [x] Clarify Project Requirements
- **Name:** hello-python
- **Type:** Desktop GUI application (PyQt5)
- **Language:** Python 3.10+
- **Package Manager:** Poetry

- [x] Scaffold the Project
## Project Structure

- [x] Customize the Project
```
src/hello_python/
├── __init__.py # Package exports
├── __main__.py # python -m entry point
├── main.py # Core logic and app entry
├── window.py # UI components (HelloWindow)
├── build.py # PyInstaller build class
└── codestyle.py # Ruff formatting/linting class
tests/
├── conftest.py # Shared test fixtures
├── test_main.py # Unit tests for main + window
├── test_build.py # Build configuration tests
├── test_build_class.py # BuildExecutable class tests
└── test_codestyle.py # CodeStyle class tests
docs/ # Documentation
```

- [x] Install Required Extensions
## Common Commands

- [x] Compile the Project
```bash
# Install dependencies
poetry install

- [x] Create and Run Task
# Run the app
poetry run hello-python

- [x] Launch the Project (skipped: no debug launch requested)
# Run fast tests
poetry run pytest -m "not slow"

- [x] Ensure Documentation is Complete
# Run all tests including slow builds
poetry run pytest

- Work through each checklist item systematically.
# Format code
poetry run python -m hello_python.codestyle

# Check style (no changes)
poetry run python -m hello_python.codestyle check

# Build executable
poetry install --with build
poetry run python -m hello_python.build

# Pre-commit hooks
poetry run pre-commit run --all-files
```

## Development Guidelines

- Work through each task systematically.
- Keep communication concise and focused.
- Follow development best practices.
- Run `poetry run pytest -m "not slow"` before committing.
- Use pre-commit hooks to enforce code quality.
- Mark slow integration tests with `@pytest.mark.slow`.
- Support both Windows and Linux in all scripts/classes.

## CI/CD

- **CI:** `.github/workflows/ci.yml` — lint, test, build on push/PR
- **CD:** `.github/workflows/cd.yml` — release candidate on main after CI passes
- **Pre-commit:** `.pre-commit-config.yaml` — local quality gate before commit
21 changes: 13 additions & 8 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,25 @@ Describe what this PR changes and why.
List exact commands and expected outcomes.

```bash
# Example
/home/raymondsu/src/Vibe-helloworld-python/.venv/bin/python -m pytest -q
poetry run pytest -m "not slow" -v
poetry run python -m hello_python.codestyle check
```

## Validation Evidence
## Checklist

- [ ] Pre-commit hooks pass (`poetry run pre-commit run --all-files`)
- [ ] Lint passes (`poetry run ruff check .`)
- [ ] Format passes (`poetry run ruff format --check .`)
- [ ] Tests pass (`poetry run pytest -m "not slow"`)
- [ ] Build succeeds (`poetry run python -m hello_python.build`) *(if applicable)*
- [ ] CI pipeline passes on this branch

- [ ] Lint passes
- [ ] Tests pass
- [ ] Build succeeds (if applicable)
## Validation Evidence

Paste important output snippets:
Paste relevant output:

```text
# ruff / pytest / build output
# pytest / ruff / build output
```

## UI/UX Changes (if applicable)
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CD

on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]

jobs:
release:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Get version
id: version
run: |
VERSION=$(grep '^version' pyproject.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v${VERSION}-rc.$(date +%Y%m%d%H%M%S)" >> "$GITHUB_OUTPUT"

- name: Download artifacts from CI
uses: actions/download-artifact@v4
with:
path: artifacts/
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Create release candidate
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: Release Candidate ${{ steps.version.outputs.tag }}
prerelease: true
generate_release_notes: true
files: artifacts/**/*
69 changes: 51 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,72 @@ name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build-and-test:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Install Poetry
run: python -m pip install poetry
- name: Install dependencies
run: python -m poetry install --no-interaction --no-ansi
- name: Check formatting
run: python -m poetry run ruff format --check .
- name: Lint
run: python -m poetry run ruff check .

test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]

os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Install Poetry
run: python -m pip install poetry

- name: Install dependencies
run: python -m poetry install --with dev --no-interaction --no-ansi

- name: Run lint
run: python -m poetry run python -m ruff check .

run: python -m poetry install --no-interaction --no-ansi
- name: Run tests
env:
QT_QPA_PLATFORM: offscreen
run: python -m poetry run python -m pytest
run: python -m poetry run pytest -m "not slow" --cov=hello_python --cov-report=term-missing

- name: Build package
run: python -m poetry build
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Install Poetry
run: python -m pip install poetry
- name: Install dependencies
run: python -m poetry install --with build --no-interaction --no-ansi
- name: Build executable
env:
QT_QPA_PLATFORM: offscreen
run: python -m poetry run python -m hello_python.build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: executable-${{ matrix.os }}
path: dist/
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.0
hooks:
- id: ruff-format
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: local
hooks:
- id: pytest
name: pytest
entry: poetry run pytest -m "not slow" -q
language: system
pass_filenames: false
always_run: true
Loading
Loading