Skip to content

Commit a0055c1

Browse files
committed
update github workflow
1 parent 9b4f0fb commit a0055c1

File tree

6 files changed

+173
-60
lines changed

6 files changed

+173
-60
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,23 @@ on:
66
pull_request:
77
branches: [ main ]
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
test:
11-
runs-on: ubuntu-latest
15+
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
1217
strategy:
18+
fail-fast: false
1319
matrix:
1420
python-version: ["3.10", "3.11", "3.12"]
21+
os: [ubuntu-latest, windows-latest, macos-latest]
1522

1623
steps:
17-
- uses: actions/checkout@v4
24+
- name: Checkout code
25+
uses: actions/checkout@v4
1826

1927
- name: Install uv
2028
uses: astral-sh/setup-uv@v5
@@ -25,23 +33,33 @@ jobs:
2533
run: uv python install ${{ matrix.python-version }}
2634

2735
- name: Install dependencies
28-
run: uv sync --extra dev
36+
run: uv sync --group test
2937

30-
- name: Run linting
38+
- name: Run linting (Linux only)
39+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
3140
run: |
3241
uv run black --check hyperdb/ tests/
3342
uv run isort --check-only hyperdb/ tests/
43+
uv run flake8 hyperdb/ tests/
3444
35-
- name: Run tests
36-
run: uv run pytest tests/ -v
45+
- name: Run tests with coverage
46+
run: uv run pytest tests/ -v --cov=hyperdb --cov-report=xml --cov-report=term
3747

38-
- name: Build package
39-
run: uv build
48+
- name: Upload coverage to Codecov
49+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
50+
uses: codecov/codecov-action@v4
51+
with:
52+
file: ./coverage.xml
53+
fail_ci_if_error: false
4054

41-
test-windows:
42-
runs-on: windows-latest
55+
build:
56+
name: Build package
57+
runs-on: ubuntu-latest
58+
needs: test
59+
4360
steps:
44-
- uses: actions/checkout@v4
61+
- name: Checkout code
62+
uses: actions/checkout@v4
4563

4664
- name: Install uv
4765
uses: astral-sh/setup-uv@v5
@@ -52,10 +70,13 @@ jobs:
5270
run: uv python install 3.11
5371

5472
- name: Install dependencies
55-
run: uv sync --extra dev
56-
57-
- name: Run tests
58-
run: uv run pytest tests/ -v
73+
run: uv sync
5974

6075
- name: Build package
6176
run: uv build
77+
78+
- name: Upload artifacts
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: packages
82+
path: dist/*

.github/workflows/docs.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: Deploy Documentation
33
on:
44
push:
55
branches: [ main ]
6+
paths:
7+
- 'docs/**'
8+
- 'mkdocs.yml'
9+
- '.github/workflows/docs.yml'
610
workflow_dispatch:
711

812
permissions:
@@ -16,6 +20,7 @@ concurrency:
1620

1721
jobs:
1822
docs:
23+
name: Deploy docs to GitHub Pages
1924
runs-on: ubuntu-latest
2025

2126
steps:
@@ -40,5 +45,14 @@ jobs:
4045
git config --global user.name "github-actions[bot]"
4146
git config --global user.email "github-actions[bot]@users.noreply.github.com"
4247
43-
- name: Deploy documentation
44-
run: uv run mkdocs gh-deploy --force
48+
- name: Build and deploy documentation
49+
run: uv run mkdocs gh-deploy --force --clean
50+
51+
- name: Upload Pages artifact
52+
uses: actions/upload-pages-artifact@v3
53+
with:
54+
path: site/
55+
56+
- name: Deploy to GitHub Pages
57+
id: deployment
58+
uses: actions/deploy-pages@v4

.github/workflows/quality.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
quality:
15+
name: Code quality checks
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v5
24+
with:
25+
version: "latest"
26+
27+
- name: Set up Python
28+
run: uv python install 3.11
29+
30+
- name: Install dependencies
31+
run: uv sync --group dev
32+
33+
- name: Check code formatting with Black
34+
run: uv run black --check --diff hyperdb/ tests/
35+
36+
- name: Check import sorting with isort
37+
run: uv run isort --check-only --diff hyperdb/ tests/
38+
39+
- name: Lint with flake8
40+
run: uv run flake8 hyperdb/ tests/
41+
42+
- name: Type checking with mypy
43+
run: uv run mypy hyperdb/ --ignore-missing-imports
44+
45+
- name: Security check with bandit
46+
run: uv run bandit -r hyperdb/ -f json -o bandit-report.json
47+
continue-on-error: true
48+
49+
- name: Upload bandit report
50+
uses: actions/upload-artifact@v4
51+
if: always()
52+
with:
53+
name: bandit-report
54+
path: bandit-report.json
55+
56+
dependency-check:
57+
name: Dependency vulnerability check
58+
runs-on: ubuntu-latest
59+
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v4
63+
64+
- name: Install uv
65+
uses: astral-sh/setup-uv@v5
66+
with:
67+
version: "latest"
68+
69+
- name: Set up Python
70+
run: uv python install 3.11
71+
72+
- name: Install dependencies
73+
run: uv sync --group dev
74+
75+
- name: Run safety check
76+
run: uv run safety check --json --output safety-report.json
77+
continue-on-error: true
78+
79+
- name: Upload safety report
80+
uses: actions/upload-artifact@v4
81+
if: always()
82+
with:
83+
name: safety-report
84+
path: safety-report.json

.github/workflows/release.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ on:
44
release:
55
types: [published]
66

7+
permissions:
8+
contents: read
9+
id-token: write # For trusted publishing to PyPI
10+
711
jobs:
812
build-and-publish:
13+
name: Build and publish to PyPI
914
runs-on: ubuntu-latest
15+
environment: release
1016

1117
steps:
12-
- uses: actions/checkout@v4
18+
- name: Checkout code
19+
uses: actions/checkout@v4
1320

1421
- name: Install uv
1522
uses: astral-sh/setup-uv@v5
@@ -20,18 +27,31 @@ jobs:
2027
run: uv python install 3.11
2128

2229
- name: Install dependencies
23-
run: uv sync --extra dev
30+
run: uv sync --group test
2431

2532
- name: Run tests
26-
run: uv run pytest tests/
33+
run: uv run pytest tests/ -v
2734

2835
- name: Build package
2936
run: uv build
3037

31-
- name: Publish to PyPI
32-
env:
33-
TWINE_USERNAME: __token__
34-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
38+
- name: Verify package
3539
run: |
3640
uv run pip install twine
37-
uv run twine upload dist/*
41+
uv run twine check dist/*
42+
43+
- name: Publish to PyPI
44+
uses: pypa/gh-action-pypi-publish@release/v1
45+
with:
46+
password: ${{ secrets.PYPI_API_TOKEN }}
47+
skip-existing: true
48+
49+
- name: Upload Release Assets
50+
uses: actions/upload-release-asset@v1
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
with:
54+
upload_url: ${{ github.event.release.upload_url }}
55+
asset_path: dist/
56+
asset_name: packages
57+
asset_content_type: application/zip

.github/workflows/test.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

pyproject.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Issues = "https://github.com/iMoonLab/Hypergraph-DB/issues"
3636
[dependency-groups]
3737
test = [
3838
"pytest>=6.0",
39+
"pytest-cov>=4.0",
40+
"pytest-xdist>=3.0",
3941
]
4042
docs = [
4143
"mkdocs>=1.5.0",
@@ -52,8 +54,13 @@ docs = [
5254
dev = [
5355
{include-group = "test"},
5456
{include-group = "docs"},
55-
"black",
56-
"isort",
57+
"black>=23.0",
58+
"isort>=5.12",
59+
"flake8>=6.0",
60+
"mypy>=1.0",
61+
"bandit>=1.7",
62+
"safety>=2.0",
63+
"twine>=4.0",
5764
"ruff>=0.12.12",
5865
]
5966

0 commit comments

Comments
 (0)