Differences
This shows you the differences between two versions of the page.
linux_wiki:managed_gitlab_ci_python_example [2019/07/16 23:22] billdozor created |
linux_wiki:managed_gitlab_ci_python_example [2019/07/20 14: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 a 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: | ||
</ | </ | ||
* 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/ | ||
+ | |||
+ | stages: | ||
+ | - build | ||
+ | - test | ||
+ | |||
+ | build: | ||
+ | # 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/ | ||
+ | |||
+ | test:test script security: | ||
+ | # Check for security issues - warn about them | ||
+ | stage: test | ||
+ | allow_failure: | ||
+ | script: " | ||
+ | ... | ||
+ | </ | ||
---- | ---- | ||