diff --git a/.github/workflows/process.yml b/.github/workflows/process.yml index f509069a83..2acb87f950 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,30 +65,24 @@ 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 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 @@ -123,13 +100,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: @@ -142,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: @@ -163,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: @@ -193,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 @@ -212,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 a302c3ac1f..5407155e3e 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"] @@ -83,17 +84,23 @@ artifacts = [ ] [tool.hatch.envs.default] -features = ["dev", "test", "docs", "lint"] +features = ["test", "docs", "lint"] [tool.hatch.envs.test] 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] diff --git a/tracking/run_tracking_inputs.py b/tracking/run_tracking_inputs.py old mode 100644 new mode 100755 index 4b865d4a5f..06da907cbf --- 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