From e6d1504887ec5a2ac6f7bcb05c00ddadc3e6b5ab Mon Sep 17 00:00:00 2001 From: Charles Eckman Date: Sat, 22 Feb 2025 17:44:56 -0500 Subject: [PATCH 1/4] Add a CI flow --- .github/workflows/test.yml | 30 ++++++++++++++++++++++++++++++ requirements.txt | 7 +++++-- tests.do | 4 ++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..7aa2185 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Run tests + +on: + push: + branches: [ $default-branch ] + pull_request: + branches: [ $default-branch ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.11"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Run tests + run: | + ./do tests + diff --git a/requirements.txt b/requirements.txt index 0024fa9..4bc1851 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,8 +9,11 @@ git+https://github.com/amaranth-lang/amaranth-boards@9d97c4816288c9c2cc304d9280c git+https://github.com/amaranth-lang/amaranth-soc@5c43cf58f15d9cd9c69ff83c97997708d386b2dc -# Support for amaranth 0.5 - +# Support for amaranth 0.5; +# This is merged to mainline git+https://github.com/greatscottgadgets/luna@1462160ba66302aaae69dca9e54fd71498a8b3ef regex +# Dev dependencies: +flake8 +pytest diff --git a/tests.do b/tests.do index 627482c..4debd16 100644 --- a/tests.do +++ b/tests.do @@ -4,3 +4,7 @@ find . -name '*_test.py' \ | sed 's/_test.py$/.vcd/' \ | xargs redo-ifchange +# stop the build if there are Python syntax errors or undefined names +flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics +# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide +flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics From 4e46b1d67c53f2189311c83eadd4b83fa3c50e3f Mon Sep 17 00:00:00 2001 From: Charles Eckman Date: Sat, 22 Feb 2025 17:57:45 -0500 Subject: [PATCH 2/4] Enter venv before running linter --- tests.do | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests.do b/tests.do index 4debd16..98b9077 100644 --- a/tests.do +++ b/tests.do @@ -4,6 +4,8 @@ find . -name '*_test.py' \ | sed 's/_test.py$/.vcd/' \ | xargs redo-ifchange +source ./enter.sh + # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide From 71d18e955186d282ca0b1f0f3002f197d4b8b82a Mon Sep 17 00:00:00 2001 From: Charles Eckman Date: Sat, 22 Feb 2025 18:04:49 -0500 Subject: [PATCH 3/4] Don't run the linter for now --- enter.sh | 2 +- tests.do | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/enter.sh b/enter.sh index 65d8b56..363387e 100644 --- a/enter.sh +++ b/enter.sh @@ -1,6 +1,6 @@ ./do venv -source ./venv.dir/bin/activate +. ./venv.dir/bin/activate export YOSYS=yowasp-yosys export NEXTPNR_ICE40=yowasp-nextpnr-ice40 export ICEPACK=yowasp-icepack diff --git a/tests.do b/tests.do index 98b9077..cd90aaf 100644 --- a/tests.do +++ b/tests.do @@ -1,12 +1,15 @@ +# TODO: How do we get it to ignore the venv? +# stop the build if there are Python syntax errors or undefined names +# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics +# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide +# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + find . -name '*_test.py' \ | grep -v venv \ | sed 's/_test.py$/.vcd/' \ | xargs redo-ifchange -source ./enter.sh +. ./enter.sh + -# stop the build if there are Python syntax errors or undefined names -flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics -# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide -flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics From 87e5067256d2fcecc267d2ee7be68c4fe680ffbc Mon Sep 17 00:00:00 2001 From: Charles Eckman Date: Sun, 23 Feb 2025 20:24:31 -0500 Subject: [PATCH 4/4] Update sourcing in README too --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f05f056..c85a0ff 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ cat extras/fomu-serial.conf | sudo tee /etc/tlp.d/fomu-serial.conf Then try: ``` -source ./enter.sh +. ./enter.sh python usb_serial.py ```