-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
267 lines (253 loc) · 8.04 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# Copyright (c) 2023-∞ blurryroots innovation qanat OÜ
---
image: thinkbiq/ue-plugin-staging:latest
stages:
- pre-release-test
- build
- release
- grace
- post-release-test
- finalize
test-functional:
stage: pre-release-test
rules:
# This ensures that only pushes to the default branch are considered.
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
when: manual
allow_failure: true
# This ensures that only pushes to the staging / testing branch
- if: $CI_COMMIT_REF_NAME == "staging"
allow_failure: false
script:
- make pip-update-all
- make run-tests
test-security:
stage: pre-release-test
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
when: manual
allow_failure: true
- if: $CI_COMMIT_REF_NAME == "staging"
allow_failure: false
- if: $CI_COMMIT_REF_NAME == "release"
allow_failure: false
script:
- make pip-update-all
- make audit
test-linting:
stage: pre-release-test
rules:
# This ensures that only pushes to the default branch are considered.
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
allow_failure: true
# This ensures that only pushes to the staging / testing branch
- if: $CI_COMMIT_REF_NAME == "staging"
allow_failure: false
script:
- make pip-update-all
- make lint
build-wheel:
stage: build
rules:
- if: $CI_COMMIT_REF_NAME == "release"
allow_failure: false
- if: $CI_COMMIT_REF_NAME == "staging"
allow_failure: false
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
when: manual
allow_failure: false
script:
- make pip-update-all
- make readme-build
- make release
- export VERSION_TAG=$(etc/./query-tag-most-relevant-version.sh)
- echo "VERSION_TAG=${VERSION_TAG}" > pypi.env
- export WHEEL_FILE_NAME="piper_whistle-${VERSION_TAG}-py3-none-any.whl"
- echo "WHEEL_FILE_NAME=${WHEEL_FILE_NAME}" >> pypi.env
- export DEP_URL_BASE="https://pypi.debian.net/piper-whistle"
- export WHEEL_FILE_URL="${DEP_URL_BASE}/${WHEEL_FILE_NAME}"
- echo "WHEEL_FILE_URL=${WHEEL_FILE_URL}" >> pypi.env
- echo "pypi.env:"
- cat pypi.env
- echo "Generating release page for ${VERSION_TAG} ..."
- if ! etc/./query-tag-message.sh ${VERSION_TAG} > release-notes.md; then
echo "Could not query tag ${VERSION_TAG}. Defaulting to empty.";
echo "" > release-notes.md;
fi
- echo "release-notes.md:"
- cat release-notes.md
artifacts:
paths:
- build/release
- release-notes.md
reports:
dotenv: pypi.env
release-pypi-test:
stage: release
rules:
# This ensures that only pushes to the staging / testing branch
- if: $CI_COMMIT_REF_NAME == "staging"
allow_failure: false
# or main branch are considered.
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
when: manual
allow_failure: true
needs:
- job: build-wheel
artifacts: true
script:
- python3 -m pip install twine
- etc/./upload-pypi.sh testpypi "${PYPI_CONFIG_FILE}" build/release/*
release-pypi:
stage: release
rules:
- if: $CI_COMMIT_REF_NAME == "release"
allow_failure: false
needs:
- job: build-wheel
artifacts: true
script:
- echo "Uploading ..."
- ls -lav build/release
- python3 -m pip install twine
- etc/./upload-pypi.sh pypi "${PYPI_LIVE_CONFIG_FILE}" build/release/*
artifacts:
paths:
- release-notes.md
- build/release
release-gitlab:
image: registry.gitlab.com/gitlab-org/release-cli:latest
stage: release
rules:
- if: $CI_COMMIT_REF_NAME == "release"
allow_failure: true
needs:
- job: build-wheel
artifacts: true
script:
- echo Tag name = "${VERSION_TAG}"
- echo Release name = "piper-whistle ${VERSION_TAG} wheel"
- echo Release notes = "$(cat release-notes.md)"
- echo Wheel file link = "${WHEEL_FILE_URL}"
release:
name: 'piper-whistle ${VERSION_TAG} wheel'
description: 'release-notes.md'
tag_name: '${VERSION_TAG}'
ref: '$CI_COMMIT_SHA'
assets:
links:
- name: '${WHEEL_FILE_NAME}'
url: '${WHEEL_FILE_URL}'
sync-github:
stage: release
rules:
# This ensures that only pushes to the release branch trigger sync.
- if: $CI_COMMIT_REF_NAME == "release"
allow_failure: true
# or main branch are considered.
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
when: manual
allow_failure: true
script:
- apt-get update -y
- apt-get install -yqqf openssh-client sshpass --fix-missing
- eval $(ssh-agent -s)
- cat "${GITHUB_DEPLOY_KEY_FILE}" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan ${GITHUB_DEPLOY_DOMAIN} >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- git config --global user.email "${GITHUB_USER_EMAIL}"
- git config --global user.name "${GITHUB_USER_NAME}"
- git fetch --all
- git checkout staging
- git checkout release
- git checkout main
- git remote rm origin 2> /dev/null
- git remote add origin ${GITHUB_REPO_LINK}
- git push --all
- git push --tags
release-github:
stage: release
rules:
- if: $CI_COMMIT_REF_NAME == "release"
allow_failure: true
needs:
- job: build-wheel
artifacts: true
- job: sync-github
script:
- echo Tag name = "${VERSION_TAG}"
- echo Release name = "piper-whistle ${VERSION_TAG} wheel"
- echo Release notes = "$(cat release-notes.md)"
- echo Wheel file link = "${WHEEL_FILE_URL}"
- echo "Uploading release "${VERSION_TAG}" to github ..."
- python3 -m src.tools.rota github-release
--token-file "${GITHUB_API_KEY_FILE}"
--attachment "build/release/${WHEEL_FILE_NAME}"
think-biq/piper-whistle release "${VERSION_TAG}" "$(cat release-notes.md)"
delay-before-checking-pypi-test:
# Helps give pypi index time to refresh cache.
stage: grace
rules:
# This ensures that only pushes to the staging / testing branch
- if: $CI_COMMIT_REF_NAME == "staging"
variables:
DELAY_IN_SECONDS: 13
script:
- echo "Sleeping for ${DELAY_IN_SECONDS} seconds ..."
- sleep ${DELAY_IN_SECONDS}
- echo "Done."
test-release-pypi-test:
stage: post-release-test
rules:
# This ensures that only pushes to the default branch are considered.
- if: $CI_COMMIT_REF_NAME == "staging"
allow_failure: true
script:
- python3 -m pip install -U pip
# Need to setup test as well as live repository, to properly resolve
# all piper-whistle dependencies. Force the staged version, as to skip
# the live version, since live repo seems to have precedence.
- export PGK_NAME="piper_whistle==$(python3 -m src.piper_whistle.version)"
- etc/./install-test-pypi.sh ${PGK_NAME}
- piper_whistle -h
- echo "Setting up search index ..."
- piper_whistle refresh
- echo "Checking if HU is supported ..."
- if [ "hu_HU" = "$(piper_whistle guess hung)" ];
then echo "Found hungarian language support";
else exit 13;
fi
- echo "Checking if model at index 1 is available ..."
- piper_whistle list -U -l hu_HU -i 1
- echo "Installing model 1 ..."
- piper_whistle install hu_HU 1
- echo "Fetching path of model 1 ..."
- export HU_VOICE_INFO=$(piper_whistle list -S -l hu_HU -i 1)
- export VOICE_NAME="$(echo ${HU_VOICE_INFO} | awk '{ print $1 }')"
- piper_whistle path ${VOICE_NAME}
pages:
stage: finalize
rules:
# This ensures that only pushes to the release branch trigger sync.
- if: $CI_COMMIT_REF_NAME == "release"
allow_failure: true
# or main branch are considered.
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
when: manual
allow_failure: true
script:
- echo "Install requirements ..."
- make pip-update-all
- echo "Building documentation ..."
- make docs-build
- echo "Exposing as public ..."
- mv docs/published public
- echo "Result:"
- ls -lav public
- echo "Hosting ..."
artifacts:
paths:
# The folder that contains the files to be exposed at the Page URL
- public