-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path.gitlab-ci.yml
117 lines (104 loc) · 2.75 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
stages:
- test
- static
- build
- dockerize
- release
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
DOCKER_IMAGE_NAME: "edgebox"
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- .cache/pip
- venv/
.python-base:
image: python:3.11.7
before_script:
- python -V # Print out python version for debugging
- pip install --progress-bar off poetry==1.4.2 # Install Poetry
- poetry -vvv install --no-root
mypy:
stage: static
extends: .python-base
allow_failure: true
script:
- pip install mypy
- python -m mypy */*.py
when: manual
flake8:
stage: static
extends: .python-base
allow_failure: true
script:
- pip install flake8
- flake8 --max-line=120 */*.py
when: manual
pylint:
stage: static
extends: .python-base
allow_failure: true
script:
- pip install pylint
- mkdir ./pylint
- pylint --output-format=text */*.py | tee ./pylint/pylint.log || pylint-exit $?
- PYLINT_SCORE=$(sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' ./pylint/pylint.log)
- anybadge --label=Pylint --file=pylint/pylint.svg --value=$PYLINT_SCORE 2=red 4=orange 8=yellow 10=green
- echo "Pylint score is $PYLINT_SCORE"
when: manual
artifacts:
paths:
- ./pylint/
.docker-base:
image: docker:20.10.24
services:
- docker:20.10.24-dind
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "/certs"
test:
stage: test
extends: .python-base
script:
- poetry run python -m unittest
build-package:
stage: build
extends: .python-base
script:
- poetry run python setup.py sdist bdist_wheel
artifacts:
paths:
- dist/*.whl
- dist/*.tar.gz
build-docker:
stage: dockerize
extends: .docker-base
needs: ["build-package"]
script:
- echo "Docker Hub Username ${DOCKER_HUB_USERNAME}"
- docker info
- docker build -t deleteme .
when: manual
release-package:
stage: release
extends: .python-base
only:
- tags
script:
- pip install twine
- python setup.py sdist bdist_wheel
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
- TWINE_PASSWORD=${PYPI_PASSWORD} TWINE_USERNAME=${PYPI_USERNAME} python -m twine upload --repository pypi dist/* --verbose
when: manual
release-docker:
stage: release
extends: .docker-base
only:
- tags
script:
- echo "Docker Hub Username ${DOCKER_HUB_USERNAME}"
- docker info
- docker build -t ${DOCKER_HUB_USERNAME}/${DOCKER_IMAGE_NAME}:${CI_COMMIT_TAG} .
- echo $DOCKER_HUB_ACCESS_TOKEN | docker login -u $DOCKER_HUB_USERNAME --password-stdin
- docker push ${DOCKER_HUB_USERNAME}/${DOCKER_IMAGE_NAME}:${CI_COMMIT_TAG}
when: manual