Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update actions #493

Merged
merged 8 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"

- uses: conda-incubator/setup-miniconda@v2
if: runner.os == 'Windows'

- name: install Microsoft Visual C++ (Windows)
uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
Expand Down Expand Up @@ -58,7 +55,7 @@ jobs:
- name: install Qt and Qt Creator
shell: bash
run: |
pip install pyyaml requests py7zr
pip install pyyaml requests py7zr tqdm_loggable
python setup.py --export_variables
cat env >> $GITHUB_ENV

Expand Down Expand Up @@ -92,9 +89,9 @@ jobs:
file ./build/ROSProjectManager-*-*-*.zip

- name: upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: plugin_archive_artifact
name: plugin_archive_artifact_${{ matrix.config.name }}
if-no-files-found: error
path: |
./build/ROSProjectManager-*-*-*.zip
Expand All @@ -106,9 +103,10 @@ jobs:
needs: build
steps:
- name: download artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: plugin_archive_artifact
pattern: plugin_archive_artifact_*
merge-multiple: true
path: ./

- name: create release
Expand Down
36 changes: 28 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import py7zr
import requests
import yaml
from tqdm_loggable.auto import tqdm


url_repo_qtc_fmt = "https://download.qt.io/{release_type}_releases/qtcreator/{qtcv_maj}/{qtcv_full}/installer_source/{os}_{arch}/"

Expand All @@ -34,18 +36,40 @@
"x64": "64"}

def download_check_fail(url, expected_type):
response = requests.get(url, allow_redirects=True)
print("download URL:", url, flush=True)
response = requests.get(url, allow_redirects=True, timeout=1800)
if not response.ok:
raise RuntimeError("error retrieving "+response.url)
if response.headers.get('content-type') != expected_type:
print("Warning: invalid content type, expected '{}', got '{}'".format(
expected_type, response.headers.get('content-type')))
expected_type, response.headers.get('content-type')), flush=True)
return response

def read_downloadable_archives(package):
archive_names = io.StringIO(package.find("DownloadableArchives").text)
return list(csv.reader(archive_names, delimiter=',', skipinitialspace=True))[0]

def extract_progress(archive_bytes, archive_name, destination_path):
class ExtractProgressBar(py7zr.callbacks.ExtractCallback, tqdm):
def __init__(self, *args, total_bytes, **kwargs):
super().__init__(self, *args, total=total_bytes, **kwargs)
def report_start_preparation(self):
pass
def report_start(self, processing_file_path, processing_bytes):
pass
def report_end(self, processing_file_path, wrote_bytes):
self.update(int(wrote_bytes))
def report_postprocess(self):
self.update(int(self.total))
def report_warning(self, message):
pass

with py7zr.SevenZipFile(io.BytesIO(archive_bytes)) as zf:
with ExtractProgressBar(unit='B', unit_scale=True, miniters=1,
total_bytes=sum([f.uncompressed for f in zf.files]),
desc=archive_name) as cb_progress:
zf.extractall(path=destination_path, callback=cb_progress)

def qtc_download_check_extract(cfg, dir_install):
# if the Qt Creator version contains '-beta' or '-rc' we have to
# use the "development" repo, otherwise use the "official" repo
Expand Down Expand Up @@ -86,14 +110,12 @@ def qtc_download_check_extract(cfg, dir_install):
for archive_name in archive_names:
url_archive = base_url+"/"+archive_name

print("download", url_archive)

content = download_check_fail(url_archive, "application/x-7z-compressed").content

if md5sums[archive_name] != hashlib.md5(content).hexdigest():
raise RuntimeError(archive_name+" MD5 hash sum does not match")

py7zr.SevenZipFile(io.BytesIO(content)).extractall(dir_install_qt)
extract_progress(content, archive_name, dir_install_qt)

if cfg['os'] == "Darwin":
dir_install_qt = os.path.join(dir_install_qt, "Qt Creator.app", "Contents", "Resources")
Expand Down Expand Up @@ -162,16 +184,14 @@ def qt_download_check_extract(cfg, dir_install):
for package_name, package_version, archive_name in archives_match:
url_archive = base_url+'/'+package_name+'/'+package_version+archive_name

print("download", url_archive)

content = download_check_fail(url_archive, "application/x-7z-compressed").content

sha1sum = download_check_fail(url_archive+".sha1", "application/x-7z-compressed").text

if sha1sum != hashlib.sha1(content).hexdigest():
raise RuntimeError(archive_name+" SHA1 hash sum does not match")

py7zr.SevenZipFile(io.BytesIO(content)).extractall(dir_install)
extract_progress(content, archive_name, dir_install)

qt_path = os.path.join(dir_install, "{}.{}.0".format(ver_maj, ver_min))
qt_archs = os.listdir(qt_path)
Expand Down