Skip to content

Commit 1826fa8

Browse files
committed
Formalize test and documentation workflows using PDM.
1 parent d491288 commit 1826fa8

File tree

3 files changed

+53
-29
lines changed

3 files changed

+53
-29
lines changed

.github/workflows/main.yaml

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,19 @@ jobs:
2525
continue-on-error: '${{ matrix.allow-failure }}'
2626
name: 'test (${{ matrix.python-version }})'
2727
steps:
28+
- name: Preserve Wasm cache
29+
uses: actions/cache@v3
30+
with:
31+
path: |
32+
~/.cache/wasmtime
33+
~/.cache/YoWASP
34+
key: ${{ runner.os }}-wasm
2835
- name: Check out source code
2936
uses: actions/checkout@v3
3037
with:
3138
fetch-depth: 0
32-
- name: Set up Python
33-
uses: actions/setup-python@v4
39+
- name: Set up PDM
40+
uses: pdm-project/setup-pdm@v3
3441
with:
3542
python-version: ${{ matrix.python-version }}
3643
- name: Install dependencies
@@ -39,24 +46,19 @@ jobs:
3946
sudo add-apt-repository 'deb http://ppa.launchpad.net/sri-csl/formal-methods/ubuntu bionic main'
4047
sudo apt-get update
4148
sudo apt-get install yices2
42-
pip install coverage codecov
43-
pip install yowasp-yosys
44-
pip install -e .[builtin-yosys]
45-
pip install -r docs/requirements.txt
46-
- name: Preserve Wasm cache
47-
uses: actions/cache@v3
48-
with:
49-
path: |
50-
~/.cache/wasmtime
51-
~/.cache/YoWASP
52-
key: ${{ runner.os }}-wasm
49+
pip install codecov yowasp-yosys
50+
pdm install --dev
5351
- name: Run tests
52+
env:
53+
YOSYS: yowasp-yosys
54+
NEXTPNR_ICE40: yowasp-nextpnr-ice40
55+
ICEPACK: yowasp-icepack
56+
SBY: yowasp-sby
57+
SMTBMC: yowasp-yosys-smtbmc
5458
run: |
55-
export AMARANTH_USE_YOSYS=builtin YOSYS=yowasp-yosys SBY=yowasp-sby SMTBMC=yowasp-yosys-smtbmc
56-
export PYTHONWARNINGS=error
57-
python -m coverage run -m unittest discover -t . -s tests
58-
unset PYTHONWARNINGS
59-
sphinx-build -b doctest docs/ docs/_build
59+
pdm run test
60+
- name: Submit code coverage
61+
run:
6062
codecov
6163

6264
document:
@@ -69,17 +71,16 @@ jobs:
6971
- name: Fetch tags from upstream repository
7072
run: |
7173
git fetch --tags https://github.com/amaranth-lang/amaranth.git
72-
- name: Set up Python
73-
uses: actions/setup-python@v4
74+
- name: Set up PDM
75+
uses: pdm-project/setup-pdm@v3
7476
with:
7577
python-version: '3.11'
7678
- name: Install dependencies
7779
run: |
78-
pip install -r docs/requirements.txt
79-
pip install .
80+
pdm install --dev
8081
- name: Build documentation
8182
run: |
82-
sphinx-build docs docs/_build
83+
pdm run document
8384
- name: Upload documentation archive
8485
uses: actions/upload-artifact@v3
8586
with:

docs/requirements.txt

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

pyproject.toml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
[build-system]
2-
requires = ["wheel", "setuptools>=67.0", "setuptools_scm[toml]>=6.2"]
3-
build-backend = "setuptools.build_meta"
1+
# Project metadata
42

53
[project]
64
dynamic = ["version", "urls"]
@@ -25,6 +23,12 @@ remote-build = ["paramiko~=2.7"]
2523
[project.scripts]
2624
amaranth-rpc = "amaranth.rpc:main"
2725

26+
# Build system configuration
27+
28+
[build-system]
29+
requires = ["wheel", "setuptools>=67.0", "setuptools_scm[toml]>=6.2"]
30+
build-backend = "setuptools.build_meta"
31+
2832
[tool.setuptools]
2933
# If amaranth 0.3 is checked out with git (e.g. as a part of a persistent editable install or
3034
# a git worktree cached by tools like poetry), it can have an empty `nmigen` directory left over,
@@ -34,3 +38,25 @@ packages = ["amaranth"]
3438

3539
[tool.setuptools_scm]
3640
local_scheme = "node-and-timestamp"
41+
42+
# Development workflow configuration
43+
44+
[tool.pdm.dev-dependencies]
45+
test = [
46+
"coverage",
47+
]
48+
docs = [
49+
"sphinx~=5.3",
50+
"sphinxcontrib-platformpicker~=1.3",
51+
"sphinx-rtd-theme~=1.2",
52+
"sphinx-autobuild",
53+
]
54+
55+
[tool.pdm.scripts]
56+
test.composite = ["test-code", "test-docs"]
57+
test-code.env = {PYTHONWARNINGS = "error"}
58+
test-code.cmd = "python -m coverage run -m unittest discover -t . -s tests -v"
59+
test-docs.cmd = "sphinx-build -b doctest docs/ docs/_build"
60+
61+
document.cmd = "sphinx-build docs/ docs/_build/"
62+
document-live.cmd = "sphinx-autobuild docs/ docs/_build/ --watch amaranth"

0 commit comments

Comments
 (0)