{"id":25527526,"url":"https://github.com/gotesttools/limgo","last_synced_at":"2025-04-11T06:12:01.142Z","repository":{"id":60492765,"uuid":"542034704","full_name":"GoTestTools/limgo","owner":"GoTestTools","description":"Simple tool to ensure the test coverage does not fall below a limit","archived":false,"fork":false,"pushed_at":"2023-10-11T10:08:09.000Z","size":233,"stargazers_count":9,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T06:11:46.437Z","etag":null,"topics":["test","test-automation","test-coverage","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GoTestTools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-27T10:47:26.000Z","updated_at":"2025-03-23T01:40:33.000Z","dependencies_parsed_at":"2023-01-30T03:16:01.685Z","dependency_job_id":null,"html_url":"https://github.com/GoTestTools/limgo","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoTestTools%2Flimgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoTestTools%2Flimgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoTestTools%2Flimgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoTestTools%2Flimgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoTestTools","download_url":"https://codeload.github.com/GoTestTools/limgo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351395,"owners_count":21089270,"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":["test","test-automation","test-coverage","testing-tools"],"created_at":"2025-02-19T22:19:28.353Z","updated_at":"2025-04-11T06:12:01.098Z","avatar_url":"https://github.com/GoTestTools.png","language":"Go","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./doc/gopher.png\" alt=\"limgo gopher\" /\u003e\n  \u003ch2 align=\"center\"\u003eLimgo\u003c/h3\u003e\n  \u003cp align=\"center\"\u003eDon't let your test coverage drop\u003c/p\u003e\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/GoTestTools/limgo/releases/latest\"\u003e\u003cimg alt=\"GitHub release\" src=\"https://img.shields.io/github/release/GoTestTools/limgo.svg?logo=github\u0026\"\u003e\u003c/a\u003e\n    \u003ca href=\"http://unlicense.org/\"\u003e\u003cimg alt=\"unlicense\" src=\"https://img.shields.io/badge/license-Unlicense-blue.svg\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/GoTestTools/limgo/actions/workflows/test.yml\"\u003e\u003cimg alt=\"Test\" src=\"https://github.com/GoTestTools/limgo/actions/workflows/test.yml/badge.svg?branch=main\"\u003e\u003c/a\u003e\n    \u003cimg src=\"https://github.com/GoTestTools/limgo/blob/limgo-badge/limgo-badge.png?raw=true\" alt=\"test coverge\" /\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n---\n\nA tool for defining and enforcing test coverage thresholds locally as well as in CI pipelines - similar to the coverage thresholds in JavaScripts popular Testing Framework [Jest](https://jestjs.io/docs/configuration#coveragethreshold-object). \n\n`limgo` builds on top of the code coverage file generated by `go test` and extends it by providing\n- a configuration schema which allows to specify test coverage thresholds\n- and a detailed view of the statement/line/branch coverage - from a module level down to every function\n\n\u003cimg src=\"./doc/example.png\" alt=\"limgo gopher\" /\u003e\n\n## Installation\n\nTo get started, install the pre-compiled `limgo` binary either manually or via `go install`. Alternatively, build it directly from source. \n\n### Manually\n\nThe `limgo` binary can be downloaded manually from the [releases section](https://github.com/GoTestTools/limgo/releases). The binaries have no dependencies and should run without any problems on any of the listed operating systems.\n\n### Using `go install`\n\nThe `limgo` binary can be installed using `go install`:\n```bash\ngo install github.com/GoTestTools/limgo/cmd/limgo@latest\n```\n\n### Building from source\n\nFirst, clone this repository via\n```bash\ngit clone https://github.com/GoTestTools/limgo.git\n```\n\nThen navigate into the `limgo` directory and build the binary: \n```bash\n# via make\nmake build\n\n# or via go directly\ngo build -o \u003coutput-name\u003e cmd/main.go\n```\n\n## Usage\n\nThe following snippet shows a basic example usage of `limgo`:\n\n```bash\n# run tests and generate coverage file\ngo test ./... -coverprofile=cov.out\n\n# verify that the coverage is not below the thresholds defined in .limgo.json\nlimgo -coverfile=cov.out -config=.limgo.json -v=3\n```\n\nAn overview as well as a short description of all supported flags can be displayed via\n```bash\nlimgo -help\n```\n\n### Output format\n\nBy default, `limgo` will output the statistic and the list of failed coverage thresholds in a tabular format (as seen above). Further, currently implemented, formats include\n```bash\n# JSON\nlimgo -coverfile=cov.out -outfmt=json\n\n# Markdown\nlimgo -coverfile=cov.out -outfmt=md\n```\n\n### The configuration file\n\nCoverage thresholds as well as statistic configuration can be defined in a configuration file. By default, `limgo` will search for a file named `.limgo.json`. This can be overridden by the `-config` flag. \n\nTo get started, the most basic configuration - an empty json - can be used:\n```json\n{}\n```\n`limgo` will, by default, always exclude the vendor directory from the statistic as well as the coverage threshold evaluation. \n\nCoverage thresholds can be defined for `statements`, `lines` and `branches`. In the example below, thresholds are defined \n- on a global (project) level\n- for all files in the \"coverage\" directory\n- for all files in the \"gosrc\" directory starting with \"g\"\n\nAlso, the dto directory is excluded from the statistc as well as from the coverage evaluation. \n```json\n{\n\t\"coverage\": {\n\t\t\"global\": {\n            \"statements\": 50,\n            \"lines\": 55,\n            \"branches\": 33\n        },\n        \"matcher\": {\n            \"pkg/coverage\": {\n                \"statements\": 70,\n                \"lines\": 70,\n                \"branches\": 33\n            },\n            \"pkg/gosrc/g.*\": {\n                \"statements\": 10,\n                \"lines\": 15,\n                \"branches\": 50\n            }\n        },\n        \"excludes\": [\n            \"dto/.*\"\n        ]\n\t},\n\t\"statistic\": {\n\t\t\"excludes\": [\n\t\t\t\"dto/.*\"\n\t\t]\n\t}\n}\n```\n\nEvery matchers key is parsed as a [regular expression](https://pkg.go.dev/regexp) and it's threshold is applied to all the files that match it. Within the `excludes` array directories and files can be excluded - this overrides any matches. \n\n## Setup in a CI system\n\nAs `limgo` is a simple binary, it is easy to set it up in any CI system. The following snippet shows an [Github Action](https://github.com/features/actions) example: \n\n```yaml\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - name: checkout repo\n        uses: actions/checkout@v2.3.4\n\n      # Checkout your project with git\n      - name: Checkout\n        uses: actions/checkout@v2\n\n      # Install Go on the VM running the action\n      - name: Set up Go\n        uses: actions/setup-go@v2\n        with:\n          go-version: 1.19\n      \n      # Option 1: \n      # install using go install\n      - name: Set up limgo - option 1\n        run: go install github.com/GoTestTools/limgo@latest\n      \n      # Option 2:\n      # install via GitHub Action\n      - name: Set up limgo - option 2\n        uses: GoTestTools/limgo-action@v1.0.1\n        with:\n          version: \"v0.0.3-beta\"\n          install-only: true\n\n      # Run tests with coverprofile\n      - name: Run tests\n        run: |\n          go test ./... -coverprofile=test.cov\n      \n      # Pass the coverprofile to limgo for coverage evaluation\n      - name: Check test coverage\n        run: |\n          limgo -covfile=test.cov -v=2\n```\n\nThe repository [limgo-action-example](https://github.com/GoTestTools/limgo-action-example) contains an example on how to use the `limgo` GitHub Action.  \n\n## Generating a badge\n\nFor generating a custom badge that visualizes the test coverage and if it meets the specified thresholds, please refer to the [limgo-badge-action](https://github.com/GoTestTools/limgo-badge-action). \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotesttools%2Flimgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotesttools%2Flimgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotesttools%2Flimgo/lists"}