|
| 1 | +name: iOS scratch (German noun capitals) |
| 2 | + |
| 3 | +# Scratch workflow for the German noun-capitalisation branch, based on the iOS |
| 4 | +# workflow in #1646. Builds the iOS targets on a simulator, runs the full |
| 5 | +# HEXMobileTests suite, and checks that the keyboard extension bundles |
| 6 | +# de.capitals. Temporary: delete it with its branch. |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: ["ios-ci-german-caps", "ios-ci-german-caps-base"] |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ios-scratch-${{ github.ref_name }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + test: |
| 20 | + name: Build and test |
| 21 | + runs-on: macos-26 |
| 22 | + timeout-minutes: 60 |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 |
| 25 | + with: |
| 26 | + persist-credentials: false |
| 27 | + |
| 28 | + - name: Install XcodeGen |
| 29 | + run: brew install xcodegen |
| 30 | + |
| 31 | + - name: Fetch the cleanup tagger model |
| 32 | + working-directory: ios |
| 33 | + run: scripts/fetch-cleanup-model.sh |
| 34 | + |
| 35 | + - name: Generate the Xcode project |
| 36 | + working-directory: ios |
| 37 | + run: xcodegen generate |
| 38 | + |
| 39 | + - name: List simulators |
| 40 | + run: | |
| 41 | + xcodebuild -version |
| 42 | + xcrun simctl list runtimes |
| 43 | + xcrun simctl list devices available |
| 44 | +
|
| 45 | + - name: Pick the newest iPhone simulator |
| 46 | + id: simulator |
| 47 | + run: | |
| 48 | + python3 - <<'PY' > "$GITHUB_OUTPUT" |
| 49 | + import json, subprocess |
| 50 | +
|
| 51 | + devices = json.loads(subprocess.check_output( |
| 52 | + ["xcrun", "simctl", "list", "devices", "available", "--json"] |
| 53 | + ))["devices"] |
| 54 | + runtimes = json.loads(subprocess.check_output( |
| 55 | + ["xcrun", "simctl", "list", "runtimes", "--json"] |
| 56 | + ))["runtimes"] |
| 57 | + version = { |
| 58 | + runtime["identifier"]: tuple(int(part) for part in runtime["version"].split(".") if part.isdigit()) |
| 59 | + for runtime in runtimes |
| 60 | + if runtime.get("isAvailable") |
| 61 | + } |
| 62 | + best = None |
| 63 | + for runtime_id, entries in devices.items(): |
| 64 | + if runtime_id not in version: |
| 65 | + continue |
| 66 | + for device in entries: |
| 67 | + if not device["name"].startswith("iPhone"): |
| 68 | + continue |
| 69 | + key = (version[runtime_id], device["name"]) |
| 70 | + if best is None or key > best[0]: |
| 71 | + best = (key, device["udid"], device["name"]) |
| 72 | + if best is None: |
| 73 | + raise SystemExit("no available iPhone simulator") |
| 74 | + print(f"udid={best[1]}") |
| 75 | + print(f"name={best[2]}") |
| 76 | + PY |
| 77 | +
|
| 78 | + - name: Build and test |
| 79 | + working-directory: ios |
| 80 | + run: | |
| 81 | + set -o pipefail |
| 82 | + xcodebuild test \\ |
| 83 | + -project HEXMobile.xcodeproj \\ |
| 84 | + -scheme HEXMobile \\ |
| 85 | + -destination "platform=iOS Simulator,id=${{ steps.simulator.outputs.udid }}" \\ |
| 86 | + -only-testing:HEXMobileTests \\ |
| 87 | + -resultBundlePath "$RUNNER_TEMP/HEXMobileTests.xcresult" \\ |
| 88 | + CODE_SIGNING_ALLOWED=NO \\ |
| 89 | + CODE_SIGNING_REQUIRED=NO \\ |
| 90 | + 2>&1 | tee "$RUNNER_TEMP/xcodebuild-test.log" |
| 91 | +
|
| 92 | + - name: Print failing tests and errors |
| 93 | + if: failure() |
| 94 | + run: | |
| 95 | + log="$RUNNER_TEMP/xcodebuild-test.log" |
| 96 | + echo "=== compile errors ===" |
| 97 | + grep -E "error: " "$log" | sort -u || true |
| 98 | + echo "=== xcodebuild summary ===" |
| 99 | + grep -E "^\\*\\* TEST|^Testing failed|^Test session results|Test Case '.*' failed" "$log" | sort -u || true |
| 100 | + echo "=== failing tests in the result bundle ===" |
| 101 | + python3 - <<'PY' |
| 102 | + import json, os, subprocess, sys |
| 103 | +
|
| 104 | + path = os.path.join(os.environ["RUNNER_TEMP"], "HEXMobileTests.xcresult") |
| 105 | + if not os.path.isdir(path): |
| 106 | + print("no result bundle at", path) |
| 107 | + sys.exit(0) |
| 108 | + run = subprocess.run( |
| 109 | + ["xcrun", "xcresulttool", "get", "test-results", "tests", "--path", path, "--format", "json"], |
| 110 | + capture_output=True, |
| 111 | + text=True, |
| 112 | + ) |
| 113 | + if run.returncode != 0: |
| 114 | + print("xcresulttool failed:", run.stderr.strip()) |
| 115 | + sys.exit(0) |
| 116 | + failing = [] |
| 117 | + passed = 0 |
| 118 | + skipped = 0 |
| 119 | + def walk(nodes): |
| 120 | + global passed, skipped |
| 121 | + for node in nodes: |
| 122 | + if node.get("nodeType") == "Test Case": |
| 123 | + result = node.get("result") |
| 124 | + if result == "Failed": |
| 125 | + failing.append(node.get("nodeIdentifier") or node.get("name")) |
| 126 | + elif result == "Skipped": |
| 127 | + skipped += 1 |
| 128 | + elif result == "Passed": |
| 129 | + passed += 1 |
| 130 | + walk(node.get("children") or []) |
| 131 | + walk(json.loads(run.stdout).get("testNodes") or []) |
| 132 | + print(f"test cases: {passed} passed, {len(failing)} failed, {skipped} skipped") |
| 133 | + for name in failing: |
| 134 | + print(f"::error::failing test: {name}") |
| 135 | + if not failing: |
| 136 | + print("no failed test cases in the result bundle") |
| 137 | + PY |
| 138 | +
|
| 139 | + - name: Verify de.capitals ships in HEXKeyboard.appex |
| 140 | + if: always() |
| 141 | + run: | |
| 142 | + set -euo pipefail |
| 143 | + appex=$(find ~/Library/Developer/Xcode/DerivedData -type d -name HEXKeyboard.appex | head -1) |
| 144 | + if [ -z "$appex" ]; then |
| 145 | + echo "::warning::HEXKeyboard.appex was not built" |
| 146 | + exit 0 |
| 147 | + fi |
| 148 | + echo "appex: $appex" |
| 149 | + find "$appex" -maxdepth 2 -type f -name "de.*" | sort |
| 150 | + capitals=$(find "$appex" -type f -name de.capitals | head -1) |
| 151 | + if [ -z "$capitals" ]; then |
| 152 | + echo "::error::de.capitals is not in $appex" |
| 153 | + exit 1 |
| 154 | + fi |
| 155 | + echo "de.capitals: $capitals" |
| 156 | + wc -l "$capitals" |
| 157 | + head -3 "$capitals" |
| 158 | +
|
| 159 | + - name: Upload build log and test results |
| 160 | + if: always() |
| 161 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 162 | + with: |
| 163 | + name: ios-scratch-results |
| 164 | + path: | |
| 165 | + ${{ runner.temp }}/HEXMobileTests.xcresult |
| 166 | + ${{ runner.temp }}/xcodebuild-test.log |
| 167 | + retention-days: 7 |
| 168 | + if-no-files-found: ignore |
0 commit comments