Skip to content

Commit 2381d6e

Browse files
authored
Merge pull request #1 from kivikakk/pdm
use pdm fully.
2 parents 596c602 + 915b094 commit 2381d6e

File tree

8 files changed

+415
-49
lines changed

8 files changed

+415
-49
lines changed

.github/workflows/unit-tests.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Unit tests
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
unit-tests:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repo
17+
uses: actions/checkout@v4
18+
19+
- name: Setup PDM
20+
uses: pdm-project/setup-pdm@v4
21+
22+
- name: Install Python dependencies
23+
run: pdm install
24+
25+
- name: Install OSS CAD Suite
26+
uses: YosysHQ/setup-oss-cad-suite@v3
27+
with:
28+
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Run tests
31+
run: .venv/bin/pytest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
__pycache__
22
/build
33
/dist
4+
.pdm-python

pdm.lock

Lines changed: 335 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
[project]
22
name = "niar"
3-
version = "0.1"
3+
version = "0.1.1"
44
description = "A small framework for building projects with Amaranth"
5-
authors = [{ name = "Asherah Connor", email = "[email protected]" }]
6-
dependencies = ["amaranth[builtin-yosys] >= 0.5, < 0.7"]
5+
authors = [
6+
{ name = "Asherah Connor", email = "[email protected]" },
7+
]
8+
dependencies = [
9+
"amaranth[builtin-yosys] @ git+https://github.com/amaranth-lang/amaranth.git@main",
10+
]
711
requires-python = ">=3.8"
812
license = { text = "BSD-2-Clause" }
9-
10-
[project.optional-dependencies]
11-
build = [
12-
"amaranth-boards", # for test
13-
]
13+
readme = "README.md"
1414

1515
[project.urls]
1616
Homepage = "https://github.com/kivikakk/niar"
1717

1818
[build-system]
1919
requires = ["pdm-backend"]
2020
build-backend = "pdm.backend"
21+
22+
[tool.pdm]
23+
distribution = true
24+
25+
[tool.pdm.dev-dependencies]
26+
test = [
27+
"pytest>=8.2.2",
28+
"pytest-xdist>=3.6.1",
29+
"amaranth-boards @ git+https://github.com/kivikakk/amaranth-boards@main",
30+
]
31+
32+
[tool.pytest.ini_options]
33+
addopts = ["--import-mode=importlib", "-n", "auto"]
34+
testpaths = ["tests"]

src/niar/logging.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from datetime import datetime
44
from typing import Optional
55

6-
__all__ = ["logger", "logtime", "enable", "disable"]
6+
__all__ = ["logger", "logtime"]
77

88
logging.basicConfig(
99
format="[%(asctime)s] %(name)s: %(levelname)s: %(message)s",
@@ -27,11 +27,3 @@ def logtime(level: int, activity: str, /, fail_level: Optional[int] = None):
2727
else:
2828
finish = datetime.now()
2929
logger.log(level, "%s finished in %s", activity, finish - start)
30-
31-
32-
def disable():
33-
logger.disabled = True
34-
35-
36-
def enable():
37-
logger.disabled = False

src/niar/test_cli.py

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

tests/__init__.py

Whitespace-only changes.

tests/test_cli.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import pytest
2+
from argparse import ArgumentParser
3+
4+
from amaranth import Elaboratable, Module
5+
from amaranth_boards.icebreaker import ICEBreakerPlatform
6+
7+
from niar import Project, build, logging
8+
9+
10+
class FixtureTop(Elaboratable):
11+
def elaborate(self, platform):
12+
return Module()
13+
14+
15+
class FixtureProject(Project):
16+
name = "fixture"
17+
top = FixtureTop
18+
targets = [ICEBreakerPlatform]
19+
20+
21+
def test_build_works():
22+
parser = ArgumentParser()
23+
build.add_arguments(FixtureProject(), parser)
24+
args, _argv = parser.parse_known_args()
25+
args.func(args)

0 commit comments

Comments
 (0)