You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently, Slicer developers are required to call the script Utilities/SetupForDevelopment.sh before crafting local commits and creating a branch that will be contributed as a pull request. This script performs various tasks, including checking if the Git environment is configured1, configuring git hooks2, and providing developer tips3.
However, once a pull request is created, multiple GitHub Workflows are triggered to perform operations like building Slicer (CI (Build) workflow) and running pre-commit hooks (CI (Lint) workflow) defined in the .pre-commit-config.yaml file.
The issue lies in the differences between the checks executed through the CI (Lint) workflow and those configured through SetupForDevelopment.sh. Additionally, developers can install pre-commit and run it locally in a Python virtual environment, but this requires configuring the virtual environment.
Problems:
Inconsistencies between CI (Lint) checks and those configured in SetupForDevelopment.sh.
The need to manually set up a virtual environment for running pre-commit4 or ruff.
Configuration complexity for developers.
Describe the solution you'd like
To streamline the developer workflow and remove the need for explicit virtual environment setup, consider the following steps:
Update SetupForDevelopment.sh to check if a local installation of Python exists and ask if the developer wants to create a virtual environment called Slicer/.git/.venv-slicer-build.
If such an environment can be created, ask the developer if they would like to run pre-commit install5. This ensures that hooks (e.g., linting and reformatting) are executed locally during commits.
If there is no Slicer/.git/.venv-slicer-build environment, create it instead in ~/Slicer-SuperBuild/.venv-slicer-build, but do not install pre-commit, as the build tree may not exist.
Regardless of the .venv-slicer-build location:
Install the latest stable versions of the pre-commit and ruff Python packages.
Add convenience targets named RunPreCommit and RunRuff to both the SuperBuild and the inner build (excluding them from ALL) and add tests checking they can run successfully.
jcfr
changed the title
Streamline execution of pre-commit tooling from a build tree.
Streamline local execution of pre-commit tooling
Nov 3, 2023
jcfr
changed the title
Streamline local execution of pre-commit tooling
Streamline Local Execution of Pre-commit Tooling and Simplify Developer Workflow
Nov 3, 2023
Is your feature request related to a problem? Please describe.
Currently, Slicer developers are required to call the script
Utilities/SetupForDevelopment.sh
before crafting local commits and creating a branch that will be contributed as a pull request. This script performs various tasks, including checking if the Git environment is configured1, configuring git hooks2, and providing developer tips3.However, once a pull request is created, multiple GitHub Workflows are triggered to perform operations like building Slicer (
CI (Build)
workflow) and runningpre-commit
hooks (CI (Lint)
workflow) defined in the.pre-commit-config.yaml
file.Slicer/.pre-commit-config.yaml
Lines 4 to 17 in ce04529
The issue lies in the differences between the checks executed through the
CI (Lint)
workflow and those configured throughSetupForDevelopment.sh
. Additionally, developers can installpre-commit
and run it locally in a Python virtual environment, but this requires configuring the virtual environment.Problems:
CI (Lint)
checks and those configured inSetupForDevelopment.sh
.pre-commit
4 orruff
.Describe the solution you'd like
To streamline the developer workflow and remove the need for explicit virtual environment setup, consider the following steps:
Update
SetupForDevelopment.sh
to check if a local installation of Python exists and ask if the developer wants to create a virtual environment calledSlicer/.git/.venv-slicer-build
.pre-commit install
5. This ensures that hooks (e.g., linting and reformatting) are executed locally during commits.If there is no
Slicer/.git/.venv-slicer-build
environment, create it instead in~/Slicer-SuperBuild/.venv-slicer-build
, but do not installpre-commit
, as the build tree may not exist.Regardless of the
.venv-slicer-build
location:Install the latest stable versions of the
pre-commit
andruff
Python packages.Add convenience targets named
RunPreCommit
andRunRuff
to both the SuperBuild and the inner build (excluding them fromALL
) and add tests checking they can run successfully.Describe alternatives you've considered
NA
Additional context
Originally posted by @lassoan in #7338 (comment)
Footnotes
https://github.com/Slicer/Slicer/blob/main/Utilities/Scripts/SetupUser.sh ↩
https://github.com/Slicer/Slicer/blob/main/Utilities/Scripts/SetupHooks.sh ↩
https://github.com/Slicer/Slicer/blob/main/Utilities/Scripts/GitTips.sh ↩
Locally running the
pre-commit
hook is possible usingpre-commit run --a
(orpre-commit run --all-files
orpre-commit run --all-files
) ↩https://pre-commit.com/#pre-commit-install ↩
The text was updated successfully, but these errors were encountered: