-
Notifications
You must be signed in to change notification settings - Fork 3
Pre-Commit #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre-Commit #37
Conversation
I found one concern by trying out source tests/venv/bin/activate
pre-commit install
deactivate
rm -rf tests/venv # NOTE: This happens as part of 'make clean' I have to manually undo the effects of It looks like this PR has no automatic effect on CI. I see no impact on CI, so if I forgot to run So, it looks like this PR adds a beneficial way to guarantee a pre-commit script runs, but only for people who can run These are technical questions that are incidental to the main policy question: Will |
I haven't yet experienced the With regards to the CI, |
@kchason I left most of how to re-produce the issue in the Bash snippet above. Please let me know if you want me to script the whole toe-stubbing. Meanwhile, I thought of another solution that avoids the
My current thinking is to make a dedicated virtual environment in the repository root, once, and not delete it on .venv-pre-commit/var/built.log:
rm -rf .venv-pre-commit
python3 -m venv .venv-pre-commit
source .venv-pre-commit/bin/activate && pip install pre-commit
source .venv-pre-commit/bin/activate && pre-commit install
mkdir -p .venv-pre-commit/var
touch $@ If this rule is an How do we feel about making a persistent virtual environment? |
This dedicated virtual environment is intended to persist through `make clean`, not disrupting the ability to run regular Git commits if the "primary" virtual environment is removed. The `pre-commit` experience it produces should align make- and local-venv-oriented users with users who have a more global availability of `pre-commit`. References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Another behavior I've observed, which is likely to impact Say a file is edited, but not staged for committing (no It seems that this temporary removal keeps text editor sessions with that edited file open happy because it happens and then reverts quickly enough that the editor either doesn't have time to complain about losing its open file. However, the stash push-pop cycle updates the timestamp on the edited file. This will cause an impact on a So, overall impact of incorporating |
References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
References: * casework/CASE-Utilities-Python#37 * https://github.com/psf/black/blob/main/docs/integrations/source_version_control.md Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
I've been trying this in a few other repositories. It has some behaviors that induce mildly unpleasant side effects for Make and Vim users related to I'm going to add a Make step to set up that dedicated pre-commit virtual environment, but otherwise there's only one last matter I'd like to know for this PR: The version of Black listed in the pre-commit setup is hard-coded. What is the practice you'd suggest for keeping that decently fresh? Should we make a pre-release checklist for pull requests into |
Disclaimer: Participation by NIST in the creation of the documentation of mentioned software is not intended to imply a recommendation or endorsement by the National Institute of Standards and Technology, nor is it intended to imply that any specific software is necessarily the best available for the purpose. References: * [AC-215] Evaluate pre-commit usage on casework repositories * [AC-216] Apply Black to all casework Python code bases * casework#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Disclaimer: Participation by NIST in the creation of the documentation of mentioned software is not intended to imply a recommendation or endorsement by the National Institute of Standards and Technology, nor is it intended to imply that any specific software is necessarily the best available for the purpose. References: * [AC-215] Evaluate pre-commit usage on casework repositories * [AC-216] Apply Black to all casework Python code bases * casework#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Disclaimer: Participation by NIST in the creation of the documentation of mentioned software is not intended to imply a recommendation or endorsement by the National Institute of Standards and Technology, nor is it intended to imply that any specific software is necessarily the best available for the purpose. References: * [AC-215] Evaluate pre-commit usage on casework repositories * casework#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
@kchason , I added three commits to the If you agree with the three commits, please merge them into your branch so this PR will pick them up. I still look forward to hearing what you think is practical for handling keeping the hard-coded versions fresh. |
@kchason , I've pushed a catch-up merge that handles what apparently has become a merge conflict since your branch state. Can you please catch your branch up with the |
Should be all set now |
Thanks! I'll merge once CI passes. |
References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Pre-commit usage was evaluated here: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
References: * casework/CASE-Utilities-Python#37 * #373
A follow-on patch will apply Python changes based on pre-commit review. References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
It is not clear why this file was not regenerated earlier. Current suspected reason is `pre-commit`'s Git operations updating timestamps, causing `make` to think it was already up to date. `make clean && make` regenerated this. References: * ucoProject/UCO#383 * casework/CASE-Utilities-Python#37 (comment) Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
This implementation was copied from case-utils. A follow-on patch will apply pre-commit effects. References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
A follow-on patch will add pre-commit to CI. References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
A follow-on patch will add pre-commit to CI. References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
This patch only applies mechanical changes from a tool used in the CASE Python utilities. References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Issues 38 and 41 began discussions on a testing framework that would eventually include static type review. Work done recently with @sldouglas-nist has been adding type signatures. Testing of each submitted pull request has included a manual run of `mypy` against some objective script files within INDXParse. This patch begins automating the review of type signatures, following the results of some discussions on Issue 38 - namely, use of Make. Make is used for the static type review, intentionally instead of `pre-commit`, due to a certain behavior that could arise: If `pre-commit` encounters any failure that it can't automatically fix, the user in their local editing environment is prevented from completing the `git commit` command. A change to a type signature can have a wide- ranging effect, and this patch is added to prevent that user-experience. (Some of this has been discussed at further length in `case-utils` PR 37, where `pre-commit` was added to another project.) The Makefile added in this patch runs `mypy` review over selected files analyzed to date, with the expectation that eventually the command will become `mypy indxparse`, not enumerating specific files. The GitHub Action is updated to include `make check` (parameterized for the runner's selected Python) as the last step run. The Makefile also confirms that the package installs in a Python 3 virtual environment, and incorporates the `mypy` package through a new feature, `testing`. Disclaimer: Participation by NIST in the creation of the documentation of mentioned software is not intended to imply a recommendation or endorsement by the National Institute of Standards and Technology, nor is it intended to imply that any specific software is necessarily the best available for the purpose. References: * casework/CASE-Utilities-Python#37 * williballenthin#38 * williballenthin#41 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
This patch draws on Cyber Domain Ontology deployments from the noted PRs. References: * casework/CASE-Utilities-Python#37 * Cyber-Domain-Ontology/CDO-Shapes-Example#1 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Text adapted from contributions to `case-utils` by @kchason. Disclaimer: Participation by NIST in the creation of the documentation of mentioned software is not intended to imply a recommendation or endorsement by the National Institute of Standards and Technology, nor is it intended to imply that any specific software is necessarily the best available for the purpose. References: * casework/CASE-Utilities-Python#37 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
pre-commit
pre-commit
to run in the GitHub Actions