Skip to content

Commit 028dfcb

Browse files
committed
setup CI/CD pipeline and enhance package metadata
Established a comprehensive CI/CD workflow and refined the package configuration to ensure robust testing, linting, and PyPI-ready distributions. Key Changes: - CI/CD: Added GitHub Actions workflow for automated testing across Python 3.8-3.13 and linting with pre-commit. - Tox Integration: Configured tox for isolated testing from wheels, code coverage collection, and automated linting. - Package Validation: Added a 'pkg' tox environment to build and validate metadata using build and twine check --strict. - Metadata: Restricted Python range to <3.14, added the official 'Framework :: cocotb' classifier, and configured coverage to omit prototypes. - Documentation: Updated README.md with status badges for CI, coverage, PyPI, and licensing. - Refactoring: Moved StreamInterface and MemoryMappedInterface to the prototypes sub-package for better architectural separation.
1 parent f353971 commit 028dfcb

17 files changed

Lines changed: 1086 additions & 196 deletions

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, devel]
6+
pull_request:
7+
branches: [main, devel]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
name: Lint with pre-commit
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.12"
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v5
24+
with:
25+
enable-cache: true
26+
- name: Install tox
27+
run: uv pip install --system tox tox-uv
28+
- name: Run pre-commit via tox
29+
run: tox run -e lint
30+
31+
pkg:
32+
name: Validate Package Metadata
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
- name: Set up Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: "3.12"
40+
- name: Install uv
41+
uses: astral-sh/setup-uv@v5
42+
with:
43+
enable-cache: true
44+
- name: Install tox
45+
run: uv pip install --system tox tox-uv
46+
- name: Build and check package
47+
run: tox run -e pkg
48+
49+
test:
50+
name: Test with tox (Python ${{ matrix.python-version }})
51+
runs-on: ubuntu-latest
52+
strategy:
53+
fail-fast: false
54+
matrix:
55+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
56+
steps:
57+
- uses: actions/checkout@v4
58+
- name: Set up Python ${{ matrix.python-version }}
59+
uses: actions/setup-python@v5
60+
with:
61+
python-version: ${{ matrix.python-version }}
62+
- name: Install uv
63+
uses: astral-sh/setup-uv@v5
64+
with:
65+
enable-cache: true
66+
- name: Install tox
67+
run: uv pip install --system tox tox-uv
68+
- name: Run tox
69+
run: tox run -e py$(echo ${{ matrix.python-version }} | tr -d .)
70+
- name: Upload coverage to Codecov
71+
uses: codecov/codecov-action@v5
72+
with:
73+
files: .tox/coverage.py${{ replace(matrix.python-version, '.', '') }}.xml
74+
fail_ci_if_error: false
75+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ jobs:
2828
- name: Set up Python
2929
uses: actions/setup-python@v3
3030
with:
31-
python-version: '3.x'
31+
python-version: "3.x"
3232
- name: Install dependencies
3333
run: |
3434
python -m pip install --upgrade pip
3535
pip install build
3636
- name: Build package
3737
run: python -m build
3838
- name: Publish package distributions to PyPI
39-
uses: pypa/gh-action-pypi-publish@release/v1
39+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ cython_debug/
182182
.abstra/
183183

184184
# Visual Studio Code
185-
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
185+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186186
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187-
# and can be added to the global gitignore or merged into this file. However, if you prefer,
187+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
188188
# you could uncomment the following to ignore the entire vscode folder
189189
# .vscode/
190190

.pre-commit-config.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: trailing-whitespace
7+
- repo: https://github.com/python-jsonschema/check-jsonschema
8+
rev: 0.36.1
9+
hooks:
10+
- id: check-github-workflows
11+
args: ["--verbose"]
12+
- repo: https://github.com/codespell-project/codespell
13+
rev: v2.4.1
14+
hooks:
15+
- id: codespell
16+
additional_dependencies: ["tomli>=2.4"]
17+
- repo: https://github.com/tox-dev/tox-ini-fmt
18+
rev: "1.7.1"
19+
hooks:
20+
- id: tox-ini-fmt
21+
args: ["-p", "lint"]
22+
- repo: https://github.com/tox-dev/pyproject-fmt
23+
rev: "v2.11.1"
24+
hooks:
25+
- id: pyproject-fmt
26+
- repo: https://github.com/astral-sh/ruff-pre-commit
27+
rev: "v0.14.14"
28+
hooks:
29+
- id: ruff-format
30+
alias: ruff
31+
args: ["--exit-non-zero-on-format"]
32+
- id: ruff-check
33+
alias: ruff
34+
args: ["--exit-non-zero-on-fix"]
35+
- repo: https://github.com/rbubley/mirrors-prettier
36+
rev: "v3.8.1"
37+
hooks:
38+
- id: prettier
39+
args: ["--print-width=120", "--prose-wrap=always"]
40+
- repo: meta
41+
hooks:
42+
- id: check-hooks-apply
43+
- id: check-useless-excludes

.vscode/settings.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"python.testing.pytestArgs": [
3-
"tests"
4-
],
5-
"python.testing.unittestEnabled": false,
6-
"python.testing.pytestEnabled": true
7-
}
2+
"python.testing.pytestArgs": ["tests"],
3+
"python.testing.unittestEnabled": false,
4+
"python.testing.pytestEnabled": true
5+
}

0 commit comments

Comments
 (0)