Skip to content

Commit

Permalink
Merge pull request #1 from kivikakk/pdm
Browse files Browse the repository at this point in the history
use pdm fully.
  • Loading branch information
kivikakk authored Jul 2, 2024
2 parents 596c602 + 915b094 commit 2381d6e
Show file tree
Hide file tree
Showing 8 changed files with 415 additions and 49 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Unit tests

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

permissions:
contents: read

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup PDM
uses: pdm-project/setup-pdm@v4

- name: Install Python dependencies
run: pdm install

- name: Install OSS CAD Suite
uses: YosysHQ/setup-oss-cad-suite@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Run tests
run: .venv/bin/pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__pycache__
/build
/dist
.pdm-python
335 changes: 335 additions & 0 deletions pdm.lock

Large diffs are not rendered by default.

30 changes: 22 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
[project]
name = "niar"
version = "0.1"
version = "0.1.1"
description = "A small framework for building projects with Amaranth"
authors = [{ name = "Asherah Connor", email = "[email protected]" }]
dependencies = ["amaranth[builtin-yosys] >= 0.5, < 0.7"]
authors = [
{ name = "Asherah Connor", email = "[email protected]" },
]
dependencies = [
"amaranth[builtin-yosys] @ git+https://github.com/amaranth-lang/amaranth.git@main",
]
requires-python = ">=3.8"
license = { text = "BSD-2-Clause" }

[project.optional-dependencies]
build = [
"amaranth-boards", # for test
]
readme = "README.md"

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

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.pdm]
distribution = true

[tool.pdm.dev-dependencies]
test = [
"pytest>=8.2.2",
"pytest-xdist>=3.6.1",
"amaranth-boards @ git+https://github.com/kivikakk/amaranth-boards@main",
]

[tool.pytest.ini_options]
addopts = ["--import-mode=importlib", "-n", "auto"]
testpaths = ["tests"]
10 changes: 1 addition & 9 deletions src/niar/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime
from typing import Optional

__all__ = ["logger", "logtime", "enable", "disable"]
__all__ = ["logger", "logtime"]

logging.basicConfig(
format="[%(asctime)s] %(name)s: %(levelname)s: %(message)s",
Expand All @@ -27,11 +27,3 @@ def logtime(level: int, activity: str, /, fail_level: Optional[int] = None):
else:
finish = datetime.now()
logger.log(level, "%s finished in %s", activity, finish - start)


def disable():
logger.disabled = True


def enable():
logger.disabled = False
32 changes: 0 additions & 32 deletions src/niar/test_cli.py

This file was deleted.

Empty file added tests/__init__.py
Empty file.
25 changes: 25 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest
from argparse import ArgumentParser

from amaranth import Elaboratable, Module
from amaranth_boards.icebreaker import ICEBreakerPlatform

from niar import Project, build, logging


class FixtureTop(Elaboratable):
def elaborate(self, platform):
return Module()


class FixtureProject(Project):
name = "fixture"
top = FixtureTop
targets = [ICEBreakerPlatform]


def test_build_works():
parser = ArgumentParser()
build.add_arguments(FixtureProject(), parser)
args, _argv = parser.parse_known_args()
args.func(args)

0 comments on commit 2381d6e

Please sign in to comment.