Skip to content

Commit

Permalink
tests: add delta update test (#354)
Browse files Browse the repository at this point in the history
* tests: add e2e test for delta update

* workflows: add delta update test
  • Loading branch information
R1kaB3rN authored Jan 25, 2025
1 parent dc3228d commit 2439791
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 2 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ permissions:

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
run: |
sudo apt-get install meson scdoc python3-hatchling python3-build python3-installer python3-filelock shellcheck bubblewrap cargo
sudo apt-get update
echo "deb http://archive.ubuntu.com/ubuntu/ noble noble-updates noble-backports main universe restricted multiverse" | sudo tee -a /etc/apt/sources.list
sudo apt-get install meson scdoc python3-hatchling python3-build python3-installer python3-filelock shellcheck bubblewrap cargo libzstd1 python3-xxhash python3-cbor2 apparmor apparmor-profiles apparmor-profiles-extra python3-xlib
sudo apparmor_parser /usr/share/apparmor/extra-profiles/bwrap-userns-restrict
python3 -m pip install --upgrade pip
pip install uv
- name: Initialize submodules
Expand All @@ -29,12 +32,20 @@ jobs:
run: |
./configure.sh --user-install
make install
- name: Make system install
run: |
./configure.sh --prefix=/usr
sudo make install
- name: Run shellcheck
run: |
shellcheck tests/*.sh
- name: Setup venv
run: |
uv venv --python 3.10
- name: Test delta update
run: |
python3 tests/test_delta.py
rm -rf "$HOME/.local/share/umu" "$HOME/Games/umu" "$HOME/.local/share/Steam/compatibilitytools.d" "$HOME/.cache/umu"
- name: Test steamrt install
run: |
source .venv/bin/activate
Expand Down
75 changes: 75 additions & 0 deletions tests/test_delta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env python3

import json
import shutil
import ssl
import subprocess
import sys
import tarfile
import tempfile
from pathlib import Path
from urllib.request import Request, urlopen

import cbor2


def main(): # noqa: D103
url = (
"https://api.github.com/repos/Open-Wine-Components/umu-mkpatch/releases/latest"
)
headers = {
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
"User-Agent": "",
}
codename = "UMU-Latest"

with urlopen( # noqa: S310
Request(url, headers=headers), # noqa: S310
context=ssl.create_default_context(),
) as resp:
releases = json.loads(resp.read())
for release in releases["assets"]:
if not release["name"].endswith("cbor"):
continue
if release["name"].startswith(codename):
durl = release["browser_download_url"]
break

with urlopen(durl) as resp: # noqa: S310
patch = cbor2.loads(resp.read())
version = patch.get("contents")[0].get("source")

url = f"https://github.com/Open-Wine-Components/umu-proton/releases/download/{version}/{version}.tar.gz"
with urlopen(url) as resp: # noqa: S310
buffer = bytearray(64 * 1024)
view = memoryview(buffer)
with tempfile.NamedTemporaryFile(mode="ab+", buffering=0) as file:
while size := resp.readinto(buffer):
file.write(view[:size])
cache = Path.home().joinpath(".cache", "umu")
cache.mkdir(parents=True, exist_ok=True)
file.seek(0)
cache.joinpath(f"{version}.tar.gz").write_bytes(file.read())

with tarfile.open(cache.joinpath(f"{version}.tar.gz")) as tar:
tar.extraction_filter = tarfile.tar_filter
tar.extractall(path=cache) # noqa: S202
compat = Path.home().joinpath(".local", "share", "umu", "compatibilitytools")
compat.mkdir(parents=True, exist_ok=True)
shutil.move(cache.joinpath(version), compat)
compat.joinpath(version).rename(compat.joinpath("UMU-Latest"))

exe = shutil.which("umu-run", path="/usr/local/bin")
if exe is None:
return 1

return subprocess.run(
(exe, "wineboot", "-u"),
env={"PROTONPATH": "UMU-Latest", "GAMEID": "umu-0", "UMU_LOG": "1"},
check=False,
).returncode


if __name__ == "__main__":
sys.exit(main())

0 comments on commit 2439791

Please sign in to comment.