diff --git a/tools/check_gamefixes.py b/.github/scripts/check_gamefixes.py similarity index 83% rename from tools/check_gamefixes.py rename to .github/scripts/check_gamefixes.py index 01e99314..e98229fc 100644 --- a/tools/check_gamefixes.py +++ b/.github/scripts/check_gamefixes.py @@ -163,10 +163,47 @@ def _batch_generator(gamefix: Path, size: int = 50) -> Generator[set[str], Any, yield appids +def check_links(root: Path) -> None: + """Check for broken symbolic links""" + gamefixes = [ + file + for file in root.glob('gamefixes-*/*.py') + if not file.name.startswith(('__init__.py', 'default.py', 'winetricks-gui.py')) + ] + + print('Checking for broken symbolic links...', file=sys.stderr) + for module in gamefixes: + print(f'{module.parent.name}/{module.name}', file=sys.stderr) + if module.is_symlink() and not module.exists(): + err = f'The following file is not a valid symbolic link: {module}' + raise FileNotFoundError(err) + + +def check_filenames(root: Path) -> None: + """Check for expected file names. + + All files in non-steam gamefixes are expected to start with 'umu-' + """ + gamefixes = [ + file + for file in root.glob('gamefixes-*/*.py') + if not file.name.startswith(('__init__.py', 'default.py', 'winetricks-gui.py')) + and not file.parent.name.startswith('gamefixes-steam') + ] + + print('Checking for expected file names...', file=sys.stderr) + for module in gamefixes: + print(f'{module.parent.name}/{module.name}', file=sys.stderr) + if module.exists() and not module.name.startswith('umu-'): + err = f'The following file does not start with "umu-": {module}' + raise FileNotFoundError(err) + + def main() -> None: """Validate gamefixes modules.""" # Top-level project directory that is expected to contain gamefix directories - project = Path(__file__).parent.parent + project = Path(__file__).parent.parent.parent + print(project) # Steam API to acquire a single id. Used as fallback in case some IDs could # not be validated. Unforutnately, this endpoint does not accept a comma @@ -192,6 +229,8 @@ def main() -> None: # See https://gogapidocs.readthedocs.io/en/latest/galaxy.html#get--products gogapi = 'https://api.gog.com/products?ids=' + check_links(project) + check_filenames(project) check_steamfixes(project, steampowered, steamapi) check_gogfixes(project, gogapi, umudb_gog) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..7c7fc95b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: make + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +permissions: + contents: read + +jobs: + container-test-job: + runs-on: ubuntu-latest + container: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:beta + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + - name: Build umu-protonfixes + run: | + make diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..963bbf98 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: ci + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + # The Steam Runtime platform (sniper) uses Python 3.9 + python-version: "3.9" + - name: Install dependencies + run: | + sudo apt-get install shellcheck + python3 -m pip install --upgrade pip + pip install ruff + pip install ijson + - name: Lint with Shellcheck + run: | + shellcheck winetricks + - name: Lint with Ruff + run: | + ruff check . + - name: Validate gamefix modules + run: | + python3 .github/scripts/check_gamefixes.py + - name: Test with unittest + run: | + python3 protonfixes_test.py diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml deleted file mode 100644 index c604ea4c..00000000 --- a/.github/workflows/make.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: make - -on: - push: - branches: ["master"] - pull_request: - branches: ["master"] - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - # The Steam Runtime platform (sniper) uses Python 3.9 - python-version: "3.9" - - name: Install dependencies - run: | - sudo apt-get install podman - - name: Initialize submodules - run: | - git submodule update --init --recursive - - name: Build protonfixes in Steam Runtime - run: | - podman run --rm -v $(pwd):/workspace -w /workspace registry.gitlab.steamos.cloud/steamrt/sniper/sdk /bin/sh -c "make install" diff --git a/.github/workflows/umu-protonfixes.yml b/.github/workflows/umu-protonfixes.yml deleted file mode 100644 index 16513064..00000000 --- a/.github/workflows/umu-protonfixes.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: umu-protonfixes - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - # The Steam Runtime platform (sniper) uses Python 3.9 - python-version: '3.9' - - name: Install dependencies - run: | - sudo apt-get install shellcheck - python3 -m pip install --upgrade pip - pip install ruff - pip install ijson - - name: Lint with Shellcheck - run: | - shellcheck tools/check-links.sh - shellcheck winetricks - - name: Check symbolic links - run: | - bash tools/check-links.sh - - name: Check gamefix module IDs - run: | - python tools/check_gamefixes.py - - name: Lint with Ruff - run: | - ruff check . - - name: Test with unittest - run: | - python protonfixes_test.py diff --git a/tools/check-links.sh b/tools/check-links.sh deleted file mode 100644 index 0595cb11..00000000 --- a/tools/check-links.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -# -# Check for valid symbolic links for non-Steam gamefixes -# - -# Lint the following gamefix dir: -# gog, amazon, egs, humble, itchio, ubisoft, umu, zoomplatform -for file in ./{gamefixes-amazon,gamefixes-gog,gamefixes-egs,gamefixes-humble,gamefixes-itchio,gamefixes-ubisoft,gamefixes-umu,gamefixes-zoomplatform}/*; do - if [[ -L "$file" && ! -e "$file" ]]; then - echo "The following file is not a valid link: ${file}" - exit 1 - fi -done diff --git a/tools/symlinkfix.sh b/tools/symlinkfix.sh deleted file mode 100755 index 3921f6f4..00000000 --- a/tools/symlinkfix.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -if [[ $(basename "$PWD") != "tools" ]]; then - echo "Not executing within subdirectory 'tools', exiting" - exit 1 -fi - -cd .. - -# change symlink targets to lower case if they aren't already -find . -type l | while read symlink; do - target=$(readlink "$symlink") - new_target=$(echo "$target" | tr '[:upper:]' '[:lower:]') - ln -sf "$new_target" "$symlink" -done - -# iterate through game folders, check if symlinks are valid, if they are not, remove them - -for gamefixes in $(ls | grep gamefixes); do - cd $gamefixes - find . -type l | while read symlink; do - target=$(readlink "$symlink") - if [[ ! -e "$target" ]]; then - echo "Broken symlink detected, removing: $gamefixes/$(echo "$symlink" | sed 's/^..//')" - rm "$symlink" - fi - done - cd .. -done diff --git a/tools/vcrunfix b/tools/vcrunfix deleted file mode 100755 index e92bee3f..00000000 --- a/tools/vcrunfix +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -if [[ $(basename "$PWD") != "tools" ]]; then - echo "Not executing within subdirectory 'tools', exiting" - exit 1 -fi - -cd .. - -find ./ \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i 's/vcrun2019/vcrun2019/g'