- Available Hooks
- Installation
- Local Development
- License
- Bugs/Features
- Contributing
- Release and Deployment
- Changelog
This repository currently includes the following pre-commit hooks:
- scanoss-check-undeclared-code
- This hook checks for potential undeclared open source software in the files being committed.
- It is designed to run at the
pre-commit,pre-push, andmanualstages. - Configuration can be provided via command-line arguments, environment variables, or a
.envfile.
To get started with this project, you'll need to install the pre-commit package manager and configure it to use the hooks provided in this repository.
You can install pre-commit using various methods:
-
Using PIP:
pip install pre-commit
-
Using Homebrew:
brew install pre-commit
For more installation options, refer to the pre-commit documentation.
-
In the root of your project repository where you want to use these hooks, create a
.pre-commit-config.yamlfile with the following content:repos: - repo: https://github.com/scanoss/pre-commit-hooks rev: v0 hooks: - id: scanoss-check-undeclared-code
Check the latest release here
-
Verify config:
pre-commit validate-config
-
Install the pre-commit hooks:
pre-commit install
-
(Optional) Configure the hook using a
.envfile in your project root:# .env SCANOSS_API_KEY=your_api_key_here SCANOSS_SCAN_URL=https://api.scanoss.com/scan/direct HTTPS_PROXY=http://proxy.example.com:8080 SCANOSS_DEBUG=trueThe hook automatically loads environment variables from the
.envfile if it exists. You can also set these variables directly in your environment or pass them as command-line arguments. -
(Optional) Run the hooks against all files to ensure everything is in order:
pre-commit run --all-files
Note: This project requires a minimum of Python 3.9.
To develop this project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/scanoss/pre-commit-hooks.git cd pre-commit-hooks -
Create a local branch for isolated development
-
Install dev requirements:
pip install -r requirements-dev.txt
-
Set up the development environment using the Makefile:
make dev_setup
This will install the package in development mode with all necessary dependencies.
-
Set up pre-commit hooks:
pre-commit install
-
Try out the command using:
pre-commit try-repo ../pre-commit-hooks scanoss-check-undeclared-code --verbose
This will attempt to run
scanoss-check-undeclared-codeagainst thepre-commit-hooksrepo.Note: This checker requires files to be
stagedin order to be considered for processingYou can achieve this using:
git add <file>
-
When you're done with development, you can uninstall using:
make dev_uninstall
-
Contributing
Please following the contributing instructions to share updates with the community.
This project is licensed under MIT. License file can be found here.
To request features or alert about bugs, please do so here.
We welcome contributions to this project! Please clone the repository and submit a pull request with your changes. Ensure that your code passes all pre-commit checks before submitting.
This project uses automated GitHub Actions workflows to manage releases. The package is distributed through GitHub Releases and the pre-commit framework (not PyPI).
-
Update Version: Modify
__version__insrc/hooks/__init__.pyfollowing semantic versioning (MAJOR.MINOR.PATCH) -
Create Tag: Run the
tag-version.ymlworkflow manually:- Go to Actions → "Tag Version" → "Run workflow"
- The workflow compares the Python package version with the latest Git tag
- If versions differ, it creates and pushes a new tag (e.g.,
v0.3.0)
-
Automated Release: The
release.ymlworkflow triggers automatically when a tag is pushed:- Builds the package in a clean environment
- Runs verification tests (binary check,
--help, basic execution) - Creates a draft GitHub Release
-
Publish Release: A maintainer reviews and publishes the draft release manually
- Current Version Source:
src/hooks/__init__.py - Versioning Strategy: Semantic Versioning (SemVer)
- Tag Format:
v0.3.0(with 'v' prefix) - Major Version Tags: The repository maintains
v0andv1tags that point to the latest patch release, allowing users to pin to a major version and automatically receive updates
Users reference this package in their .pre-commit-config.yaml:
repos:
- repo: https://github.com/scanoss/pre-commit-hooks
rev: v0 # Pin to major version, or use v0.3.0 for specific version
hooks:
- id: scanoss-check-undeclared-codeThe pre-commit framework installs directly from the Git repository—no PyPI publishing required.
.github/workflows/tag-version.yml- Manual workflow for version tagging.github/workflows/release.yml- Automated draft release creation.github/workflows/test.yml- Continuous testing on main branch and PRs.github/workflows/update-main-version.yml- Major version tag maintenance
Details of major changes to the library can be found in CHANGELOG.md.