CI environment construction ~ Python edition ~

A free and easy way to set up a Python continuous integration environment

Services to use

-Travis CI (free CI environment) -CoverAll (a service that allows you to view the coverage of code executed by Travis CI) -Slack (Chat service that receives notifications from Travis CI)

Advance preparation

  1. Get a GitHub account
  2. Create repository
  3. Install RubyGem (used for Travis command installation)

Travis CI account acquisition and repository selection

  1. Sign in with your GitHub account from the link in the upper right
  2. Turn on the repository you want to test

Test code

tests/hoge_test.py

  1. Display "test_first"
  2. Call the index method of the Fuga class and check True.

tests/hoge_test.py


# coding:utf-8

import unittest
from fuga import Fuga

class HogeTest(unittest.TestCase):

    def setUp(self):
        print('setUp')

    def test_first(self):
        print('test_first')

    def test_fuga(self):
        fuga = Fuga()
        self.assertTrue(fuga.index())


def suite():
    suite = unittest.TestSuite()
    suite.addTests(unittest.makeSuite(HogeTest))
    return suite

tests/fuga.py

  1. ʻindex ()`: Returns True.

src/fuga.py


# coding utf-8

class Fuga:

    def index(self):
        return True

setting file

setup.py

  1. Execution environment setting script
  2. Set the path of the code to be used for sys.path.append ()
  3. Specify the test file name suite.addTests () in the code in test_suite in the format of" testfile_name.suite "

setup.py


from setuptools import setup, find_packages
import sys

sys.path.append('./src')
sys.path.append('./tests')

setup(
    name = 'Hoge',
    version = '0.1',
    description='This is test codes for travis ci',
    packages = find_packages(),
    test_suite = 'hoge_test.suite'
)

.travis.yml

  1. Travis CI configuration file
  2. python: version specification
  3. ʻinstall:` install the coversalls package with pip
  4. Run the test with the script: coverage command
  5. ʻafter_script: Execute the `coveralls command
  6. notifications: Notification settings for slack

yaml:.travis.yml


language: python

python:
  - 3.3
  - 3.4

install:
  - pip install coveralls

script:
  - coverage run --source=hoge_test setup.py test

after_success:
  - coveralls

notifications:
  slack:
    secure: your_token_key

-Refer to COVERALLS FOR PYTHON for cooperation with CoverAll. --See Configuring Build Notifications for notification settings. --See Encryption keys for how to encrypt your_token_key.

Push to GitHub

For the result display, refer to CI environment construction ~ PHP edition ~

Recommended Posts

CI environment construction ~ Python edition ~
Environment construction (python)
python environment construction
Python --Environment construction
Python environment construction
python environment construction
[Python3] Development environment construction << Windows edition >>
python windows environment construction
homebrew python environment construction
Python development environment construction
python2.7 development environment construction
Mac environment construction Python
Python environment construction @ Win7
Python + Anaconda + Pycharm environment construction
Python environment construction (Windows10 + Emacs)
Python environment construction For Mac
Anaconda3 python environment construction procedure
Python3 environment construction (for beginners)
Python environment construction and TensorFlow
Python environment construction under Windows7 environment
[MEMO] [Development environment construction] Python
Environment construction, Build -Go edition-
Environment construction of python2 & 3 (OSX)
Environment construction of python and opencv
Python environment construction memo on Windows 10
Anaconda python environment construction on Windows 10
Python + Unity Reinforcement learning environment construction
I checked Mac Python environment construction
Python environment construction memo on Mac
Python environment construction (pyenv, anaconda, tensorflow)
Python development environment construction on macOS
Python environment construction (pyenv + poetry + pipx)
Environment construction of python3.8 on mac
Python3 environment construction with pyenv-virtualenv (CentOS 7.3)
Python3 TensorFlow for Mac environment construction
Emacs Python development environment construction memo
pytorch @ python3.8 environment construction with pipenv
[docker] python3.5 + numpy + matplotlib environment construction
Python3.6 environment construction (using Win environment Anaconda)
OpenCV3 & Python3 environment construction on Ubuntu
Django environment construction
[Ubuntu 18.04] Python environment construction with pyenv + pipenv
Python (anaconda) development environment construction procedure (SpringToolsSuites) _2020.4
DeepIE3D environment construction
Emacs-based environment construction
Linux environment construction
Python project environment construction procedure (for windows)
python environment settings
python windows environment
[Python] Road to snake charmer (1) Environment construction
django environment construction
Python3 + venv + VSCode + macOS development environment construction
CodeIgniter environment construction
VScode environment construction (Windows10, Python, C ++, C, Git)
Environment construction procedure: Ubuntu + Apache2 + Python + Pyramid
Python and machine learning environment construction (macOS)
Golang environment construction
Let's get along with Python # 0 (Environment construction)
Windows + gVim + Poetry python development environment construction
Word2vec environment construction
Python3 TensorFlow environment construction (Mac and pyenv virtualenv)