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.
--GitLab uses the SaaS version, that is, the Web browser version --And no charge
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
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