Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
ci(app): run the Swift tests in a job of their own
raymondchinsfe7a029677d2
diff --git a/.github/workflows/app.yml b/.github/workflows/app.ymlindex a5a0dad..96abfdb 100644--- a/.github/workflows/app.yml+++ b/.github/workflows/app.yml@@ -2,9 +2,9 @@ name: app# Starts on every PR and every push to main and beta, so the "app gate" job below always# reports: it is the check a branch rule can require. The scope job decides whether the-# change is docs-only (.github/docs-only-paths); if so the build and checks jobs are+# change is docs-only (.github/docs-only-paths); if so the build, checks and tests jobs are# skipped and the gate passes. scripts/build-local.sh reuses a run for a release only when-# those two jobs ran and succeeded (scripts/ci-run-passed.sh), so keep their names.+# those three jobs ran and succeeded (scripts/ci-run-passed.sh), so keep their names.on:push:branches: [main, beta]@@ -165,7 +165,7 @@ jobs:- name: Build the apprun: make app- # The checks job runs the rest of the one check list (make ci-checks).+ # The checks and tests jobs run the rest of the one check list (make ci-checks).- name: Run the checks that need the built apprun: make ci-checks-built@@ -200,12 +200,30 @@ jobs:- name: Run the checksrun: make ci-checks-source+ # The Swift tests build their own debug products, so they run beside the app build+ # instead of after it, and on a runner of their own: the timing-sensitive controller+ # checks in the checks job would share three cores with the Swift compiler otherwise.+ tests:+ name: swift tests+ needs: scope+ if: needs.scope.outputs.docs_only != 'true'+ runs-on: xcode-27+ timeout-minutes: 20+ steps:+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0++ - name: Select Xcode+ run: sudo xcode-select -s /Applications/Xcode_27.0.app++ - name: Run the Swift tests+ run: make ci-checks-tests+# The one check a branch rule requires. always(): a skipped required check counts as# passing, so a gate skipped because build or checks failed or were cancelled would let# the change in. scripts/ci-gate.sh says what is green.gate:name: app gate- needs: [scope, build, checks]+ needs: [scope, build, checks, tests]if: always()runs-on: ubuntu-latesttimeout-minutes: 5@@ -218,4 +236,5 @@ jobs:DOCS_ONLY: ${{ needs.scope.outputs.docs_only }}BUILD_RESULT: ${{ needs.build.result }}CHECKS_RESULT: ${{ needs.checks.result }}+ TESTS_RESULT: ${{ needs.tests.result }}run: sh scripts/ci-gate.shdiff --git a/Makefile b/Makefileindex f520110..26e5749 100644--- a/Makefile+++ b/Makefile@@ -948,14 +948,17 @@ CI_CHECKS := mincheck l10ncheck \seedcheck gamefixescheck versioncheck cicheck padcheck compat-reported-check np-native-tests native-shim-tests \app-tests native-installercheck 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-# parallel job; both lists together are CI_CHECKS.-CI_CHECKS_BUILT := mincheck l10ncheck app-tests-CI_CHECKS_SOURCE := $(filter-out $(CI_CHECKS_BUILT),$(CI_CHECKS))+# app.yml runs the checks that need the built app in its build job, the Swift tests in a+# job of their own and the rest in a third; the three lists together are CI_CHECKS.+CI_CHECKS_BUILT := mincheck l10ncheck+CI_CHECKS_TESTS := app-tests+CI_CHECKS_SOURCE := $(filter-out $(CI_CHECKS_BUILT) $(CI_CHECKS_TESTS),$(CI_CHECKS))-.PHONY: ci-checks ci-checks-built ci-checks-source+.PHONY: ci-checks ci-checks-built ci-checks-tests ci-checks-sourceci-checks-built:@$(MAKE) -s ci-checks CI_CHECKS="$(CI_CHECKS_BUILT)"+ci-checks-tests:+ @$(MAKE) -s ci-checks CI_CHECKS="$(CI_CHECKS_TESTS)"ci-checks-source:@$(MAKE) -s ci-checks CI_CHECKS="$(CI_CHECKS_SOURCE)"# The checks run side by side, CHECK_JOBS at a time (CHECK_JOBS=1 runs them one by one).diff --git a/scripts/build-local.sh b/scripts/build-local.shindex 34cdf3e..2c96ccf 100755--- a/scripts/build-local.sh+++ b/scripts/build-local.sh@@ -245,7 +245,7 @@ fi# whose sources (version.h and docs aside) match a commit that workflow passed skips them# too: push, let CI pass, bump, release. Needs gh; without it, or with no passing run, the# checks run here. A docs-only run is green with its build and checks skipped, so a run-# counts only when both jobs ran and succeeded (scripts/ci-run-passed.sh).+# counts only when its build, checks and tests jobs ran and succeeded (scripts/ci-run-passed.sh).ci_slug=${BRIDGEPLAY_CI_REPO:-raymondchins/Bridgeplay}ci_passed() {command -v gh >/dev/null 2>&1 || return 1diff --git a/scripts/ci-gate.sh b/scripts/ci-gate.shindex 875fcec..5544418 100755--- a/scripts/ci-gate.sh+++ b/scripts/ci-gate.sh@@ -1,12 +1,13 @@#!/bin/sh# The verdict of the app workflow's "app gate" job, the one check a branch rule requires.-# Green only when the heavy jobs both succeeded, or both were skipped because the change+# Green only when the heavy jobs all succeeded, or all were skipped because the change# is docs-only. Failed, cancelled and any other skip are red: a required check that is# skipped counts as passing, so a skipped build must never be read as one.# SCOPE_RESULT needs.scope.result# DOCS_ONLY needs.scope.outputs.docs_only# BUILD_RESULT needs.build.result# CHECKS_RESULT needs.checks.result+# TESTS_RESULT needs.tests.resultfail() {echo "app gate: $*" >&2exit 1@@ -20,9 +21,10 @@ false) want=success ;;esac[ "${BUILD_RESULT:-}" = "$want" ] || fail "full app build ended ${BUILD_RESULT:-with no result}, expected $want"[ "${CHECKS_RESULT:-}" = "$want" ] || fail "source checks ended ${CHECKS_RESULT:-with no result}, expected $want"+[ "${TESTS_RESULT:-}" = "$want" ] || fail "swift tests ended ${TESTS_RESULT:-with no result}, expected $want"if [ "$want" = skipped ]; then- echo "app gate: docs-only change, build and checks skipped"+ echo "app gate: docs-only change, build, checks and tests skipped"else- echo "app gate: full app build and source checks passed"+ echo "app gate: full app build, source checks and swift tests passed"fidiff --git a/scripts/ci-run-passed.sh b/scripts/ci-run-passed.shindex c962093..d2b214a 100755--- a/scripts/ci-run-passed.sh+++ b/scripts/ci-run-passed.sh@@ -1,20 +1,22 @@#!/bin/sh# ci-run-passed.sh <owner/repo> <sha>: exit 0 when the app workflow has a run on that commit-# whose build and check jobs both ran and succeeded. A docs-only run is green too, with+# whose build, checks and tests jobs all ran and succeeded. A docs-only run is green too, with# those jobs skipped, so the run's own conclusion proves nothing about the sources.# The job names are the `name:` of the jobs in .github/workflows/app.yml.[ $# -eq 2 ] || { echo "usage: ci-run-passed.sh <owner/repo> <sha>" >&2; exit 2; }build_job=${BRIDGEPLAY_CI_BUILD_JOB:-full app build}checks_job=${BRIDGEPLAY_CI_CHECKS_JOB:-source checks}+tests_job=${BRIDGEPLAY_CI_TESTS_JOB:-swift tests}command -v gh >/dev/null 2>&1 || exit 1ids=$(gh run list -R "$1" -w app --commit "$2" --status success --limit 20 \--json databaseId -q '.[].databaseId' 2>/dev/null) || exit 1for id in $ids; dogh run view "$id" -R "$1" --json jobs -q '.jobs[] | [.name, .conclusion] | @tsv' 2>/dev/null |- awk -F '\t' -v b="$build_job" -v c="$checks_job" '+ awk -F '\t' -v b="$build_job" -v c="$checks_job" -v t="$tests_job" '$1 == b && $2 == "success" { nb++ }$1 == c && $2 == "success" { nc++ }- END { exit !(nb == 1 && nc == 1) }' && exit 0+ $1 == t && $2 == "success" { nt++ }+ END { exit !(nb == 1 && nc == 1 && nt == 1) }' && exit 0doneexit 1diff --git a/scripts/tests/cicheck.sh b/scripts/tests/cicheck.shindex b3fa005..7e6c70c 100644--- a/scripts/tests/cicheck.sh+++ b/scripts/tests/cicheck.sh@@ -163,7 +163,8 @@ eq "pull request, HEAD is not a merge" "docs_only=false" "$(scope pull_request)"# --- ci-gate.sh ---------------------------------------------------------------------gate() { SCOPE_RESULT=$1 DOCS_ONLY=$2 BUILD_RESULT=$3 CHECKS_RESULT=$4 sh "$root/scripts/ci-gate.sh"; }+# The tests job ends like the checks job unless a fifth result is given.+gate() { SCOPE_RESULT=$1 DOCS_ONLY=$2 BUILD_RESULT=$3 CHECKS_RESULT=$4 TESTS_RESULT=${5:-$4} sh "$root/scripts/ci-gate.sh"; }yes "gate: docs-only, heavy jobs skipped" gate success true skipped skippedyes "gate: code, heavy jobs passed" gate success false success success@@ -172,8 +173,12 @@ no "gate: code, checks failed" gate success false success failureno "gate: code, build cancelled" gate success false cancelled successno "gate: code, checks cancelled" gate success false success cancelledno "gate: code, heavy jobs skipped" gate success false skipped skipped+no "gate: code, tests failed" gate success false success success failure+no "gate: code, tests cancelled" gate success false success success cancelled+no "gate: code, tests skipped" gate success false success success skipped+no "gate: docs-only, tests ran" gate success true skipped skipped successno "gate: scope failed" gate failure '' skipped skipped-no "gate: no results at all" env -u SCOPE_RESULT -u DOCS_ONLY -u BUILD_RESULT -u CHECKS_RESULT sh "$root/scripts/ci-gate.sh"+no "gate: no results at all" env -u SCOPE_RESULT -u DOCS_ONLY -u BUILD_RESULT -u CHECKS_RESULT -u TESTS_RESULT sh "$root/scripts/ci-gate.sh"# Every combination: green exactly for the two good ones.for s in success failure cancelled skipped; do@@ -218,9 +223,9 @@ chmod +x "$work/bin/gh"FAKE_DIR=$work/fakeexport FAKE_DIRtab=$(printf '\t')-jobs_file() { # jobs_file <id> <scope> <build> <checks> <gate>- printf 'change scope%s%s\nfull app build%s%s\nsource checks%s%s\napp gate%s%s\n' \- "$tab" "$2" "$tab" "$3" "$tab" "$4" "$tab" "$5" >"$FAKE_DIR/jobs.$1"+jobs_file() { # jobs_file <id> <scope> <build> <checks> <gate> [tests, default <checks>]+ printf 'change scope%s%s\nfull app build%s%s\nsource checks%s%s\nswift tests%s%s\napp gate%s%s\n' \+ "$tab" "$2" "$tab" "$3" "$tab" "$4" "$tab" "${6:-$4}" "$tab" "$5" >"$FAKE_DIR/jobs.$1"}reset_fake() { rm -f "$FAKE_DIR"/runs.* "$FAKE_DIR"/jobs.* "$FAKE_DIR/calls" "$FAKE_DIR/list-fails"; }passed_run() { PATH="$work/bin:$PATH" sh "$root/scripts/ci-run-passed.sh" owner/repo abc123; }@@ -244,6 +249,10 @@ reset_fakejobs_file 20 success success failure failureprintf '20\n' >"$FAKE_DIR/runs.abc123"no "run: checks failed" passed_run+jobs_file 20 success success success success failure+no "run: tests failed" passed_run+printf 'change scope\tsuccess\nfull app build\tsuccess\nsource checks\tsuccess\napp gate\tsuccess\n' >"$FAKE_DIR/jobs.20"+no "run: a run from before the tests job" passed_runjobs_file 20 success skipped success successno "run: build skipped" passed_runjobs_file 20 success cancelled success success@@ -346,24 +355,28 @@ yes "app.yml: other runs have a group of their own" grep -Fxq ' group: app-${{build=$(job build)checks=$(job checks)+tests=$(job tests)gate_job=$(job gate)scope_job=$(job scope)yes "build job name" has " name: full app build" "$build"yes "checks job name" has " name: source checks" "$checks"+yes "tests job name" has " name: swift tests" "$tests"yes "gate job name" has " name: app gate" "$gate_job"eq "ci-run-passed.sh knows the build job" "full app build" "$(sed -n 's/^build_job=\${BRIDGEPLAY_CI_BUILD_JOB:-\(.*\)}$/\1/p' "$root/scripts/ci-run-passed.sh")"eq "ci-run-passed.sh knows the checks job" "source checks" "$(sed -n 's/^checks_job=\${BRIDGEPLAY_CI_CHECKS_JOB:-\(.*\)}$/\1/p' "$root/scripts/ci-run-passed.sh")"-for j in build checks; do+eq "ci-run-passed.sh knows the tests job" "swift tests" "$(sed -n 's/^tests_job=\${BRIDGEPLAY_CI_TESTS_JOB:-\(.*\)}$/\1/p' "$root/scripts/ci-run-passed.sh")"+for j in build checks tests; dobody=$(job "$j")yes "$j: waits for scope" has " needs: scope" "$body"yes "$j: skipped for docs-only" has " if: needs.scope.outputs.docs_only != 'true'" "$body"done-yes "gate: waits for every job" has " needs: [scope, build, checks]" "$gate_job"+yes "gate: waits for every job" has " needs: [scope, build, checks, tests]" "$gate_job"yes "gate: runs whatever the others did" has " if: always()" "$gate_job"yes "gate: on a Linux runner" has " runs-on: ubuntu-latest" "$gate_job"yes "gate: runs the verdict script" has " run: sh scripts/ci-gate.sh" "$gate_job"for v in 'SCOPE_RESULT: ${{ needs.scope.result }}' 'DOCS_ONLY: ${{ needs.scope.outputs.docs_only }}' \- 'BUILD_RESULT: ${{ needs.build.result }}' 'CHECKS_RESULT: ${{ needs.checks.result }}'; do+ 'BUILD_RESULT: ${{ needs.build.result }}' 'CHECKS_RESULT: ${{ needs.checks.result }}' \+ 'TESTS_RESULT: ${{ needs.tests.result }}'; doyes "gate input $v" has " $v" "$gate_job"doneyes "scope: on a Linux runner" has " runs-on: ubuntu-latest" "$scope_job"