Repo Grep Checks
Verify the existence or contents of files or folders in your repo.
After setting up a Git Repository Integration, OpsLevel can continuously scan your code repositories and verify all of the operational best practices you’ve defined.
Repo Grep Checks operate very similarly to Repo File Checks. As such, we recommend reading the docs on Repo File and Repo Search Checks before beginning to experiment further with Repo Grep Checks. Note that we also have a special Package Version check as well, which may cover your use case.
The Repo Grep Check
With Repo Grep Checks, you can verify the existence or contents of files or folders in your repo. While Repo File and Repo Search Checks can resolve most use-cases, there are certain circumstances with which Repo Grep Checks can offer additional capabilities. For example:
- Searching multiple specific files
- Searching using glob patterns
- Searching for certain special characters
- Repo Grep checks support exists, fixed-string, regex, and version constraints
Repo Grep Check Examples
Ensure services are declaring code ownership
You may have a mandate for all services to declare code owners within their repo. While these could exist in a /CODEOWNERS
file, there might be situations where a legacy service define owners in a .github
folder, or in the /docs
folder as supported by GitHub. If both of these are permissible, you can use Repo Grep Checks to ensure at least one of the files exists:
Predicate | File Paths |
---|---|
Exists | /CODEOWNERS, /.github/CODEOWNERS, /docs/CODEOWNERS |
Note: A glob pattern of **/CODEOWNERS
would not be recommended in this case, as **
does not include hidden folders. For other use cases where inclusion of hidden folders is needed, extglob
patterns are supported and can be used.
Ensure JavaScript services lock their dependencies using yarn or npm
You may have a policy that all JavaScript services use yarn
or npm
. You can use Repo Grep Checks to make sure this policy is being followed:
Predicate | File Paths |
---|---|
Exists | package-lock.json, yarn.lock |
Ensure Python services no longer use the deprecated "plank" library
Say you have a policy that all Python services can no longer use a deprecated library called plank
. You can use Repo Grep Checks to enforce this policy:
Predicate | Search Term | File Paths |
---|---|---|
Does Not Contain | import plank | **/*.py |
And More!
Those were just some examples to get the creative juices flowing. But there’s tons more you can do with Repo Grep Checks. If you have any questions, or just come up with some interesting checks you want to share, hit us up at [email protected].
Updated 6 months ago