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

CI: Annotations for shellcheck and ruff + enable pyright (without static type checking) #205

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
42 changes: 30 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,53 @@ jobs:
with:
submodules: recursive
fetch-depth: 0

- 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
cache: 'pip' # caching pip dependencies

- name: Install Python dependencies
run: |
sudo apt-get install shellcheck
python3 -m pip install --upgrade pip
pip install ruff
pip install ijson
pip install trio
pip install "git+https://github.com/njbooher/steam.git@wsproto#egg=steam[client]"
- name: Lint with Shellcheck
run: |
shellcheck winetricks

# PyRight, the unit tests, and other scripts import/resolve the "protonfixes" module
# We are using the path "umu-protonfixes", which isn't a valid module name and can't be used
# However: this simple, hacky symbolic link in the parent folder can fix this inconvenience
- name: Fix python module resolution
run: ln -rs . ../protonfixes

# FIXME: problem matcher is currently disabled upstream, using a fork for the moment
# https://github.com/ludeeus/action-shellcheck/pull/103
# FIXME: symlinks don't work upstream
# https://github.com/ludeeus/action-shellcheck/pull/104
- name: Run ShellCheck
uses: Root-Core/action-shellcheck@fork
with:
ignore_paths: subprojects # prevent ShellCheck from checking unrelated files
ignore_symlinks: false # winetricks is symlinked

# Ruff uses ruff.toml for it's configuration
- name: Lint with Ruff
run: |
ruff check .
uses: astral-sh/ruff-action@v1

# Pyright uses pyproject.toml for it's configuration
- name: Static type checking with Pyright
uses: jakebailey/pyright-action@v2

- name: Validate gamefix modules
run: |
python3 .github/scripts/check_gamefixes.py
python3 .github/scripts/check_verbs.py

- name: Validate gamefix imports
run: |
cd ..
ln -s umu-protonfixes protonfixes
cd protonfixes
python3 .github/scripts/check_imports.py

- name: Test with unittest
run: |
python3 protonfixes_test.py
3 changes: 2 additions & 1 deletion fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
try:
import __main__ as protonmain
except ImportError:
log.warn('Unable to hook into Proton main script environment')
log.crit('Unable to hook into Proton main script environment')
exit()


@lru_cache
Expand Down
2 changes: 0 additions & 2 deletions protonfixes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import tempfile
from pathlib import Path
from unittest.mock import patch, mock_open
import io
import urllib.request
import fix


Expand Down
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[project]
name = "umu-protonfixes"
description = "Stop gap solution to fix issues in games that run under Wine."
keywords = ["proton", "protontricks", "wine", "winetricks", "linux", "gaming"]
license = {file = "LICENSE"}
requires-python = "3.9"


[project.urls]
Repository = "https://github.com/Open-Wine-Components/umu-protonfixes.git"
Issues = "https://github.com/Open-Wine-Components/umu-protonfixes/issues"


[tool.pyright]
exclude = [
"**/__pycache__",
"subprojects",
"verbs"
]
extraPaths = [ ".." ] # Fix "protonfixes" module resolution
pythonVersion = "3.9"
pythonPlatform = "Linux"

typeCheckingMode = "off"
reportMissingImports = "error"
reportMissingModuleSource = "error"
reportUnusedImport = "error"
reportDuplicateImport = "error"
reportWildcardImportFromLibrary = "error"
reportPrivateImportUsage = "error"
reportShadowedImports = "error"
3 changes: 2 additions & 1 deletion util.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
try:
import __main__ as protonmain
except ImportError:
log.warn('Unable to hook into Proton main script environment')
log.crit('Unable to hook into Proton main script environment')
exit()


def which(appname: str) -> Union[str, None]:
Expand Down
Loading