Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

ci(compat): refresh the ratings on main whatever the default branch is

Raystorms6de66ea7279f
diff --git a/.github/workflows/compat-reported.yml b/.github/workflows/compat-reported.yml
index 85a0c39..692dd86 100644
--- a/.github/workflows/compat-reported.yml
+++ b/.github/workflows/compat-reported.yml
@@ -13,30 +13,22 @@ permissions:
concurrency: compat-reported
+# The branch the site reads. A scheduled run starts on the default branch, which is not
+# always this one, so the job checks this branch out and pushes only to it.
+env:
+ TARGET_BRANCH: main
+
jobs:
refresh:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ with:
+ ref: ${{ env.TARGET_BRANCH }}
- name: Fetch AppleGamingWiki ratings
run: python3 scripts/compat-reported.py
- name: Commit if the game list changed
- run: |
- set -euo pipefail
- # "fetched" changes every run; only a different games list is worth a commit.
- if git show HEAD:compat/reported.json | python3 -c '
- import json, sys
- old = json.load(sys.stdin)["games"]
- new = json.load(open("compat/reported.json"))["games"]
- sys.exit(0 if old == new else 1)'; then
- echo "no change in the game list"
- exit 0
- fi
- git add compat/reported.json
- git -c user.name="github-actions[bot]" \
- -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
- commit -q -m "chore(compat): refresh AppleGamingWiki ratings"
- git push -q origin HEAD:main
+ run: bash scripts/compat-reported-commit.sh
diff --git a/AGENTS.md b/AGENTS.md
index a2f84b3..d1530b3 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -60,7 +60,8 @@ The checks the workflows run (`make -s <target>`):
- **C and shell suites:** `sigcheck`, `callscheck`, `webpatch-fixtures`, `peicon-fixtures`,
`panel-behavior`, `spawn-env`, `activatecheck`, `compatcheck`, `compatsvc-check`,
`shortcutcheck`, `launch-shell`, `envcheck`, `buildcheck`, `settingscheck`, `routecheck`,
- `bridgecheck`, `gamedrivecheck`, `launchercheck`, `seedcheck`, `gamefixescheck`
+ `bridgecheck`, `gamedrivecheck`, `launchercheck`, `seedcheck`, `gamefixescheck`,
+ `compat-reported-check`
- **Hardware-free device checks:** `game-host-check`, `dualsense-check`, `steam-rumble-check`
`make tests-list` prints the test paths. A check whose tool or input is missing prints
diff --git a/Makefile b/Makefile
index d3fb076..03d5011 100644
--- a/Makefile
+++ b/Makefile
@@ -74,7 +74,7 @@ DEPS := $(OBJS:.o=.d)
overlay-shim-bench iconmaker icon \
appinfo helpers-install ntdll-resolve bridge runcheck compatcheck \
compatsvc-check shortcutcheck scriptcheck envcheck buildcheck settingscheck routecheck bridgecheck gamedrivecheck \
- gamefixescheck launchercheck padcheck launch-shell activatecheck FORCE
+ gamefixescheck launchercheck padcheck launch-shell activatecheck compat-reported-check FORCE
APP_PAYLOAD := app/Sources/BridgeplayApp/Resources/payload
@@ -142,6 +142,11 @@ launchercheck:
@if [ ! -f dylib/tests/launchercheck.sh ]; then $(call SKIP,launchercheck,dylib/tests/launchercheck.sh); exit 0; fi; \
sh dylib/tests/launchercheck.sh dylib/feats/compat_run.sh
+# Runs the weekly compat refresh's commit step against local git repos
+compat-reported-check:
+ @if [ ! -f scripts/tests/compat-reported-commit.sh ]; then $(call SKIP,compat-reported-check,scripts/tests/compat-reported-commit.sh); exit 0; fi; \
+ sh scripts/tests/compat-reported-commit.sh
+
.PHONY: mincheck
mincheck:
@sh dylib/tests/mincheck.sh "$(APP_BUNDLE)" "$(MINCHECK_VER)" "$(GLASS_SDK)"
@@ -888,7 +893,7 @@ CI_CHECKS := mincheck l10ncheck \
sigcheck callscheck webpatch-fixtures peicon-fixtures panel-behavior spawn-env \
activatecheck compatcheck compatsvc-check shortcutcheck launch-shell envcheck \
buildcheck settingscheck routecheck bridgecheck gamedrivecheck launchercheck \
- seedcheck gamefixescheck padcheck np-native-tests native-shim-tests \
+ seedcheck gamefixescheck padcheck compat-reported-check np-native-tests native-shim-tests \
app-tests game-host-check dualsense-check steam-rumble-check
# app.yml runs the checks that need the built app in its build job and the rest in a
diff --git a/scripts/compat-reported-commit.sh b/scripts/compat-reported-commit.sh
new file mode 100755
index 0000000..af1f32e
--- /dev/null
+++ b/scripts/compat-reported-commit.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+# Commit compat/reported.json onto $TARGET_BRANCH when its games list changed, and push
+# it there. Run by .github/workflows/compat-reported.yml after scripts/compat-reported.py
+# has rewritten the file, from a checkout of $TARGET_BRANCH. It pushes that one branch and
+# never forces, so a rejected push (another push got in first) fails the run.
+set -euo pipefail
+
+branch="${TARGET_BRANCH:-main}"
+remote="${REMOTE:-origin}"
+file=compat/reported.json
+tip="refs/remotes/$remote/$branch"
+
+fail() {
+ echo "::error::compat-reported: $*" >&2
+ exit 1
+}
+
+# A checkout of the default branch would commit the file on top of unreleased code.
+[ "$(git symbolic-ref -q --short HEAD || true)" = "$branch" ] \
+ || fail "the checkout is not on $branch, refusing to commit"
+[ "$(git rev-parse HEAD)" = "$(git rev-parse --verify -q "$tip" || true)" ] \
+ || fail "HEAD is not the tip of $remote/$branch, refusing to commit"
+
+# "fetched" changes every run; only a different games list is worth a commit.
+old=$(git show "$tip:$file")
+rc=0
+printf '%s' "$old" | python3 -c '
+import json, sys
+old = json.load(sys.stdin)["games"]
+new = json.load(open(sys.argv[1]))["games"]
+sys.exit(0 if old == new else 10)' "$file" || rc=$?
+case "$rc" in
+ 0) echo "no change in the game list"; exit 0 ;;
+ 10) ;;
+ *) fail "could not compare the game lists (exit $rc)" ;;
+esac
+
+git add -- "$file"
+git -c user.name="github-actions[bot]" \
+ -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
+ commit -q -m "chore(compat): refresh AppleGamingWiki ratings" -- "$file"
+
+# One explicit refspec, no tags, no force.
+git -c push.followTags=false push -q "$remote" "HEAD:refs/heads/$branch" \
+ || fail "the push to $branch was rejected; another push probably landed first. Nothing else was pushed, run the workflow again"
diff --git a/scripts/tests/compat-reported-commit.sh b/scripts/tests/compat-reported-commit.sh
new file mode 100755
index 0000000..fc826e4
--- /dev/null
+++ b/scripts/tests/compat-reported-commit.sh
@@ -0,0 +1,161 @@
+#!/bin/sh
+# Runs scripts/compat-reported-commit.sh against local bare repos standing in for GitHub:
+# main plus a beta that is ahead of it and is the default branch.
+set -eu
+here=$(cd "$(dirname "$0")" && pwd)
+repo=$(cd "$here/../.." && pwd)
+script="$repo/scripts/compat-reported-commit.sh"
+workflow_src="$repo/.github/workflows/compat-reported.yml"
+[ -f "$script" ] || { echo "compat-reported-commit: $script not present, skipped"; exit 0; }
+
+work=$(mktemp -d)
+trap 'rm -rf "$work"' EXIT
+export GIT_AUTHOR_NAME=test [email protected]
+export GIT_COMMITTER_NAME=test [email protected]
+export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null
+
+fails=0
+ok() { echo "ok: $1"; }
+bad() { echo "FAIL: $1"; fails=$((fails + 1)); }
+check() { # check <description> <command...>
+ d=$1; shift
+ if "$@"; then ok "$d"; else bad "$d"; fi
+}
+refs() { git -C "$origin" for-each-ref --format='%(refname) %(objectname)'; }
+
+# $origin has main, beta (HEAD, two commits ahead of main) and a tag.
+mkorigin() {
+ origin="$work/origin.git"
+ rm -rf "$origin" "$work/seed"
+ git init -q --bare -b beta "$origin"
+ git init -q -b main "$work/seed"
+ (
+ cd "$work/seed"
+ mkdir compat
+ printf '{"fetched":"2026-01-01","games":[{"id":1}]}\n' > compat/reported.json
+ git add . && git commit -q -m "main: reported"
+ git tag v-main
+ git checkout -q -b beta
+ echo beta1 > beta.txt && git add beta.txt && git commit -q -m "beta 1"
+ echo beta2 >> beta.txt && git commit -q -am "beta 2"
+ git push -q "$origin" main beta v-main
+ )
+}
+
+# What actions/checkout does with `ref: main`; $1 is the ref to check out.
+clone() {
+ rm -rf "$work/ci"
+ git clone -q "$origin" "$work/ci"
+ git -C "$work/ci" fetch -q origin "$1"
+ git -C "$work/ci" checkout -q -B "$1" "refs/remotes/origin/$1"
+}
+
+# Stands in for compat-reported.py: new games list, new "fetched".
+refresh() {
+ printf '{"fetched":"2026-02-02","games":%s}\n' "$1" > "$work/ci/compat/reported.json"
+}
+
+run() { (cd "$work/ci" && bash "$script" 2>"$work/err" >"$work/out"); }
+
+echo "== changed list, default branch is beta"
+mkorigin
+before=$(refs)
+beta_tip=$(git -C "$origin" rev-parse beta)
+main_tip=$(git -C "$origin" rev-parse main)
+clone main
+refresh '[{"id":1},{"id":2}]'
+check "script succeeds" run
+check "main moved by exactly one commit" \
+ test "$(git -C "$origin" rev-list --count "$main_tip..main")" = 1
+check "the new commit's parent is main's old tip" \
+ test "$(git -C "$origin" rev-parse main^)" = "$main_tip"
+check "the commit touches only compat/reported.json" \
+ test "$(git -C "$origin" diff-tree --no-commit-id --name-only -r main)" = compat/reported.json
+check "the commit message is the refresh message" \
+ test "$(git -C "$origin" log -1 --format=%s main)" = "chore(compat): refresh AppleGamingWiki ratings"
+check "main does not contain beta" sh -c '! git -C "$1" merge-base --is-ancestor "$2" main' _ "$origin" "$beta_tip"
+check "beta is untouched" test "$(git -C "$origin" rev-parse beta)" = "$beta_tip"
+check "beta.txt is not on main" test -z "$(git -C "$origin" ls-tree --name-only main beta.txt)"
+check "the default branch is still beta" test "$(git -C "$origin" symbolic-ref HEAD)" = refs/heads/beta
+check "nothing but main changed on the remote" \
+ test "$(refs | grep -v '^refs/heads/main ')" = "$(echo "$before" | grep -v '^refs/heads/main ')"
+
+echo "== unchanged list"
+mkorigin
+before=$(refs)
+clone main
+printf '{"fetched":"2026-03-03","games":[{"id":1}]}\n' > "$work/ci/compat/reported.json"
+check "script succeeds" run
+check "it says there is no change" grep -q "no change in the game list" "$work/out"
+check "the remote is unchanged" test "$(refs)" = "$before"
+check "no local commit was made" test "$(git -C "$work/ci" rev-parse HEAD)" = "$(git -C "$origin" rev-parse main)"
+
+echo "== checkout is on the default branch (checkout ref missing)"
+mkorigin
+before=$(refs)
+clone beta
+refresh '[{"id":1},{"id":2}]'
+check "script fails" sh -c '! ( cd "$1" && bash "$2" ) >/dev/null 2>&1' _ "$work/ci" "$script"
+check "the remote is unchanged" test "$(refs)" = "$before"
+check "no commit was made" test "$(git -C "$work/ci" rev-parse HEAD)" = "$(git -C "$origin" rev-parse beta)"
+
+echo "== checkout is a detached HEAD at main's tip"
+mkorigin
+before=$(refs)
+clone main
+git -C "$work/ci" checkout -q --detach
+refresh '[{"id":1},{"id":2}]'
+check "script fails" sh -c '! ( cd "$1" && bash "$2" ) >/dev/null 2>&1' _ "$work/ci" "$script"
+check "the remote is unchanged" test "$(refs)" = "$before"
+
+echo "== main moved after the checkout (rejected push)"
+mkorigin
+clone main
+refresh '[{"id":1},{"id":2}]'
+(
+ cd "$work/seed"
+ git checkout -q main
+ echo race > race.txt && git add race.txt && git commit -q -m "race"
+ git push -q "$origin" main
+)
+before=$(refs)
+check "script fails" sh -c '! ( cd "$1" && bash "$2" ) >/dev/null 2>"$3"' _ "$work/ci" "$script" "$work/err"
+check "the error says the push was rejected" grep -q "push to main was rejected" "$work/err"
+check "the remote is unchanged" test "$(refs)" = "$before"
+
+echo "== a push the remote refuses"
+mkorigin
+clone main
+refresh '[{"id":1},{"id":2}]'
+printf '#!/bin/sh\necho no >&2\nexit 1\n' > "$origin/hooks/pre-receive"
+chmod +x "$origin/hooks/pre-receive"
+before=$(refs)
+check "script fails" sh -c '! ( cd "$1" && bash "$2" ) >/dev/null 2>"$3"' _ "$work/ci" "$script" "$work/err"
+check "the error says the push was rejected" grep -q "push to main was rejected" "$work/err"
+check "the remote is unchanged" test "$(refs)" = "$before"
+
+echo "== TARGET_BRANCH is honoured"
+mkorigin
+main_tip=$(git -C "$origin" rev-parse main)
+clone beta
+refresh '[{"id":1},{"id":2}]'
+check "script succeeds with TARGET_BRANCH=beta" sh -c 'cd "$1" && TARGET_BRANCH=beta bash "$2" >/dev/null 2>&1' _ "$work/ci" "$script"
+check "beta gained the commit" test "$(git -C "$origin" log -1 --format=%s beta)" = "chore(compat): refresh AppleGamingWiki ratings"
+check "main is untouched" test "$(git -C "$origin" rev-parse main)" = "$main_tip"
+
+echo "== the workflow"
+workflow="$work/workflow.yml"
+tr -d '\r' < "$workflow_src" > "$workflow"
+check "TARGET_BRANCH is main" grep -qx ' TARGET_BRANCH: main' "$workflow"
+check "the checkout step names the target branch" \
+ sh -c 'grep -A1 "uses: actions/checkout@" "$1" | grep -qx " with:" && grep -qx " ref: \${{ env.TARGET_BRANCH }}" "$1"' _ "$workflow"
+check "the commit step runs the script" grep -q 'run: bash scripts/compat-reported-commit.sh' "$workflow"
+check "the workflow pushes nothing itself" test -z "$(grep -n 'git push' "$workflow" || true)"
+check "the job has no ref other than the target branch" \
+ test "$(grep -c '^ *ref:' "$workflow")" = 1
+
+if [ "$fails" -ne 0 ]; then
+ echo "compat-reported-commit: $fails check(s) failed"
+ exit 1
+fi
+echo "==> compat-reported-commit: all checks passed"