-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
140 lines (123 loc) · 3.32 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---
image: python:3.7-slim-stretch
stages:
- test
- build
- deploy
variables:
package: gitlab-job-guard
before_script:
- env | sort |
perl -pe 's/((?:PASSWORD|TOKEN)=)(.*)/$1 . q[X] x length($2)/e'
- pwd; pwd -P
- python -m pip install --upgrade pip virtualenv
- virtualenv -p python venv
- . venv/bin/activate
- python -m pip install --upgrade pip setuptools virtualenv wheel
- echo '.' > requirements.txt
- pip install -e ./
- pip freeze -l --exclude-editable > requirements.txt
- awk -F"'" '
/version/ { $0=$1"'"'"$CI_COMMIT_REF_NAME"'"'"$3 }{ print $0 }
' setup.py > setup.py.tmp; mv -v setup.py.tmp setup.py
- chmod +x ./setup.py
- python ./setup.py sdist bdist_wheel
- pip install dist/gitlab-job-guard*.tar.gz
'test-py2':
stage: test
image: python:2.7-slim-stretch
script:
- python ./setup.py sdist bdist_wheel
- pip install dist/gitlab-job-guard*.tar.gz
- python2 $(which gitlab-job-guard) -c='feature/' -s 'running' -w 60;
'test-py3':
stage: test
image: python:3.7-slim-stretch
script:
- python3 $(which gitlab-job-guard) -c='feature/' -s 'running' -w 60;
'test-py3-exit-immediately':
stage: test
image: python:3.7-slim-stretch
script:
- ( set +e; gitlab-job-guard -c='.+' -s='.+' -x; [ $? = 7 ] )
'test-py3-retry-until-timeout':
stage: test
image: python:3.7-slim-stretch
script:
- ( set +e; gitlab-job-guard -c='.+' -s='.+' -w 60; [ $? = 11 ] )
'test-py3-retry-failed-until-timeout':
stage: test
image: python:3.7-slim-stretch
script:
- ( set +e;
gitlab-job-guard -c='.+' -s='failed|skipped' -w 60;
[ $? = 11 ]
)
'test-py3-retry-feature-failed-until-timeout':
stage: test
image: python:3.7-slim-stretch
script:
- ( set +e;
gitlab-job-guard -c='feature/' -s='failed|skipped' -w 60;
[ $? = 11 ]
)
'test-py3-unreachable-api-endpoint':
stage: test
image: python:3.7-slim-stretch
script:
- ( set +e;
CI_API_V4_URL='https://gitlab.local/api/v4/'
gitlab-job-guard -c='.+' -s='.+' -w 60;
[ $? = 11 ]
)
'test-py3-invalid-api-url':
stage: test
image: python:3.7-slim-stretch
script:
- ( set +e;
CI_API_V4_URL="$CI_API_V4_URL/blah-blah-blah"
gitlab-job-guard -c='.+' -s='.+' -w 60;
[ $? = 11 ]
)
'test-py3-invalid-project-id':
stage: test
image: python:3.7-slim-stretch
script:
- ( set +e;
CI_PROJECT_ID='123123123'
gitlab-job-guard -c='.+' -s='.+' -w 60;
[ $? = 11 ]
)
'test-py3-invalid-token':
stage: test
image: python:3.7-slim-stretch
script:
- ( set +e;
PRIVATE_TOKEN='abracadabra'
gitlab-job-guard -c='.+' -s='.+' -w 60;
[ $? = 11 ]
)
'build-package':
stage: build
script:
- echo "Built $package@$CI_COMMIT_REF_NAME ... "
except:
- tags
'deploy-package':
stage: deploy
environment:
name: gitlab-job-guard-package
url: $af_repo_url
script:
- echo "Deploying package to artifactory"
- echo "Deploying $package@$CI_COMMIT_REF_NAME to $af_repo_url as $af_username ..."
- python -m pip install --upgrade twine
- cat setup.py
- twine check dist/*
- twine upload
--repository-url "$af_url"
--username "$af_user"
--password "$af_password"
dist/*
only:
- tags