-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
174 lines (163 loc) · 4.67 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: "$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS"
when: never
- if: "$CI_COMMIT_BRANCH || $CI_COMMIT_TAG"
stages:
- test-release
- test
- release
- scan
- sync
upload test-pypi:
stage: test-release
tags:
- docker
image: python:3.8
script:
- git clean -xfd
- pip install pipenv
- pipenv lock --dev
- pipenv install --system --dev
- python -m build --wheel
- twine upload --skip-existing --username $TESTPYPI_USERNAME --password $TESTPYPI_PASSWORD --repository testpypi dist/*
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/'
python-test:
stage: test
tags:
- docker
image: python:3.8
script:
- git clean -xfd
- pip install -e .
- pip install pytest pytest-cov
- pytest --cov=amplify_bench --cov-report term --cov-report xml:coverage.xml test
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH
python-test-full:
stage: test
tags:
- docker
image: python:3.8
script:
- git clean -xfd
- pip install -e .
- pip install pytest pytest-cov
# - pipenv run pytest --runslow --cov=amplify_bench --cov-report term --cov-report xml:coverage.xml test
- pytest --cov=amplify_bench --cov-report term --cov-report xml:coverage.xml test
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
upload pypi:
stage: release
tags:
- docker
image: python:3.8
script:
- git clean -xfd
- pip install pipenv
- pipenv lock --dev
- pipenv install --system --dev
- python -m build --wheel
- pipenv run twine upload --username $PYPI_USERNAME --password $PYPI_PASSWORD dist/*
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/'
when: manual
check-formatter:
stage: scan
tags:
- docker
image: python:3.8
script:
- git clean -xfd
- pip install pipenv
- pipenv lock --dev
- pipenv install --system --dev
- isort --check amplify_bench test
- black --check amplify_bench test
rules:
- if: $CI_COMMIT_TAG
when: never
- when: on_success
check-linter:
stage: scan
tags:
- docker
image: python:3.8
script:
- git clean -xfd
- pip install pipenv
- pipenv lock --dev
- pipenv install --system --dev
- flake8 amplify_bench test
- mypy amplify_bench
- mypy --explicit-package-bases test
rules:
- if: $CI_COMMIT_TAG
when: never
- when: on_success
check-license:
stage: scan
tags:
- docker
image: bitnami/git
script:
- bash license.sh
- >
if [[ $(git diff --name-only HEAD | grep -e amplify_bench/ || echo '') != "" ]]; then
RED="\e[31m"
END_COLOR="\e[0m"
echo ""
echo -e "${RED}######################################################################${END_COLOR}"
echo -e "${RED}# Some of the files in the src folder do not have the LICENSE block. #${END_COLOR}"
echo -e "${RED}# Please sh license.sh before committing. #${END_COLOR}"
echo -e "${RED}######################################################################${END_COLOR}"
echo ""
exit 1
fi
rules:
- if: $CI_COMMIT_TAG
when: never
- when: on_success
sync-repositories:
stage: sync
tags:
- docker
image: bitnami/git
script:
# prepare remote repositories
- git remote set-url origin https://gitlab-ci-token:$GITLAB_TOKEN@${CI_REPOSITORY_URL##*@}
- git config remote.github.url >&- && git remote set-url github https://$GITHUB_USERNAME:[email protected]/fixstars/amplify-benchmark-test.git || git remote add github https://$GITHUB_USERNAME:[email protected]/fixstars/amplify-benchmark-test.git
- git config user.email "[email protected]"
- git config user.name "GitLab Bot"
- git fetch github main
- git fetch origin main develop
- git switch develop
- git switch -C develop origin/develop
- git clean -xfd
# rebase and push
- git status
- git rebase github/main
- git push origin develop
- git push origin develop:main
- git push github develop:main
- git push --follow-tags github
rules:
- if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop" || $CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/'