-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
91 lines (81 loc) · 2.35 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
image: docker:20
include:
- template: Dependency-Scanning.gitlab-ci.yml
- template: Security/License-Scanning.gitlab-ci.yml
variables:
DOCKER_DRIVER: overlay
stages:
- Test
- Deploy package
- Build image
- Push to registries
services:
- docker:dind
test:
stage: Test
variables:
PYTHONHASHSEED: "random"
script:
- apk update
- apk upgrade
- apk add -t build-dependencies python3-dev libffi-dev build-base
- apk add python3 py3-pip sqlite openssl openssl-dev ca-certificates su-exec tini
- pip3 install setuptools flake8 pytest pytest-cov wheel twine nose-py3 gunicorn cffi flask
- pip3 install -e .
- nikas --version
- touch .env.pypi
- make test
deploy:gitlab:
stage: Deploy package
image: python:latest
allow_failure: true
only:
- master
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 https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi --skip-existing dist/*
build image:
stage: Build image
script:
- NIKAS_VERSION=$(cat version.env)
- DATE_CREATED=$(date +'%Y-%m-%d')
- echo $NIKAS_VERSION
- echo $DATE_CREATED
- docker build -t $CI_REGISTRY/nikas-project/server:$NIKAS_VERSION --build-arg DATE_CREATED=$DATE_CREATED --build-arg VERSION=$NIKAS_VERSION .
- mkdir image
- docker save $CI_REGISTRY/nikas-project/server:$NIKAS_VERSION > image/gitlab.tar
artifacts:
expire_in: 5 mins
paths:
- image
push to gitlab:
stage: Push to registries
only:
- master
script:
- NIKAS_VERSION=$(cat version.env)
- docker load -i image/gitlab.tar
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push $CI_REGISTRY/nikas-project/server:$NIKAS_VERSION
dependency_scanning:
stage: .pre
variables:
DS_REMEDIATE: "false"
DS_PYTHON_VERSION: 3
PIP_REQUIREMENTS_FILE: "requirements.txt"
artifacts:
expire_in: 1 week
reports:
dependency_scanning: gl-dependency-scanning-report.json
license_scanning:
stage: .pre
variables:
CI_DEBUG_TRACE: "true"
LM_PYTHON_VERSION: 3
ASDF_PYTHON_VERSION: 3
PIP_REQUIREMENTS_FILE: "requirements.txt"
artifacts:
expire_in: 1 week
reports:
license_scanning: gl-license-scanning-report.json