-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
72 lines (63 loc) · 2.09 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
variables:
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE
DEBIAN_FRONTEND: "noninteractive"
FF_TIMESTAMPS: true
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PIP_DEFAULT_TIMEOUT: 120
TAG_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
TAG_COMMIT: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
# https://pip.pypa.io/en/stable/topics/caching/
cache:
paths:
- .cache/
- .cache/pip
- "$CI_PROJECT_DIR/.cache/pip"
services:
- docker:20.10.16-dind
stages:
- secrets_detection
- tests
.install_dependencies:
image: python:3.9.19-slim
before_script:
- pwd ; ls -la ; python --version ; pip --version
- pip install -r tests/requirements.txt
- pip install -e .
# Static Application Security Testing: https://docs.gitlab.com/ee/user/application_security/sast/
sast:
stage: secrets_detection
# Secret Detection: https://docs.gitlab.com/ee/user/application_security/secret_detection/
secret_detection:
stage: secrets_detection
# Dependency Scanning: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/
dependency_scanning:
stage: secrets_detection
# Python tests
test:
stage: tests
extends: .install_dependencies
needs: [secret_detection]
script:
- python -m cProfile -s time -o profile_verbose -m pytest --cov --cov-report term --cov-report xml:coverage.xml
- echo -e 'sort cumtime\nreverse\nstats' | python -m pstats profile_verbose > profile_summary.txt
- coverage xml -o coverage.xml
- ls -la
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
paths:
- coverage.xml
- report.xml
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
junit: report.xml
when: always
tags: [runner]
only:
changes:
- "**/*.py"
include:
- template: Security/SAST.gitlab-ci.yml
- template: Jobs/Secret-Detection.gitlab-ci.yml
- template: Jobs/Dependency-Scanning.gitlab-ci.yml