Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mesonium
gajim
Commits
54d4c9f8
Commit
54d4c9f8
authored
2 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
ci: Split windows job into build and deploy stages
parent
b7cd7dcc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.ci/appveyor_build.py
+15
-13
15 additions, 13 deletions
.ci/appveyor_build.py
.ci/deploy.py
+32
-0
32 additions, 0 deletions
.ci/deploy.py
.gitlab-ci.yml
+16
-19
16 additions, 19 deletions
.gitlab-ci.yml
with
63 additions
and
32 deletions
.ci/appveyor_build.py
+
15
−
13
View file @
54d4c9f8
#!/usr/bin/env python3
#!/usr/bin/env python3
from
typing
import
Any
import
json
import
os
import
os
import
requests
import
requests
import
time
import
time
...
@@ -7,6 +10,7 @@
...
@@ -7,6 +10,7 @@
from
rich.console
import
Console
from
rich.console
import
Console
ACCOUNT
=
'
lovetox
'
ACCOUNT
=
'
lovetox
'
PROJECT_SLUG
=
'
gajim
'
PROJECT_SLUG
=
'
gajim
'
BRANCH
=
'
master
'
BRANCH
=
'
master
'
...
@@ -67,7 +71,7 @@ def is_build_finished(build: dict[str, str]) -> bool:
...
@@ -67,7 +71,7 @@ def is_build_finished(build: dict[str, str]) -> bool:
return
build
[
'
status
'
]
==
'
success
'
return
build
[
'
status
'
]
==
'
success
'
def
get_artifacts
(
build_id
:
str
)
->
None
:
def
check_for_response
(
build_id
:
str
)
->
None
:
time
.
sleep
(
INITIAL_START_DELAY
)
time
.
sleep
(
INITIAL_START_DELAY
)
while
True
:
while
True
:
time
.
sleep
(
RETRY_TIMEOUT
)
time
.
sleep
(
RETRY_TIMEOUT
)
...
@@ -89,28 +93,26 @@ def get_artifacts(build_id: str) -> None:
...
@@ -89,28 +93,26 @@ def get_artifacts(build_id: str) -> None:
build_folder
.
mkdir
()
build_folder
.
mkdir
()
for
job
in
build
[
'
jobs
'
]:
for
job
in
build
[
'
jobs
'
]:
download_job_artifacts
(
job
[
'
jobId
'
],
build_folder
)
response
=
get_job_response
(
job
[
'
jobId
'
])
result
=
build_folder
/
f
'
{
job
[
"
jobId
"
]
}
.json
'
console
.
print
(
'
All artifacts downloaded!
'
)
result
.
write_text
(
json
.
dumps
(
response
))
console
.
print
(
'
Write job response:
'
,
result
)
def
download_job_artifacts
(
job_id
:
str
,
target_folder
:
Path
)
->
None
:
def
get_job_response
(
job_id
:
str
)
->
list
[
dict
[
str
,
Any
]]
:
artifacts_api_url
=
f
'
{
BASE_URL
}
/buildjobs/
{
job_id
}
/artifacts
'
artifacts_api_url
=
f
'
{
BASE_URL
}
/buildjobs/
{
job_id
}
/artifacts
'
req
=
requests
.
get
(
artifacts_api_url
,
headers
=
HEADERS
)
req
=
requests
.
get
(
artifacts_api_url
,
headers
=
HEADERS
)
req
.
raise_for_status
()
req
.
raise_for_status
()
response
=
req
.
json
()
response
=
req
.
json
()
for
artifact
in
response
:
for
artifact
in
response
:
filename
=
artifact
[
'
fileName
'
]
file_url
=
f
'
{
artifacts_api_url
}
/
{
artifact
[
"
fileName
"
]
}
'
console
.
print
(
'
Download
'
,
filename
,
'
...
'
)
artifact
[
'
fileUrl
'
]
=
file_url
file_url
=
f
'
{
artifacts_api_url
}
/
{
filename
}
'
req
=
requests
.
get
(
file_url
,
headers
=
HEADERS
)
return
response
req
.
raise_for_status
()
with
open
(
target_folder
/
filename
,
'
wb
'
)
as
file
:
file
.
write
(
req
.
content
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
push_yaml_to_project
()
push_yaml_to_project
()
build_id
=
start_build
()
build_id
=
start_build
()
get_artifacts
(
build_id
)
check_for_response
(
build_id
)
This diff is collapsed.
Click to expand it.
.ci/deploy.py
+
32
−
0
View file @
54d4c9f8
#!/usr/bin/env python3
from
typing
import
Any
from
typing
import
Any
from
typing
import
Optional
from
typing
import
Optional
import
functools
import
functools
import
json
import
os
import
os
import
sys
import
sys
from
datetime
import
date
from
datetime
import
date
from
ftplib
import
FTP_TLS
from
ftplib
import
FTP_TLS
from
pathlib
import
Path
from
pathlib
import
Path
import
requests
from
rich.console
import
Console
from
rich.console
import
Console
...
@@ -15,6 +19,9 @@
...
@@ -15,6 +19,9 @@
FTP_USER
=
os
.
environ
[
'
FTP_USER
'
]
FTP_USER
=
os
.
environ
[
'
FTP_USER
'
]
FTP_PASS
=
os
.
environ
[
'
FTP_PASS
'
]
FTP_PASS
=
os
.
environ
[
'
FTP_PASS
'
]
API_KEY
=
os
.
environ
[
'
APPVEYOR_API_KEY
'
]
HEADERS
=
{
'
Authorization
'
:
f
'
Bearer
{
API_KEY
}
'
}
WINDOWS_NIGHTLY_FOLDER
=
'
downloads/snap/win
'
WINDOWS_NIGHTLY_FOLDER
=
'
downloads/snap/win
'
LINUX_NIGHTLY_FOLDER
=
'
downloads/snap
'
LINUX_NIGHTLY_FOLDER
=
'
downloads/snap
'
...
@@ -84,6 +91,29 @@ def upload_file(ftp: FTP_TLS,
...
@@ -84,6 +91,29 @@ def upload_file(ftp: FTP_TLS,
ftp
.
storbinary
(
'
STOR
'
+
name
,
f
)
ftp
.
storbinary
(
'
STOR
'
+
name
,
f
)
def
download_artifacts
(
path
:
Path
)
->
None
:
build_results
=
list
(
path
.
glob
(
'
*.json
'
))
if
not
build_results
:
sys
.
exit
(
'
No build build_results found
'
)
responses
=
[
json
.
loads
(
response
.
read_text
())
for
response
in
build_results
]
for
response
in
responses
:
for
artifact
in
response
:
filename
=
artifact
[
'
fileName
'
]
file_url
=
artifact
[
'
fileUrl
'
]
console
.
print
(
'
Download
'
,
filename
,
'
...
'
)
req
=
requests
.
get
(
file_url
,
headers
=
HEADERS
)
req
.
raise_for_status
()
with
open
(
path
/
filename
,
'
wb
'
)
as
file
:
file
.
write
(
req
.
content
)
for
result
in
build_results
:
result
.
unlink
()
def
get_deploy_method
()
->
str
:
def
get_deploy_method
()
->
str
:
deploy_type
=
os
.
environ
[
'
DEPLOY_TYPE
'
]
deploy_type
=
os
.
environ
[
'
DEPLOY_TYPE
'
]
is_nightly
=
bool
(
os
.
environ
.
get
(
'
GAJIM_NIGHTLY_BUILD
'
))
is_nightly
=
bool
(
os
.
environ
.
get
(
'
GAJIM_NIGHTLY_BUILD
'
))
...
@@ -95,6 +125,7 @@ def get_deploy_method() -> str:
...
@@ -95,6 +125,7 @@ def get_deploy_method() -> str:
@ftp_connection
@ftp_connection
def
deploy_windows_nightly
(
ftp
:
FTP_TLS
,
filedir
:
Path
)
->
None
:
def
deploy_windows_nightly
(
ftp
:
FTP_TLS
,
filedir
:
Path
)
->
None
:
ftp
.
cwd
(
WINDOWS_NIGHTLY_FOLDER
)
ftp
.
cwd
(
WINDOWS_NIGHTLY_FOLDER
)
download_artifacts
(
filedir
)
upload_all_from_dir
(
ftp
,
filedir
)
upload_all_from_dir
(
ftp
,
filedir
)
...
@@ -102,6 +133,7 @@ def deploy_windows_nightly(ftp: FTP_TLS, filedir: Path) -> None:
...
@@ -102,6 +133,7 @@ def deploy_windows_nightly(ftp: FTP_TLS, filedir: Path) -> None:
def
deploy_windows_release
(
ftp
:
FTP_TLS
,
filedir
:
Path
)
->
None
:
def
deploy_windows_release
(
ftp
:
FTP_TLS
,
filedir
:
Path
)
->
None
:
tag
=
get_gajim_tag
()
tag
=
get_gajim_tag
()
create_release_folder
(
ftp
,
tag
)
create_release_folder
(
ftp
,
tag
)
download_artifacts
(
filedir
)
upload_all_from_dir
(
ftp
,
filedir
)
upload_all_from_dir
(
ftp
,
filedir
)
...
...
This diff is collapsed.
Click to expand it.
.gitlab-ci.yml
+
16
−
19
View file @
54d4c9f8
...
@@ -84,22 +84,18 @@ build-linux:
...
@@ -84,22 +84,18 @@ build-linux:
paths
:
paths
:
-
dist/gajim-*.tar.gz
-
dist/gajim-*.tar.gz
build-
and-deploy-
windows
:
build-windows
:
stage
:
build
stage
:
build
dependencies
:
[]
dependencies
:
[]
rules
:
rules
:
-
if
:
'
$GAJIM_NIGHTLY_BUILD'
-
if
:
'
$GAJIM_NIGHTLY_BUILD'
-
if
:
'
$CI_COMMIT_TAG'
-
if
:
'
$CI_COMMIT_TAG'
variables
:
DEPLOY_TYPE
:
"
windows"
script
:
script
:
-
python3 .ci/appveyor_build.py
-
python3 .ci/appveyor_build.py
-
python3 .ci/deploy.py build
artifacts
:
expire_in
:
1 day
# artifacts:
paths
:
# expire_in: 1 day
-
build/*.json
# paths:
# - build/Gajim-*.exe
deploy-linux
:
deploy-linux
:
stage
:
deploy
stage
:
deploy
...
@@ -113,16 +109,17 @@ deploy-linux:
...
@@ -113,16 +109,17 @@ deploy-linux:
script
:
script
:
-
python3 .ci/deploy.py dist
-
python3 .ci/deploy.py dist
# deploy-windows:
deploy-windows
:
# stage: deploy
stage
:
deploy
# rules:
dependencies
:
# - if: '$GAJIM_NIGHTLY_BUILD'
-
build-windows
# - if: '$CI_COMMIT_TAG'
rules
:
# when: manual
-
if
:
'
$GAJIM_NIGHTLY_BUILD'
# variables:
-
if
:
'
$CI_COMMIT_TAG'
# DEPLOY_TYPE: "windows"
variables
:
# script:
DEPLOY_TYPE
:
"
windows"
# - python3 .ci/deploy.py build
script
:
-
python3 .ci/deploy.py build
deploy-flatpak
:
deploy-flatpak
:
image
:
git-deploy:latest
image
:
git-deploy:latest
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment