{"id":18929554,"url":"https://github.com/thecodingmachine/washingmachine","last_synced_at":"2025-04-15T15:31:07.934Z","repository":{"id":57067890,"uuid":"81455263","full_name":"thecodingmachine/washingmachine","owner":"thecodingmachine","description":"CI tool that integrates with Gitlab to show variations in the CRAP index","archived":false,"fork":false,"pushed_at":"2018-08-10T07:18:31.000Z","size":486,"stargazers_count":22,"open_issues_count":4,"forks_count":1,"subscribers_count":6,"default_branch":"2.0","last_synced_at":"2025-04-11T18:59:52.785Z","etag":null,"topics":["ci","gitlab","gitlab-ci","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecodingmachine.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-02-09T13:55:17.000Z","updated_at":"2024-04-12T09:21:37.000Z","dependencies_parsed_at":"2022-08-24T14:54:08.420Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/washingmachine","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fwashingmachine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fwashingmachine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fwashingmachine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fwashingmachine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/washingmachine/tar.gz/refs/heads/2.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248630446,"owners_count":21136438,"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":["ci","gitlab","gitlab-ci","php"],"created_at":"2024-11-08T11:33:33.758Z","updated_at":"2025-04-15T15:31:07.596Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/thecodingmachine/washingmachine/v/stable)](https://packagist.org/packages/thecodingmachine/washingmachine)\n[![Total Downloads](https://poser.pugx.org/thecodingmachine/washingmachine/downloads)](https://packagist.org/packages/thecodingmachine/washingmachine)\n[![Latest Unstable Version](https://poser.pugx.org/thecodingmachine/washingmachine/v/unstable)](https://packagist.org/packages/thecodingmachine/washingmachine)\n[![License](https://poser.pugx.org/thecodingmachine/washingmachine/license)](https://packagist.org/packages/thecodingmachine/washingmachine)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/thecodingmachine/washingmachine/badges/quality-score.png?b=2.0)](https://scrutinizer-ci.com/g/thecodingmachine/washingmachine/?branch=2.0)\n[![Build Status](https://travis-ci.org/thecodingmachine/washingmachine.svg?branch=2.0)](https://travis-ci.org/thecodingmachine/washingmachine)\n[![Coverage Status](https://coveralls.io/repos/thecodingmachine/washingmachine/badge.svg?branch=2.0\u0026service=github)](https://coveralls.io/github/thecodingmachine/washingmachine?branch=2.0)\n\n\n# Washing machine\n\nThe *washing machine* is a tool that helps you writing cleaner code by integrating PHPUnit with Gitlab CI.\n\nAs a result, when you perform a merge request in Gitlab, the washing machine will add meaningful information about your code quality.\n\n## Usage\n\n### Enable Gitlab CI for your project\n\nFirst, you need a Gitlab project with continuous integration enabled (so a project with a `.gitlab-ci.yml` file).\n\n### Create a personal access token\n\nThen, you need a [Gitlab API personal access token](https://docs.gitlab.com/ce/api/README.html#personal-access-tokens).\n\nGot it?\n\n### Add a secret variable\n\nNow, we need to add this token as a \"secret variable\" of your project (so the CI script can modify the merge request comments):\n\nGo to your project page in Gitlab\n\n**Settings ➔ CI/CD Pipelines ➔ Secret Variables**\n\n- Key: `GITLAB_API_TOKEN`\n- Value: the token you just received in previous step\n\n### Configure PHPUnit to dump a \"clover\" test file\n\n\nLet's configure PHPUnit. Go to your `phpunit.xml.dist` file and add:\n\n```\n\u003cphpunit\u003e\n    \u003clogging\u003e\n        \u003clog type=\"coverage-clover\" target=\"clover.xml\"/\u003e\n    \u003c/logging\u003e\n\u003c/phpunit\u003e\n```\n\nNote: the \"clover.xml\" file must be written at the root of your GIT repository, so if your `phpunit.xml.dist` sits in a subdirectory, the correct path will be something like \"../../clover.xml\".\n\nAlternatively, washing-machine also knows how to read Crap4J files. Crap4J files contain Crap score, but not code coverage score so you will get slightly less data from Crap4J. The expected file name is \"crap4j.xml\".\n\n### Configure Gitlab CI yml file\n\nNow, we need to install the *washingmachine*, and get it to run.\n\n`.gitlab-ci.yml`\n```\nimage: php:7.1\n\ntest:\n  before_script:\n   - cd /root \u0026\u0026 composer create-project thecodingmachine/washingmachine washingmachine ^2.0\n \n  script:\n   - phpdbg -qrr vendor/bin/phpunit\n \n  after_script:\n   - /root/washingmachine/washingmachine run -v\n```\n\nNotice that we need to make sure the PHPDbg extension for PHP is installed. Also, make sure that Xdebug is NOT enabled on your Docker instance. Xdebug can also return code coverage data but is less accurate than PHPDbg, leading to wrong CRAP score results.\n\n### Supported Gitlab versions\n\n- The washingmachine v2.0+ has support for Gitlab 9+.\n\nIf you seek support for older Gitlab versions, here is a list of supported Gitlab versions by washingmachine version:\n\n- The washingmachine v1.0 =\u003e v1.2 has support for Gitlab 8.\n- The washingmachine v1.2+ has support for Gitlab 8 and up to Gitlab 9.5.\n\n### Adding extra data in the comment\n\nWhen the *washingmachine* adds a comment in your merge-request, you can ask it to add additional text.\nThis text must be stored in a file.\n\nYou simply do:\n\n```\nwashingmachine run -f file_to_added_to_comments.txt\n```\n\nOf course, this file might be the output of a CI tool.\n\nThe *washingmachine* will only display the first 50 lines of the file. If the file is longer, a link to download the file is added at the end of the comment.\n\nYou can also add several files by repeating the \"-f\" option:\n\n```\nwashingmachine run -f file1.txt -f file2.txt\n```\n\n### Opening an issue\n\nWhen a merge request is open, the *washingmachine* will post comments directly in the merge request.\n\nIf no merge request exists, the *washingmachine* can open an issue in your Gitlab project.\n\nTo open an issue, use the `--open-issue` option:\n\n```\nwashingmachine run --open-issue\n```\n\nTip: you typically want to add the `--open-issue` tag conditionally if a build fails. Also, the `--open-issue` is ignored if a merge request matches the build.\n\n### Adding comments in commits\n\nThe washingmachine can add comments directly in the commits (in addition to adding comments in the merge request).\n\nTo add comments in commits, use the `--add-comments-in-commits` option:\n\n```\nwashingmachine run --add-comments-in-commits\n```\n\nNote: this option was enabled by default in 1.x and has to be manually enabled in 2.x. For each comment, a mail is sent to the committer. This can generate a big number of mails on big commits. You have been warned :)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fwashingmachine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fwashingmachine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fwashingmachine/lists"}