From 09463e9ae5fcf6b98ee5592f1df7a82892032d60 Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Wed, 7 Jan 2026 14:37:56 +0000 Subject: [PATCH 1/3] Use hatch to run tests on CI --- .github/workflows/process.yml | 56 +++++++++++------------------------ pyproject.toml | 11 +++++-- 2 files changed, 26 insertions(+), 41 deletions(-) diff --git a/.github/workflows/process.yml b/.github/workflows/process.yml index f509069a8..149fa4425 100644 --- a/.github/workflows/process.yml +++ b/.github/workflows/process.yml @@ -12,20 +12,17 @@ permissions: jobs: unit-test: + strategy: + matrix: + os: [ubuntu-latest, macos-latest] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: Install PROCESS - # Editable install to match default install - run: | - pip install -e '.[test]' - - name: Run unit tests + - name: Setup python and hatch + uses: Fusion-Power-Plant-Framework/fppf-actions/setup-hatch@main + - name: Run unit tests with coverage report run: | - pytest --cov=process tests/unit -v \ - --cov-report xml + hatch run test:tests-cov tests/unit - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 env: @@ -37,37 +34,23 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - name: Setup python and hatch + uses: Fusion-Power-Plant-Framework/fppf-actions/setup-hatch@main with: python-version: '3.10' - - name: Install PROCESS - # Editable install to match default install - run: | - pip install -e '.[test]' - - name: Install poppler - run: | - sudo apt update - sudo apt install poppler-utils - name: Run integration tests - run: pytest tests/integration -n auto -v + run: hatch run test-default:tests tests/integration example-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - name: Setup python and hatch + uses: Fusion-Power-Plant-Framework/fppf-actions/setup-hatch@main with: python-version: '3.10' - - name: Install PROCESS - # Editable install to match default install - run: | - pip install -e '.[test, examples]' - - name: Install poppler - run: | - sudo apt update - sudo apt install poppler-utils - - name: Run example notebook tests - run: pytest tests/examples -n auto -v + - name: Run example tests + run: hatch run test-default:tests tests/examples regression-test: runs-on: ubuntu-latest @@ -82,17 +65,12 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v5 + - name: Setup python and hatch + uses: Fusion-Power-Plant-Framework/fppf-actions/setup-hatch@main with: python-version: '3.10' - - name: Install PROCESS - # Editable install to match default install - run: | - pip install -e '.[test]' - - name: Allow git commands to be run - run: git config --global --add safe.directory '*' - name: Run regression tests - run: pytest tests/regression -sv --reg-tolerance=${{ matrix.tolerance }} + run: hatch run test-default:tests tests/regression --reg-tolerance=${{ matrix.tolerance }} run-tracking-inputs: runs-on: ubuntu-latest diff --git a/pyproject.toml b/pyproject.toml index a302c3ac1..11a7e87ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,8 @@ test = [ "requests>=2.30", "testbook>=0.4", "pytest-cov>=3.0.0", - "pytest-xdist>=2.5.0" + "pytest-xdist>=2.5.0", + "process[examples]" ] examples = ["jupyter==1.0.0"] plotly = ["plotly>=5.15.0,<6"] @@ -90,10 +91,16 @@ features = ["test"] [[tool.hatch.envs.test.matrix]] python = ["3.10", "3.11", "3.12", "3.13"] [tool.hatch.envs.test.scripts] -tests = "pytest {args:tests}" +tests = "pytest -n auto -v {args:tests}" tests-cov = "pytest --cov process --cov-report html:htmlcov --cov-report xml {args:tests}" tests-cov-private = "pytest --private --cov process --cov-report html:htmlcov --cov-report xml {args:tests}" +[tool.hatch.envs.test-default] +template="test" +[[tool.hatch.envs.test-default.matrix]] +python = ["3.10"] + + [tool.hatch.envs.docs] features = ["docs"] [tool.hatch.envs.docs.scripts] From 47540bcdf1a8bdfb783e3af4e12b4797584af0e0 Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Wed, 7 Jan 2026 14:42:35 +0000 Subject: [PATCH 2/3] Use hatch for quality job --- .github/workflows/process.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/process.yml b/.github/workflows/process.yml index 149fa4425..78ac272e5 100644 --- a/.github/workflows/process.yml +++ b/.github/workflows/process.yml @@ -101,13 +101,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - name: Setup python and hatch + uses: Fusion-Power-Plant-Framework/fppf-actions/setup-hatch@main with: python-version: '3.10' - - name: Install dev dependencies - run: pip install '.[lint]' - name: Run pre-commit - run: pre-commit run --all-files + run: hatch run lint:fmt tracking: concurrency: From 1459a541d23499ecddb45735fd4ff1aadd48db64 Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Wed, 7 Jan 2026 15:22:19 +0000 Subject: [PATCH 3/3] Use hatch to run tracking and docs scripts --- .github/workflows/process.yml | 27 ++++++++++++--------------- pyproject.toml | 2 +- tracking/run_tracking_inputs.py | 1 + 3 files changed, 14 insertions(+), 16 deletions(-) mode change 100644 => 100755 tracking/run_tracking_inputs.py diff --git a/.github/workflows/process.yml b/.github/workflows/process.yml index 78ac272e5..2acb87f95 100644 --- a/.github/workflows/process.yml +++ b/.github/workflows/process.yml @@ -77,13 +77,12 @@ jobs: if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - name: Setup python and hatch + uses: Fusion-Power-Plant-Framework/fppf-actions/setup-hatch@main with: python-version: '3.10' - - name: Install PROCESS - run: pip install -e '.[lint, docs, test]' - name: Run regression input files - run: python tracking/run_tracking_inputs.py run tests/regression/input_files + run: hatch run python tracking/run_tracking_inputs.py run tests/regression/input_files - name: Move other files run: mv tests/regression/input_files/*.json tracking/ - name: Archive tracked MFILEs @@ -119,11 +118,10 @@ jobs: COMMIT_MESSAGE: ${{ github.event.head_commit.message }} steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - name: Setup python and hatch + uses: Fusion-Power-Plant-Framework/fppf-actions/setup-hatch@main with: python-version: '3.10' - - name: Install PROCESS - run: pip install -e '.[test, docs, lint]' - name: Setup SSH identity uses: webfactory/ssh-agent@v0.7.0 with: @@ -140,9 +138,9 @@ jobs: run: | MSG=$(printf "%q " $COMMIT_MESSAGE) git config --global --add safe.directory '*' - python tracking/run_tracking_inputs.py track process-tracking-data "${MSG}" ${{ github.sha }} + hatch run python tracking/run_tracking_inputs.py track process-tracking-data "${MSG}" ${{ github.sha }} - name: Create the tracking dashboard - run: python tracking/tracking_data.py plot process-tracking-data --out tracking.html + run: hatch run python tracking/tracking_data.py plot process-tracking-data --out tracking.html - name: Archive tracking dashboard uses: actions/upload-artifact@v4 with: @@ -170,12 +168,11 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v4 + - name: Setup python and hatch + uses: Fusion-Power-Plant-Framework/fppf-actions/setup-hatch@main with: python-version: '3.10' - - name: Install PROCESS - run: pip install -e '.[test, lint, docs]' - - run: python scripts/vardes.py + - run: hatch run python scripts/vardes.py - run: git config --global --add safe.directory '*' - name: Download STF_TF.json files uses: actions/download-artifact@v4 @@ -189,10 +186,10 @@ jobs: path: tracking/ - run: mv tracking/large_tokamak_nof.SIG_TF.json tracking/large_tokamak_nof_SIG_TF.json - name: Create an example plot proc - run: python process/io/plot_proc.py -f tracking/large_tokamak_nof_MFILE.DAT + run: hatch run python process/io/plot_proc.py -f tracking/large_tokamak_nof_MFILE.DAT - name: Move plot proc file to docs images run: mv tracking/large_tokamak_nof_MFILE.DATSUMMARY.pdf documentation/images/plot_proc.pdf - - run: mkdocs build + - run: hatch run docs:build - name: Download tracking html uses: actions/download-artifact@v4 with: diff --git a/pyproject.toml b/pyproject.toml index 11a7e87ca..5407155e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,7 +84,7 @@ artifacts = [ ] [tool.hatch.envs.default] -features = ["dev", "test", "docs", "lint"] +features = ["test", "docs", "lint"] [tool.hatch.envs.test] features = ["test"] diff --git a/tracking/run_tracking_inputs.py b/tracking/run_tracking_inputs.py old mode 100644 new mode 100755 index 4b865d4a5..06da907cb --- a/tracking/run_tracking_inputs.py +++ b/tracking/run_tracking_inputs.py @@ -1,3 +1,4 @@ +#!python """Run the tracked files and move into tracking directory.""" import argparse