ci: fix python heredoc indentation
This commit is contained in:
98
.github/workflows/ci.yml
vendored
98
.github/workflows/ci.yml
vendored
@@ -138,36 +138,36 @@ jobs:
|
|||||||
RESULT_BUNDLE_PATH="$RUNNER_TEMP/Clawdis-iOS.xcresult"
|
RESULT_BUNDLE_PATH="$RUNNER_TEMP/Clawdis-iOS.xcresult"
|
||||||
DEST_ID="$(
|
DEST_ID="$(
|
||||||
python3 - <<'PY'
|
python3 - <<'PY'
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
data = json.loads(subprocess.check_output(["xcrun", "simctl", "list", "devices", "available", "-j"], text=True))
|
data = json.loads(subprocess.check_output(["xcrun", "simctl", "list", "devices", "available", "-j"], text=True))
|
||||||
runtimes = []
|
runtimes = []
|
||||||
for runtime in data.get("devices", {}).keys():
|
for runtime in data.get("devices", {}).keys():
|
||||||
m = re.search(r"\\.iOS-(\\d+)-(\\d+)$", runtime)
|
m = re.search(r"\\.iOS-(\\d+)-(\\d+)$", runtime)
|
||||||
if m:
|
if m:
|
||||||
runtimes.append((int(m.group(1)), int(m.group(2)), runtime))
|
runtimes.append((int(m.group(1)), int(m.group(2)), runtime))
|
||||||
|
|
||||||
runtimes.sort(reverse=True)
|
runtimes.sort(reverse=True)
|
||||||
|
|
||||||
def pick_device(devices):
|
def pick_device(devices):
|
||||||
iphones = [d for d in devices if d.get("isAvailable") and d.get("name", "").startswith("iPhone")]
|
iphones = [d for d in devices if d.get("isAvailable") and d.get("name", "").startswith("iPhone")]
|
||||||
if not iphones:
|
if not iphones:
|
||||||
return None
|
return None
|
||||||
prefer = [d for d in iphones if "iPhone 16" in d.get("name", "")]
|
prefer = [d for d in iphones if "iPhone 16" in d.get("name", "")]
|
||||||
return (prefer[0] if prefer else iphones[0]).get("udid")
|
return (prefer[0] if prefer else iphones[0]).get("udid")
|
||||||
|
|
||||||
for _, __, runtime in runtimes:
|
for _, __, runtime in runtimes:
|
||||||
udid = pick_device(data["devices"].get(runtime, []))
|
udid = pick_device(data["devices"].get(runtime, []))
|
||||||
if udid:
|
if udid:
|
||||||
print(udid)
|
print(udid)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
print("No available iPhone simulators found.", file=sys.stderr)
|
print("No available iPhone simulators found.", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
PY
|
PY
|
||||||
)"
|
)"
|
||||||
echo "Using iOS Simulator id: $DEST_ID"
|
echo "Using iOS Simulator id: $DEST_ID"
|
||||||
xcodebuild test \
|
xcodebuild test \
|
||||||
@@ -188,35 +188,35 @@ jobs:
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
RESULT_BUNDLE_PATH="$RUNNER_TEMP/Clawdis-iOS.xcresult"
|
RESULT_BUNDLE_PATH="$RUNNER_TEMP/Clawdis-iOS.xcresult"
|
||||||
RESULT_BUNDLE_PATH="$RESULT_BUNDLE_PATH" python3 - <<'PY'
|
RESULT_BUNDLE_PATH="$RESULT_BUNDLE_PATH" python3 - <<'PY'
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
target_name = "Clawdis.app"
|
target_name = "Clawdis.app"
|
||||||
minimum = 0.50
|
minimum = 0.50
|
||||||
|
|
||||||
report = json.loads(
|
report = json.loads(
|
||||||
subprocess.check_output(
|
subprocess.check_output(
|
||||||
["xcrun", "xccov", "view", "--report", "--json", os.environ["RESULT_BUNDLE_PATH"]],
|
["xcrun", "xccov", "view", "--report", "--json", os.environ["RESULT_BUNDLE_PATH"]],
|
||||||
text=True,
|
text=True,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
target_coverage = None
|
target_coverage = None
|
||||||
for target in report.get("targets", []):
|
for target in report.get("targets", []):
|
||||||
if target.get("name") == target_name:
|
if target.get("name") == target_name:
|
||||||
target_coverage = float(target["lineCoverage"])
|
target_coverage = float(target["lineCoverage"])
|
||||||
break
|
break
|
||||||
|
|
||||||
if target_coverage is None:
|
if target_coverage is None:
|
||||||
print(f"Could not find coverage for target: {target_name}")
|
print(f"Could not find coverage for target: {target_name}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print(f"{target_name} line coverage: {target_coverage * 100:.2f}% (min {minimum * 100:.2f}%)")
|
print(f"{target_name} line coverage: {target_coverage * 100:.2f}% (min {minimum * 100:.2f}%)")
|
||||||
if target_coverage + 1e-12 < minimum:
|
if target_coverage + 1e-12 < minimum:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
PY
|
PY
|
||||||
|
|
||||||
android:
|
android:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
Reference in New Issue
Block a user