Static analysis of Python code with GitLab CI

This is a memo because I did static analysis of Python code using GitLab CI. I couldn't find a subtly simple introduction article, so I hope it helps someone.

Purpose

--GitLab uses the SaaS version, that is, the Web browser version --And no charge

yml file creation

Create .gitlab-ci.yml in the root directory.

yml:.gitlab-ci.yml


#Specify Docker Image
image: python:latest

#Where to save the cache
variables:
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

#Introduced virtualenv to cache what you pip installed
cache:
  paths:
    - .cache/pip
    - venv/

#Pre-execution script
before_script:
  - python -V
  - pip install virtualenv
  - virtualenv venv
  - source venv/bin/activate

#Use a stage called test
#I didn't like the length of 79 characters or less, so I ignored it.
test:
  script:
    # - python setup.py test
    - pip install flake8
    - flake8 *.py --exclude venv/,.cache --ignore E501
  only:
    refs:
      - merge_requests

Run

Make a merge request that includes this file. The round and round test begins to rotate. If you pass the test, you will be able to merge.

Recommended Posts

Static analysis of Python code with GitLab CI
Static analysis of Python programs
Data analysis with python 2
Convert the character code of the file with Python3
Voice analysis with python
Data analysis with Python
[Blender x Python] Think of code with symbols
[OpenCV / Python] I tried image analysis of cells with OpenCV
Challenge principal component analysis of text data with Python
List of Python code used in big data analysis
Planar skeleton analysis with Python (4) Handling of forced displacement
Get country code with python
Python with VS Code (Windows 10)
[Python] Morphological analysis with MeCab
[Co-occurrence analysis] Easy co-occurrence analysis with Python! [Python]
Sentiment analysis with Python (word2vec)
Debug Python with VS Code
Planar skeleton analysis with Python
Japanese morphological analysis with Python
Muscle jerk analysis with Python
Document Python code with Doxygen
3. Natural language processing with Python 5-1. Concept of sentiment analysis [AFINN-111]
Perform isocurrent analysis of open channels with Python and matplotlib
Mass generation of QR code with character display by Python
3D skeleton structure analysis with Python
Impedance analysis (EIS) with python [impedance.py]
Text mining with Python ① Morphological analysis
Getting Started with Python Basics of Python
Life game with Python! (Conway's Game of Life)
10 functions of "language with battery" python
Implementation of Dijkstra's algorithm with python
Data analysis starting with python (data visualization 1)
Logistic regression analysis Self-made with python
Coexistence of Python2 and 3 with CircleCI (1.0)
Data analysis starting with python (data visualization 2)
Install python with mac vs code
Basic study of OpenCV with Python
Practical exercise of data analysis with Python ~ 2016 New Coder Survey Edition ~
Let's summarize the degree of coupling between modules with Python code
Image processing with Python 100 knocks # 4 Binarization of Otsu (discriminant analysis method)
From the introduction of JUMAN ++ to morphological analysis of Japanese with Python
Installation of Visual studio code and installation of python
Basics of binarized image processing with Python
[Python] Automate Pelican builds with Travis CI
Marketing analysis with Python ① Customer analysis (decyl analysis, RFM analysis)
Two-dimensional saturated-unsaturated osmotic flow analysis with Python
Execute Python script with cron of TS-220
Machine learning with python (2) Simple regression analysis
Check the existence of the file with python
Algorithm learned with Python 8th: Evaluation of algorithm
2D FEM stress analysis program with Python
Clogged with python update of GCP console ①
Easy introduction of speech recognition with Python
[Python3] Rewrite the code object of the function
Example of 3D skeleton analysis by Python
I tried to get the authentication code of Qiita API with Python.
Source code of sound source separation (machine learning practice series) learned with Python
Sentiment analysis of tweets with deep learning
Tweet analysis with Python, Mecab and CaboCha
UnicodeEncodeError struggle with standard output of python3
1. Statistics learned with Python 1-3. Calculation of various statistics (statistics)