{"id":16114762,"url":"https://github.com/solarliner/implementing-testing","last_synced_at":"2025-04-06T08:17:26.928Z","repository":{"id":80989117,"uuid":"99472836","full_name":"SolarLiner/implementing-testing","owner":"SolarLiner","description":"A test repo for me to figure this shit out, and in the future, a guide for you because you don't have to be alone in this.","archived":false,"fork":false,"pushed_at":"2017-08-07T08:10:59.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T13:54:09.792Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/SolarLiner.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-06T08:06:04.000Z","updated_at":"2017-08-06T17:19:41.000Z","dependencies_parsed_at":"2023-03-12T12:57:20.253Z","dependency_job_id":null,"html_url":"https://github.com/SolarLiner/implementing-testing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLiner%2Fimplementing-testing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLiner%2Fimplementing-testing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLiner%2Fimplementing-testing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLiner%2Fimplementing-testing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SolarLiner","download_url":"https://codeload.github.com/SolarLiner/implementing-testing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247451658,"owners_count":20940944,"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":[],"created_at":"2024-10-09T20:15:41.384Z","updated_at":"2025-04-06T08:17:26.911Z","avatar_url":"https://github.com/SolarLiner.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Implementing automatic testing and coverage checking for your GitHub repo\n\nApparently I'm the only person here who doesn't know how to do this so this may be useless. Nevertheless it helps me understand. Here is a small guide to get your project tested automatically, with coveage reports.  \nSince it seems like every node.js programmer seems to know how to do this, we'll focus on Python.\n\nWe will use Travis CI, Codacy and Coveralls, which are all free for open-source projects. (Thanks guys for doing this!). I'm assuming you know how to sign up using GitHub, and select your project(s) in those services by yourself. \n\n## Step 1: Write code.\n\nWether your routine starts with code or with tests, you should first get your codebase up and running. Having nothing to test will seriously impair your ability to add automatic testing to such (nonexistant) code.\n\n## Step 2: Checking code coverage\n\nWe'll first setup coverage on Coveralls, then on Codacy. I find it better to start with this rather than Travis as you'll come to build your scripts along while setting up coverage, and then you'll only have to plug them in Travis to automate the process.\n\n### [Coveralls](https://coveralls.io/) [![Coverage Status](https://coveralls.io/repos/github/SolarLiner/implementing-testing/badge.svg?branch=master)](https://coveralls.io/github/SolarLiner/implementing-testing?branch=master)\n\nCoveralls's interface with python is `python-coveralls` which is available in `pip`. Continue by create a configuration file for it by creating a new file at the root:`.coveralls.yml`, and edit it to add your repo\\_token. Find your repo\\_token in the settings on the Coveralls project.\n\nOnce everything is setup, simply run  `coverage run $FILES \u0026\u0026 coverage xml \u0026\u0026 coveralls`, with `$FILES` being the entry point of your app.\n\n### [Codacy](https://www.codacy.com/) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/762b882cc76a4fddbd56587dfcbc275d)](https://www.codacy.com/app/solarliner/implementing-testing?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=SolarLiner/implementing-testing\u0026amp;utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/762b882cc76a4fddbd56587dfcbc275d)](https://www.codacy.com/app/solarliner/implementing-testing?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=SolarLiner/implementing-testing\u0026utm_campaign=Badge_Coverage)\n\nIn order to send coverage to Codacy you'll need to install the python package `codacy-coverage` or similar for your language In Ubuntu 16.04+. You'll need to install and activate `virtualenv` for your repository as to avoid conflicts with the patched version of pip Canonical offers.\n\nThen, it's a matter of running your tests, `coverage run $FILES \u0026\u0026 coverage xml` and then `CODACY_PROJECT_TOKEN=$TOKEN python-codacy-coverage`. You can read more about setting up Codacy [here](https://support.codacy.com/hc/en-us/articles/207993835-Add-coverage-to-your-repo).  \nNote that you don't need to run coverage twice, simply chain codacy after coveralls.\n\nAlthough we focused on code coverage with Codacy, the service offers much more analytics of your code.  \nYou don't need neither services; you can choose only one or the other or a different service should one fit your needs better.\n\n## Step 2: Automation\n\nNow that we have everything ready, we'll strap Travis CI onto our repo. For the end user, Travis will be the most important part of the project as it will be able to test and build your project for you.  \nOnce you've activated Travis for your repo, check \"build only if travis.yml is present\". You may want to activate a daily or weekly build of your project, depending on how often it is updated.\n\n### Configuring Travis CI [![Build Status](https://travis-ci.org/SolarLiner/implementing-testing.svg?branch=master)](https://travis-ci.org/SolarLiner/implementing-testing)\n\nOnce we have all of our scripts ready, configuring Travis will be fairly simple. Add a `.travis.yml` file at the root of your repo and add the following lines:\n```yaml\ndist: xenial\nlanguage: python\npython:\n    - \"2.7\" # List all supported versions of python here\n\ninstall: pip install -r pip_req_test.txt\nscript: scripts/test.sh\nafter_success: scripts/coverage.sh\n```\n\nChange accordingly but the configuration should be present otherwise.  \nNote that the different build steps are ran in order: `install \u003e script \u003e after_success | after_failure`. For a complete doc about the configuration, refer to the Travis doc: \u003chttps://docs.travis-ci.com/user/customizing-the-build\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolarliner%2Fimplementing-testing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolarliner%2Fimplementing-testing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolarliner%2Fimplementing-testing/lists"}