-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
145 lines (125 loc) · 4.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
140
141
142
143
144
145
include:
- template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
TORCH_HOME: "$CI_PROJECT_DIR/.cache/torch"
SECML_HOME_DIR: "$CI_PROJECT_DIR/secml-data"
# To avoid waiting indefinitely due to opened matplotlib figures
MPLBACKEND: Agg
stages:
- test
- release
.shared_windows_runners:
tags:
- shared-windows
- windows
- windows-1809
.test-cache:
cache: &test-cache
paths:
- $PIP_CACHE_DIR
- $TORCH_HOME
- $SECML_HOME_DIR
.test-cache-py36:
cache: &test-cache-py36
key: "test-cache-py36"
<<: *test-cache
.test-cache-py36-win:
cache: &test-cache-py36-win
key: "test-cache-py36-win"
<<: *test-cache
.test-cache-py37:
cache: &test-cache-py37
key: "test-cache-py37"
<<: *test-cache
.test-cache-py38:
cache: &test-cache-py38
key: "test-cache-py38"
<<: *test-cache
.test:
stage: test
interruptible: true
before_script:
- echo $CI_PROJECT_DIR
- echo $SECML_ZOO_BRANCH
- python -V
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install pytest>=5
script:
- pip install -r requirements.txt
- py.test models/ --junitxml=pytest-report.xml
rules:
- if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH !~ /^v.*/'
variables:
SECML_ZOO_BRANCH: $CI_COMMIT_BRANCH
- when: on_success
.test-report:
artifacts: &pytest-report
reports:
junit: pytest-report.xml
expire_in: 1 week
test:py36:
extends: .test
image: python:3.6
cache: *test-cache-py36
artifacts: *pytest-report
test:py37:
extends: .test
image: python:3.7
cache: *test-cache-py37
artifacts: *pytest-report
test:py38:
extends: .test
image: python:3.8
cache: *test-cache-py38
artifacts: *pytest-report
test:py36:win:
extends:
- .test
- .shared_windows_runners
image: python:3.6
variables:
PIP_FIND_LINKS: "https://download.pytorch.org/whl/cpu/torch_stable.html"
before_script:
- echo $CI_PROJECT_DIR
- echo $SECML_ZOO_BRANCH
- choco install vcredist2017 -y
- choco install python -y --version=3.6.8
# Path is not updated by default by choco
- $env:Path += ";C:\Python36;C:\Python36\Scripts"
- python -V
# If matplotlib cannot find the following registry item tries to read the "WINDIR" env key (caps) and crashes
- New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" -Name "Fonts" -Value "C:\Windows\Fonts" -PropertyType "String"
# The https://download.pytorch.org/ certificates chain is not recognized by default as trusted
- Import-Certificate -FilePath ".gitlab\dl-pytorch-chain.p7b" -CertStoreLocation Cert:\LocalMachine\Root
- pip install virtualenv
- virtualenv venv
- venv\Scripts\activate
- pip install pytest>=5
allow_failure: true
cache: *test-cache-py36-win
artifacts: *pytest-report
.release:
stage: release
image: ${CI_REGISTRY}/pralab/docker-helper-images/alpine-release:latest
only:
variables:
- $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $RELEASE # Should be set to "vX.Y.Z" (without quotes)
release:zoo:
extends: .release
before_script:
- echo $CI_PROJECT_ID
- echo $CI_DEFAULT_BRANCH
- echo $RELEASE
script:
- RELEASE=$(echo $RELEASE | ( IFS=".$IFS" ; read a b c && echo ${a:1}.$b )) # Use Major.Minor only
- 'curl --request PUT --header "PRIVATE-TOKEN: $API_ACCESS_TOKEN" --header "Content-Type: application/json"
--data "{\"branch\": \"$CI_DEFAULT_BRANCH\", \"content\": \"git+https://gitlab.com/secml/secml#egg=secml[pytorch] >= $RELEASE.dev0\", \"commit_message\": \"Updated requirements.txt for version $RELEASE\"}"
"$CI_PROJECT_DOMAIN/api/v4/projects/$CI_PROJECT_ID/repository/files/requirements.txt"'
- 'curl --request POST --header "PRIVATE-TOKEN: $API_ACCESS_TOKEN"
"$CI_PROJECT_DOMAIN/api/v4/projects/$CI_PROJECT_ID/repository/branches?branch=v$RELEASE&ref=$CI_DEFAULT_BRANCH"'
- 'curl --request PUT --header "PRIVATE-TOKEN: $API_ACCESS_TOKEN" --header "Content-Type: application/json"
--data "{\"branch\": \"v$RELEASE\", \"content\": \"secml[pytorch] ~= $RELEASE.0\", \"commit_message\": \"Release v$RELEASE\"}"
"$CI_PROJECT_DOMAIN/api/v4/projects/$CI_PROJECT_ID/repository/files/requirements.txt"'