Skip to content

Commit fdc1e4b

Browse files
authored
Merge pull request #4 from barisgit/feature/ci-cd
[ci] Test new ci/cd
2 parents 60685bf + 34b9f8f commit fdc1e4b

File tree

19 files changed

+373
-130
lines changed

19 files changed

+373
-130
lines changed
Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3-
4-
name: Python package
1+
name: CI
52

63
on:
74
push:
@@ -11,31 +8,43 @@ on:
118
workflow_dispatch:
129

1310
jobs:
14-
build:
15-
16-
runs-on: ubuntu-latest
11+
test:
12+
runs-on: ${{ matrix.os }}
1713
strategy:
1814
fail-fast: false
1915
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
2017
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
2118

2219
steps:
2320
- uses: actions/checkout@v4
21+
2422
- name: Set up Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v3
23+
uses: actions/setup-python@v5
2624
with:
2725
python-version: ${{ matrix.python-version }}
26+
2827
- name: Install dependencies
2928
run: |
3029
python -m pip install --upgrade pip
31-
python -m pip install flake8 pytest
3230
pip install -e .[dev]
33-
- name: Lint with flake8
31+
32+
- name: Lint with ruff
3433
run: |
35-
# stop the build if there are Python syntax errors or undefined names
36-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
37-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
38-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
34+
ruff check .
35+
ruff format --check .
36+
37+
- name: Type check with pyrefly
38+
run: |
39+
pyrefly check
40+
3941
- name: Test with pytest
4042
run: |
41-
pytest
43+
pytest --cov=kicad_lib_manager --cov-report=xml
44+
45+
- name: Upload coverage to Codecov
46+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
47+
uses: codecov/codecov-action@v4
48+
with:
49+
file: ./coverage.xml
50+
fail_ci_if_error: false

.github/workflows/release.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to release (e.g., v0.3.1)'
11+
required: true
12+
type: string
13+
14+
permissions:
15+
contents: write
16+
id-token: write
17+
18+
jobs:
19+
build-and-publish:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.11'
31+
32+
- name: Install build dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install build hatch
36+
37+
- name: Verify version matches tag
38+
run: |
39+
if [[ "${{ github.event_name }}" == "push" ]]; then
40+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
41+
else
42+
TAG_VERSION="${{ github.event.inputs.version }}"
43+
TAG_VERSION="${TAG_VERSION#v}"
44+
fi
45+
46+
PACKAGE_VERSION=$(python -c "import kicad_lib_manager; print(kicad_lib_manager.__version__)")
47+
48+
if [[ "$TAG_VERSION" != "$PACKAGE_VERSION" ]]; then
49+
echo "Version mismatch: tag=$TAG_VERSION, package=$PACKAGE_VERSION"
50+
exit 1
51+
fi
52+
53+
echo "VERSION=$TAG_VERSION" >> $GITHUB_ENV
54+
55+
- name: Run tests
56+
run: |
57+
pip install -e .[dev]
58+
ruff check .
59+
ruff format --check .
60+
pyrefly
61+
pytest
62+
63+
- name: Build package
64+
run: |
65+
python -m build
66+
67+
- name: Check package
68+
run: |
69+
pip install twine
70+
twine check dist/*
71+
72+
- name: Generate release notes
73+
id: release_notes
74+
env:
75+
GH_TOKEN: ${{ github.token }}
76+
run: |
77+
# Get the previous release tag
78+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
79+
80+
if [ -z "$PREVIOUS_TAG" ]; then
81+
# First release, get all commits
82+
COMMITS=$(git log --oneline --no-merges)
83+
else
84+
# Get commits since last release
85+
COMMITS=$(git log --oneline --no-merges ${PREVIOUS_TAG}..HEAD)
86+
fi
87+
88+
# Get PR information
89+
PRS=$(gh pr list --state merged --search "merged:>${PREVIOUS_TAG:-1970-01-01}" --json number,title,url --jq '.[] | "- #\(.number): \(.title) (\(.url))"' 2>/dev/null || echo "")
90+
91+
# Generate release notes
92+
cat > release_notes.md << EOF
93+
## What's Changed in v${VERSION}
94+
95+
### Commits
96+
$(echo "$COMMITS" | sed 's/^/- /')
97+
98+
EOF
99+
100+
if [ ! -z "$PRS" ]; then
101+
cat >> release_notes.md << EOF
102+
103+
### Pull Requests
104+
$(echo "$PRS")
105+
106+
EOF
107+
fi
108+
109+
cat >> release_notes.md << 'EOF'
110+
111+
### Installation
112+
113+
**Using pipx (recommended for CLI tools):**
114+
```bash
115+
pipx install kilm
116+
```
117+
118+
**Using pip:**
119+
```bash
120+
pip install kilm
121+
```
122+
123+
**From release assets:**
124+
1. Download the wheel file from this release
125+
2. Install with pipx or pip:
126+
```bash
127+
pipx install kilm-${VERSION}-py3-none-any.whl
128+
# or
129+
pip install kilm-${VERSION}-py3-none-any.whl
130+
```
131+
132+
### Auto-Update (Coming Soon)
133+
Future versions will include `kilm update` functionality for easy updates.
134+
EOF
135+
136+
# Store release notes for next step
137+
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
138+
cat release_notes.md >> $GITHUB_OUTPUT
139+
echo "EOF" >> $GITHUB_OUTPUT
140+
141+
- name: Create GitHub Release
142+
uses: softprops/action-gh-release@v2
143+
with:
144+
tag_name: ${{ github.event_name == 'push' && github.ref_name || format('v{0}', github.event.inputs.version) }}
145+
name: Release ${{ github.event_name == 'push' && github.ref_name || format('v{0}', github.event.inputs.version) }}
146+
body: ${{ steps.release_notes.outputs.release_notes }}
147+
draft: true
148+
prerelease: false
149+
files: |
150+
dist/*.whl
151+
dist/*.tar.gz
152+
153+
- name: Publish to PyPI
154+
uses: pypa/gh-action-pypi-publish@release/v1
155+
with:
156+
print-hash: true
157+
verbose: true

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Professional command-line tool for managing KiCad libraries across projects and workstations.
1010

11-
**[📚 Official Documentation](https://kilm.aristovnik.me)**
11+
**[Official Documentation](https://kilm.aristovnik.me)**
1212

1313
## Features
1414

@@ -41,18 +41,18 @@ kilm setup
4141
kilm status
4242
```
4343

44-
> **📚 [Complete Installation Guide](https://kilm.aristovnik.me/guides/installation/)** - Multiple installation methods, verification steps, and troubleshooting.
44+
> **[Complete Installation Guide](https://kilm.aristovnik.me/guides/installation/)** - Multiple installation methods, verification steps, and troubleshooting.
4545
4646
## Documentation
4747

48-
**[📚 Complete Documentation](https://kilm.aristovnik.me)**
48+
**[Complete Documentation](https://kilm.aristovnik.me)**
4949

5050
| Guide | Description |
5151
|-------|-------------|
52-
| [🚀 Getting Started](https://kilm.aristovnik.me/guides/getting-started/) | Creator and consumer workflows with Git integration |
53-
| [⚙️ Configuration](https://kilm.aristovnik.me/guides/configuration/) | KiLM and KiCad configuration management |
54-
| [📖 CLI Reference](https://kilm.aristovnik.me/reference/cli/) | Complete command documentation with examples |
55-
| [🛠️ Development](https://kilm.aristovnik.me/community/development/) | Setup guide for contributors and development |
52+
| [Getting Started](https://kilm.aristovnik.me/guides/getting-started/) | Creator and consumer workflows with Git integration |
53+
| [Configuration](https://kilm.aristovnik.me/guides/configuration/) | KiLM and KiCad configuration management |
54+
| [CLI Reference](https://kilm.aristovnik.me/reference/cli/) | Complete command documentation with examples |
55+
| [Development](https://kilm.aristovnik.me/community/development/) | Setup guide for contributors and development |
5656

5757
## License
5858

@@ -70,5 +70,5 @@ Contributions are welcome! See our comprehensive guides:
7070
git clone https://github.com/barisgit/kilm.git
7171
cd kilm
7272
pip install -e ".[dev]"
73-
pytest # Run tests
73+
pytest # Run all tests
7474
```

kicad_lib_manager/commands/add_hook/command.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def add_hook(directory, force):
7777
else:
7878
# Merge with existing content to preserve user logic
7979
click.echo("Merging KiLM content with existing hook...")
80-
new_content = merge_hook_content(existing_content, create_kilm_hook_content())
80+
new_content = merge_hook_content(
81+
existing_content, create_kilm_hook_content()
82+
)
8183

8284
except (OSError, UnicodeDecodeError):
8385
click.echo("Warning: Could not read existing hook content, overwriting...")

kicad_lib_manager/commands/config/command.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ def set_default(library_name, library_type):
292292

293293
# Set as current library
294294
if library_path is None:
295-
click.echo(f"Error: Could not find path for library '{library_name}'", err=True)
295+
click.echo(
296+
f"Error: Could not find path for library '{library_name}'", err=True
297+
)
296298
sys.exit(1)
297299
config.set_current_library(library_path)
298300
click.echo(f"Set {library_type} library '{library_name}' as default.")
@@ -350,7 +352,9 @@ def remove(library_name, library_type, force):
350352
# Find libraries matching the name and type
351353
matching_libraries = []
352354
for lib in all_libraries:
353-
if lib.get("name") == library_name and (library_type == "all" or lib.get("type") == library_type):
355+
if lib.get("name") == library_name and (
356+
library_type == "all" or lib.get("type") == library_type
357+
):
354358
matching_libraries.append(lib)
355359

356360
if not matching_libraries:

kicad_lib_manager/commands/setup/command.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ def setup(
478478

479479
# Also list existing libraries to pin them all
480480
try:
481-
482481
existing_symbols, existing_footprints = list_libraries(kicad_lib_dir)
483482
symbol_libs = existing_symbols
484483
footprint_libs = existing_footprints

kicad_lib_manager/commands/status/command.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ def status():
2626
config_data = yaml.safe_load(f)
2727

2828
# Show libraries
29-
if config_data and "libraries" in config_data and config_data["libraries"]:
29+
if (
30+
config_data
31+
and "libraries" in config_data
32+
and config_data["libraries"]
33+
):
3034
click.echo(" Configured Libraries:")
3135

3236
# Group by type
@@ -48,7 +52,8 @@ def status():
4852
path = lib.get("path", "unknown")
4953
current = (
5054
" (current)"
51-
if config_data and config_data.get("current_library") == path
55+
if config_data
56+
and config_data.get("current_library") == path
5257
else ""
5358
)
5459
click.echo(f" - {name}: {path}{current}")
@@ -67,7 +72,8 @@ def status():
6772
path = lib.get("path", "unknown")
6873
current = (
6974
" (current)"
70-
if config_data and config_data.get("current_library") == path
75+
if config_data
76+
and config_data.get("current_library") == path
7177
else ""
7278
)
7379
click.echo(f" - {name}: {path}{current}")
@@ -83,7 +89,8 @@ def status():
8389

8490
# Show current library
8591
if (
86-
config_data and "current_library" in config_data
92+
config_data
93+
and "current_library" in config_data
8794
and config_data["current_library"]
8895
):
8996
click.echo(

kicad_lib_manager/commands/template/command.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,12 @@ def make(
817817
if not git_path.endswith("/"):
818818
git_path += "/"
819819

820-
if gitignore_spec and gitignore_spec.match_file(git_path) or additional_spec and additional_spec.match_file(git_path):
820+
if (
821+
gitignore_spec
822+
and gitignore_spec.match_file(git_path)
823+
or additional_spec
824+
and additional_spec.match_file(git_path)
825+
):
821826
dirs_to_remove.append(d)
822827
excluded_files.append(f"{rel_path}/")
823828

kicad_lib_manager/commands/unpin/command.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def unpin(symbols, footprints, all, dry_run, max_backups, verbose):
5050
"""Unpin libraries in KiCad"""
5151
# Enforce mutual exclusivity of --all with --symbols/--footprints
5252
if all and (symbols or footprints):
53-
raise click.UsageError("'--all' cannot be used with '--symbols' or '--footprints'")
53+
raise click.UsageError(
54+
"'--all' cannot be used with '--symbols' or '--footprints'"
55+
)
5456

5557
# Find KiCad configuration
5658
try:

0 commit comments

Comments
 (0)