DIY photovoltaic power generation system makes it possible to graph and check the power generation status, but behind the scenes, software written in a programming language called Python It's working.
Published on PyPI, so please use it. You can find it like this ↓.
$ pip search tsmppt60-driver
tsmppt60-driver - Python module to get status of your solar charge controller TS-MPPT-60.
… You need to get TS-MPPT-60 in advance.
When publishing on PyPI, I thought that it would be bad if I did not write the test seriously, so I tried using unittest, doctest, nose, MiniMock.
The individual details will be turned around again, this time with CI (Continuous Integration), continuous integration material.
There is Jenkins as a famous CI tool, but since the tsmppt60-driver I made this time is pushed as OSS on github, I used the popular Travis CI. ..
When using Travis CI, the overall flow is as follows.
If you have a github account, you can hook the push to github and automatically build and test it with just a simple GUI operation on the browser, and ![Build Status](https://travis-ci. You can also display badges like org / dodo5522 / tsmppt60_driver.svg) in your README.
The setup is very easy as below.
First, jump to Travis CI and log in with Sign In With GitHub.
Then, since the cooperation with GitHub has already been completed, switch on the repository you want to CI.
In the example below, the CI of the home-automation repository is turned on.
Click the gear mark in the image above to see detailed settings and build history.
Maybe it's set to build with push as a trigger by default.
All you have to do is add the .travis.yml file set according to Travis CI Help to the GitHub repository and push it.
Since tsmppt60-driver is a python package, the settings for python are as follows.
language: python
python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
# does not have headers provided, please ask https://launchpad.net/~pypy/+archive/ppa
# maintainers to fix their pypy-dev package.
- "pypy"
# command to install dependencies
install:
- pip install .
- pip install -r requirements.txt -r test-requirements.txt
# command to run tests
script: nosetests
I keep track of the main and latest versions of Python, and pip install the necessary packages before building and testing.
requirements.txt describes the dependent packages required for tsmppt60-driver to work, and test-requirements.txt describes the dependent packages required to run the test.
$ cat requirements.txt
requests>=2.8.0
$ cat test-requirements.txt
MiniMock>=1.2.8
nose
coverage
If you put these .travis.yml, requirements.txt and test-requirements.txt in the root of the tsmppt60-driver repository and git add / commit / push, you will see the result as below.
It doesn't notify you while the build or test continues to succeed, but once it fails, it emails you like Jenkins that it failed.
You can also find how to display the build status badge in the GitHub README at Travis CI Help (https://docs.travis-ci.com/user/status-images/).
The build status display of the private repository says that the URL to the badge contains a security token, so be careful, but this repository is treated as public, so there is no problem.
Now that the test environment is in place, it's time to continue to Measure test code coverage (http://blog.rinka-blossom.com/githubnipushji-minopythonkodowo/).
Recommended Posts