-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
81 lines (70 loc) · 1.88 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
73
74
75
76
77
78
79
80
81
#========================
# Define pipeline stages
#========================
stages:
- lint
- test
- scan
- build
image: python:3.10
cache:
paths:
- .pip
.before_script_build: &before_script_build
before_script:
- rm -rf build dist *.egg-info
- apt-get update && apt-get install -y twine
#========================
# Define jobs
#========================
lint-code:
stage: lint
needs: [ ]
before_script:
- python -m pip install --upgrade pip
- pip install black flake8 typing_extensions isort
script:
- flake8 . --count --max-complexity=15 --max-line-length=120 --statistics --ignore W503
- black . --check --target-version=py310 --line-length=120
- isort . --check-only --profile=black --lbt=1 -l=120
unit-test:
stage: test
needs: [ ]
before_script:
- python -m pip install --upgrade pip
- pip install pytest typing_extensions
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
script:
# install local module
- pip install .
# test with Pytest
- pytest
allow_failure: true
sast:
stage: scan
needs: [ ]
dependency_scanning:
stage: scan
needs: [ ]
secret_detection:
stage: scan
needs: [ ]
license_scanning:
stage: scan
needs: [ ]
latest-image:
stage: build
<<: *before_script_build
script:
- python -m pip install --upgrade pip
- pip install build
- python -m build
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token twine upload --verbose --repository-url https://git.rabiloo.net/api/v4/projects/${CI_PROJECT_ID}/packages/pypi dist/*
only:
- master
include:
- template: Security/License-Scanning.gitlab-ci.yml
- template: Security/SAST.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml