From 1826fa83bd176e7e96ec1beff986fd7d5a3397f7 Mon Sep 17 00:00:00 2001 From: Catherine Date: Mon, 24 Jul 2023 12:21:55 +0000 Subject: [PATCH] Formalize test and documentation workflows using PDM. --- .github/workflows/main.yaml | 47 +++++++++++++++++++------------------ docs/requirements.txt | 3 --- pyproject.toml | 32 ++++++++++++++++++++++--- 3 files changed, 53 insertions(+), 29 deletions(-) delete mode 100644 docs/requirements.txt diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b2fe4cc..397da8f 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -25,12 +25,19 @@ jobs: continue-on-error: '${{ matrix.allow-failure }}' name: 'test (${{ matrix.python-version }})' steps: + - name: Preserve Wasm cache + uses: actions/cache@v3 + with: + path: | + ~/.cache/wasmtime + ~/.cache/YoWASP + key: ${{ runner.os }}-wasm - name: Check out source code uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v4 + - name: Set up PDM + uses: pdm-project/setup-pdm@v3 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -39,24 +46,19 @@ jobs: sudo add-apt-repository 'deb http://ppa.launchpad.net/sri-csl/formal-methods/ubuntu bionic main' sudo apt-get update sudo apt-get install yices2 - pip install coverage codecov - pip install yowasp-yosys - pip install -e .[builtin-yosys] - pip install -r docs/requirements.txt - - name: Preserve Wasm cache - uses: actions/cache@v3 - with: - path: | - ~/.cache/wasmtime - ~/.cache/YoWASP - key: ${{ runner.os }}-wasm + pip install codecov yowasp-yosys + pdm install --dev - name: Run tests + env: + YOSYS: yowasp-yosys + NEXTPNR_ICE40: yowasp-nextpnr-ice40 + ICEPACK: yowasp-icepack + SBY: yowasp-sby + SMTBMC: yowasp-yosys-smtbmc run: | - export AMARANTH_USE_YOSYS=builtin YOSYS=yowasp-yosys SBY=yowasp-sby SMTBMC=yowasp-yosys-smtbmc - export PYTHONWARNINGS=error - python -m coverage run -m unittest discover -t . -s tests - unset PYTHONWARNINGS - sphinx-build -b doctest docs/ docs/_build + pdm run test + - name: Submit code coverage + run: codecov document: @@ -69,17 +71,16 @@ jobs: - name: Fetch tags from upstream repository run: | git fetch --tags https://github.com/amaranth-lang/amaranth.git - - name: Set up Python - uses: actions/setup-python@v4 + - name: Set up PDM + uses: pdm-project/setup-pdm@v3 with: python-version: '3.11' - name: Install dependencies run: | - pip install -r docs/requirements.txt - pip install . + pdm install --dev - name: Build documentation run: | - sphinx-build docs docs/_build + pdm run document - name: Upload documentation archive uses: actions/upload-artifact@v3 with: diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index e862aba..0000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -sphinx~=5.3 -sphinxcontrib-platformpicker~=1.3 -sphinx-rtd-theme~=1.2 diff --git a/pyproject.toml b/pyproject.toml index 84cdc11..6bad763 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,4 @@ -[build-system] -requires = ["wheel", "setuptools>=67.0", "setuptools_scm[toml]>=6.2"] -build-backend = "setuptools.build_meta" +# Project metadata [project] dynamic = ["version", "urls"] @@ -25,6 +23,12 @@ remote-build = ["paramiko~=2.7"] [project.scripts] amaranth-rpc = "amaranth.rpc:main" +# Build system configuration + +[build-system] +requires = ["wheel", "setuptools>=67.0", "setuptools_scm[toml]>=6.2"] +build-backend = "setuptools.build_meta" + [tool.setuptools] # If amaranth 0.3 is checked out with git (e.g. as a part of a persistent editable install or # a git worktree cached by tools like poetry), it can have an empty `nmigen` directory left over, @@ -34,3 +38,25 @@ packages = ["amaranth"] [tool.setuptools_scm] local_scheme = "node-and-timestamp" + +# Development workflow configuration + +[tool.pdm.dev-dependencies] +test = [ + "coverage", +] +docs = [ + "sphinx~=5.3", + "sphinxcontrib-platformpicker~=1.3", + "sphinx-rtd-theme~=1.2", + "sphinx-autobuild", +] + +[tool.pdm.scripts] +test.composite = ["test-code", "test-docs"] +test-code.env = {PYTHONWARNINGS = "error"} +test-code.cmd = "python -m coverage run -m unittest discover -t . -s tests -v" +test-docs.cmd = "sphinx-build -b doctest docs/ docs/_build" + +document.cmd = "sphinx-build docs/ docs/_build/" +document-live.cmd = "sphinx-autobuild docs/ docs/_build/ --watch amaranth"