Try CIing the pushed python code on GitHub.

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.

  1. Travis CI account registration (can be linked with GitHub account)
  2. Select the CI target GitHub repository on the Travis CI web settings screen.
  3. Add the .travis.yml file configured according to Travis CI help to your GitHub repository

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

Try CIing the pushed python code on GitHub.
Python: Try using the UI on Pythonista 3 on iPad
Try touching the micro: bit with VS Code + Python
Try the Python LINE Pay SDK
Memorize the Python commentary on YouTube.
Try using the Python Cmd module
[Python] Read the Flask source code
Sakura Use Python on the Internet
Quickly install OpenCV 2.4 (+ python) on OS X and try the sample
I tried using the COTOHA API (there is code on GitHub)
Disguise the grass on GitHub and try to become an engineer.
Put Cabocha 0.68 on Windows and try to analyze the dependency with Python
Try using the Wunderlist API in Python
Execute Python code on C ++ (using Boost.Python)
Discover the most yabe functions on github
Try using the Kraken API in Python
Try python
[Python3] Rewrite the code object of the function
[Python] Try pydash of the Python version of lodash
Download files on the web with Python
Clone the github repository on jupyter notebook
Try to write python code to generate go code --Try porting JSON-to-Go and so on
Python amateurs try to summarize the list ①
Run Python code on A2019 Community Edition
[Python] Get the character code of the file
Try hitting the YouTube API in Python
Get the EDINET code list in Python
[Python] A progress bar on the terminal
Notes on using code formatter in Python
python setup.py test the code using multiprocess
Try to solve the traveling salesman problem with a genetic algorithm (Python code)
I stumbled on the character code when converting CSV to JSON in Python
Visualize the timeline of the number of issues on GitHub assigned to you in Python
Build a Docker image containing the private repository Python library on GitHub Actions
[Python] Read the source code of Bottle Part 2
Try the python version of emacs-org parser orgparse
Quickly display the QR code on the command line
Try to solve the Python class inheritance problem
[Cloudian # 7] Try deleting the bucket in Python (boto3)
Try using a QR code on a Raspberry Pi
Try to solve the man-machine chart with Python
Try using the BitFlyer Ligntning API in Python
Try using the Python web framework Tornado Part 1
[Python] Read the source code of Bottle Part 1
Try the free version of Progate [Python I]
Building multiple Python environments on the same system
Try working with Mongo in Python on Mac
Introduction to Python with Atom (on the way)
Sound the buzzer using python on Raspberry Pi 3!
Try using the collections module (ChainMap) of python3
Code for checking the operation of Python Matplotlib
At the time of python update on ubuntu
Until the Sphinx documentation is published on GitHub
Convert the character code of the file with Python3
Try using the Python web framework Tornado Part 2
Try implementing the Monte Carlo method in Python
Try accessing the YQL API directly from Python 3
Try importing MLB data on Mac and Python
Try using the DropBox Core API in Python
Python on Windows
twitter on python3