[[linux_wiki:managed_gitlab_ci_python_example]]

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

linux_wiki:managed_gitlab_ci_python_example [2019/07/17 03:22]
billdozor created
linux_wiki:managed_gitlab_ci_python_example [2019/07/20 18:50] (current)
billdozor
Line 23: Line 23:
 ---- ----
  
-====== CI File ======+====== CI File Examples ​======
  
 The .gitlab-ci.yml file belongs in the root of your project. The .gitlab-ci.yml file belongs in the root of your project.
  
-Create, commit and push file like this<code yaml .gitlab-ci.yml>​---+Create, commit and push the file to your project. 
 + 
 +---- 
 + 
 +===== Python CI with Pip Installs ===== 
 + 
 +<code yaml .gitlab-ci.yml>​---
 # GitLab CI Job # GitLab CI Job
 # Check python files syntax and security # Check python files syntax and security
Line 77: Line 83:
 </​code>​ </​code>​
   * Note: This ci file could be shorter if the testing image you pull down already had black and bandit installed.   * Note: This ci file could be shorter if the testing image you pull down already had black and bandit installed.
 +
 +----
 +
 +===== Python CI no installs =====
 +
 +<code yaml .gitlab-ci.yml>​---
 +# GitLab CI Job
 +# Check python files syntax and security
 +
 +# Docker image based on latest python 3
 +image: whowe/​py3tester
 +
 +stages:
 +    - build
 +    - test
 +
 +build:​verify packages:
 +    # Verify required packages for testing
 +    stage: build
 +    script:
 +        - "which bandit"​
 +        - "which black"
 +
 +test:script syntax:
 +    # Check syntax and formatting
 +    stage: test
 +    script:
 +        - "black --check *.py"
 +        - "black --check unit-tests/​*.py"​
 +
 +test:test script security:
 +    # Check for security issues - warn about them
 +    stage: test
 +    allow_failure:​ true
 +    script: "​bandit --recursive *.py"
 +...
 +</​code>​
  
 ---- ----
  
  • linux_wiki/managed_gitlab_ci_python_example.txt
  • Last modified: 2019/07/20 18:50
  • by billdozor