Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.ci/deploy.py70
-rwxr-xr-x.ci/sdist.py36
-rw-r--r--.gitlab-ci.yml13
-rw-r--r--pyrightconfig.json5
4 files changed, 89 insertions, 35 deletions
diff --git a/.ci/deploy.py b/.ci/deploy.py
index e8099d22d..b2603943e 100644
--- a/.ci/deploy.py
+++ b/.ci/deploy.py
@@ -1,17 +1,24 @@
+from typing import Any
+from typing import Optional
+
+import functools
import os
import sys
+from datetime import date
from ftplib import FTP_TLS
from pathlib import Path
-import functools
-from typing import Any
from rich.console import Console
+
FTP_URL = 'panoramix.gajim.org'
FTP_USER = os.environ['FTP_USER']
FTP_PASS = os.environ['FTP_PASS']
-WINDOWS_NIGHTLY_FOLDER = 'win_snap'
+WINDOWS_NIGHTLY_FOLDER = 'downloads/snap/win'
+LINUX_NIGHTLY_FOLDER = 'downloads/snap'
+
+RELEASE_FOLDER_BASE = 'downloads'
console = Console()
@@ -37,24 +44,44 @@ def get_gajim_tag() -> str:
tag = os.environ.get('CI_COMMIT_TAG')
if tag is None:
exit('No tag found')
- return tag.removesuffix('gajim-')
+ return tag.removeprefix('gajim-')
+
+
+def find_linux_tarball(filedir: Path) -> Path:
+ files = list(filedir.glob('gajim-*.tar.gz'))
+ if len(files) != 1:
+ exit('Unknown files found')
+ return files[0]
def get_dir_list(ftp: FTP_TLS) -> list[str]:
return [x[0] for x in ftp.mlsd()]
-def ensure_folder_exists(ftp: FTP_TLS, dirname: str) -> None:
+def create_release_folder(ftp: FTP_TLS, tag: str) -> None:
+ ftp.cwd(RELEASE_FOLDER_BASE)
+ folder = get_release_folder_from_tag(tag)
dir_list = get_dir_list(ftp)
- if dirname not in dir_list:
- ftp.mkd(dirname)
+ if folder not in dir_list:
+ ftp.mkd(folder)
+ ftp.cwd(folder)
+
+
+def upload_all_from_dir(ftp: FTP_TLS, filedir: Path) -> None:
+ for filepath in filedir.iterdir():
+ upload_file(ftp, filepath)
+
+def upload_file(ftp: FTP_TLS,
+ filepath: Path,
+ name: Optional[str] = None) -> None:
-def upload_all_from_dir(ftp: FTP_TLS, dir: Path) -> None:
- for file_path in dir.iterdir():
- console.print('Upload file', file_path.name)
- with open(file_path, 'rb') as f:
- ftp.storbinary('STOR ' + file_path.name, f)
+ if name is None:
+ name = filepath.name
+
+ console.print('Upload file', filepath.name, 'as', name)
+ with open(filepath, 'rb') as f:
+ ftp.storbinary('STOR ' + name, f)
def get_deploy_method() -> str:
@@ -74,20 +101,25 @@ def deploy_windows_nightly(ftp: FTP_TLS, filedir: Path) -> None:
@ftp_connection
def deploy_windows_release(ftp: FTP_TLS, filedir: Path) -> None:
tag = get_gajim_tag()
- folder = get_release_folder_from_tag(tag)
- ensure_folder_exists(ftp, folder)
- ftp.cwd(folder)
+ create_release_folder(ftp, tag)
upload_all_from_dir(ftp, filedir)
@ftp_connection
-def deploy_linux_nightly():
- raise NotImplementedError
+def deploy_linux_nightly(ftp: FTP_TLS, filedir: Path) -> None:
+ ftp.cwd(LINUX_NIGHTLY_FOLDER)
+ filepath = find_linux_tarball(filedir)
+ filename = f'gajim-{date.today().isoformat()}.tar.gz'
+ upload_file(ftp, filepath, name=filename)
@ftp_connection
-def deploy_linux_release():
- raise NotImplementedError
+def deploy_linux_release(ftp: FTP_TLS, file: Path) -> None:
+ tag = get_gajim_tag()
+ create_release_folder(ftp, tag)
+ filepath = find_linux_tarball(filedir)
+ filename = f'gajim-{tag}.tar.gz'
+ upload_file(ftp, filepath, name=filename)
if __name__ == '__main__':
diff --git a/.ci/sdist.py b/.ci/sdist.py
index 8aeda48b8..513338c91 100755
--- a/.ci/sdist.py
+++ b/.ci/sdist.py
@@ -1,11 +1,16 @@
#!/usr/bin/env python3
import io
-import zipfile
-import subprocess
+import requests
import shutil
+import subprocess
+import zipfile
from pathlib import Path
-import requests
+
+from rich.console import Console
+
+console = Console()
+
PLUGINS = [
'plugin_installer',
@@ -15,36 +20,37 @@ PLUGINS_BASE_URL = 'https://ftp.gajim.org'
PLUGINS_FOLDER = Path('./gajim/data/plugins')
-def get_plugins_url(plugin):
+def get_plugins_url(plugin: str) -> str:
return f'{PLUGINS_BASE_URL}/plugins_master_zip/{plugin}.zip'
-def extraxt_zip(zip_bytes, path):
- print('Extract to', path)
+def extraxt_zip(zip_bytes: bytes, path: Path) -> None:
+ console.print('Extract to', path)
with zipfile.ZipFile(io.BytesIO(zip_bytes)) as zip_file:
zip_file.extractall(path)
-def download_plugins():
+def download_plugins() -> None:
PLUGINS_FOLDER.mkdir(parents=True)
for plugin in PLUGINS:
url = get_plugins_url(plugin)
- print('Download', url)
+ console.print('Download', url)
req = requests.get(url)
req.raise_for_status()
extraxt_zip(req.content, PLUGINS_FOLDER)
-def setup():
- print('Setup')
+def setup() -> None:
+ console.print('Setup')
subprocess.call(['python3', 'setup.py', 'sdist'])
-def cleanup():
- print('Cleanup')
+def cleanup() -> None:
+ console.print('Cleanup')
shutil.rmtree(PLUGINS_FOLDER)
-download_plugins()
-setup()
-cleanup()
+if __name__ == '__main__':
+ download_plugins()
+ setup()
+ cleanup()
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c6e8ceb9c..9a92f4d72 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -45,7 +45,6 @@ build-linux:
rules:
- if: '$GAJIM_NIGHTLY_BUILD'
- if: '$CI_COMMIT_TAG'
- when: manual
script:
- python3 .ci/sdist.py
@@ -68,6 +67,18 @@ build-windows:
paths:
- build/Gajim-*.exe
+deploy-linux:
+ stage: deploy
+ needs: ['build-linux']
+ rules:
+ - if: '$GAJIM_NIGHTLY_BUILD'
+ - if: '$CI_COMMIT_TAG'
+ when: manual
+ variables:
+ DEPLOY_TYPE: "linux"
+ script:
+ - python3 .ci/deploy.py sdist
+
deploy-windows:
stage: deploy
needs: ['build-windows']
diff --git a/pyrightconfig.json b/pyrightconfig.json
index 4e590c9b7..5145a6c97 100644
--- a/pyrightconfig.json
+++ b/pyrightconfig.json
@@ -4,7 +4,12 @@
"typeCheckingMode": "strict",
"reportImportCycles": "none",
"reportImplicitStringConcatenation": "none",
+ "exclude": [
+ "**/__pycache__",
+ ".git"
+ ],
"include": [
+ ".ci/*",
"gajim/gajim.py",
"gajim/common/application.py",
"gajim/common/cert_store.py",