{"id":13788104,"url":"https://github.com/anderseknert/pre-commit-opa","last_synced_at":"2026-01-04T00:42:04.428Z","repository":{"id":47754768,"uuid":"237276304","full_name":"anderseknert/pre-commit-opa","owner":"anderseknert","description":"Pre-commit git hooks for Open Policy Agent (OPA) and Rego development","archived":false,"fork":false,"pushed_at":"2022-02-14T08:19:41.000Z","size":89,"stargazers_count":66,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-14T20:50:41.847Z","etag":null,"topics":["conftest","git-hooks","opa","openpolicyagent","pre-commit","pre-commit-hooks","rego"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anderseknert.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-30T18:19:57.000Z","updated_at":"2024-09-02T13:06:08.000Z","dependencies_parsed_at":"2022-07-26T05:16:51.969Z","dependency_job_id":null,"html_url":"https://github.com/anderseknert/pre-commit-opa","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anderseknert%2Fpre-commit-opa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anderseknert%2Fpre-commit-opa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anderseknert%2Fpre-commit-opa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anderseknert%2Fpre-commit-opa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anderseknert","download_url":"https://codeload.github.com/anderseknert/pre-commit-opa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244538587,"owners_count":20468745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conftest","git-hooks","opa","openpolicyagent","pre-commit","pre-commit-hooks","rego"],"created_at":"2024-08-03T21:00:36.875Z","updated_at":"2026-01-04T00:42:04.370Z","avatar_url":"https://github.com/anderseknert.png","language":null,"readme":"# pre-commit-opa\n\n![Python application](https://github.com/anderseknert/pre-commit-opa/workflows/build/badge.svg)\n\n[Pre-commit](https://pre-commit.com/) git hooks for Open Policy Agent (OPA) and Rego development\n\n\u003cimg src=\"assets/pre-commit.svg\" width=150\u003e\u003cimg src=\"assets/opa.png\" width=150\u003e\n\n### Using pre-commit-opa with pre-commit\n\nAdd the `pre-commit-opa` repo to the `.pre-commit-config.yaml` file in your git root directory, and add any number of the available hooks:\n\n```yaml\nrepos:\n- repo: https://github.com/anderseknert/pre-commit-opa\n  rev: v1.4.1\n  hooks:\n  - id: opa-fmt\n  - id: opa-check\n  - id: opa-test\n  - id: conftest-test\n  - id: conftest-verify\n```\n\nOnce saved, run `pre-commit install` to install git pre-commit hooks.\n\n### Hooks available\n\n#### `opa-fmt`\nRuns `opa fmt` on any rego files in the repository.\n\nNote that any files changed by this hook will need to be re-added (`git add`) to be included in the commit.\n\n#### `opa-check`\nRuns `opa check` on any rego files in the repository.\n\n#### `opa-test`\nIf rego files are present in commit, runs `opa test` in git root directory.\n\nSince it doesn't make sense to only provide `opa test` with the files changed (as these might not include tests), the default is to run `opa test .` in the project root directory. If you keep your policies, tests and data in a specific directory, you'll likely want to change this by pointing out the location of that, like:\n\n```yaml\n- id: opa-test\n  args: ['my/policies', 'my/other/policies/']\n```\n\n#### `conftest-fmt`\nRuns `conftest fmt` on any Rego files in the repository.\n\nNote that any files changed by this hook will need to be re-added (`git add`) to be included in the commit.\n\n#### `conftest-test`\nRuns `conftest test` on any configuration file format supported by conftest.\n\nJust like with `opa-test` you'll likely want to specify the location of your conftest policies, and possibly what type of files changed should trigger the hook:\n\n```yaml\n- id: conftest-test\n  args: ['--policy', 'conftest/policy']\n  files: conftest/.*\\.yaml$\n```\n\n#### `conftest-verify`\nIf rego files are present in commit, runs `conftest verify` in git root directory.\n\nJust like with `conftest-test` you'll likely want to specify the location of your conftest policies, and possibly what type of files changed should trigger the hook:\n\n```yaml\n- id: conftest-verify\n  args: ['--policy', 'conftest/policy']\n  files: conftest/.*\\.yaml$\n```\n","funding_links":[],"categories":["Tools and Utilities"],"sub_categories":["Serverless Blogs and Articles","Testing Blogs and Articles"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanderseknert%2Fpre-commit-opa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanderseknert%2Fpre-commit-opa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanderseknert%2Fpre-commit-opa/lists"}