Add swift command for running accessibility tests

This commit is contained in:
Stefan Ceriu
2026-02-27 10:02:58 +02:00
committed by Stefan Ceriu
parent 2d60a2b755
commit 17189bf968
5 changed files with 44 additions and 31 deletions

View File

@@ -20,29 +20,17 @@ jobs:
steps:
- uses: nschloe/action-cached-lfs-checkout@f46300cd8952454b9f0a21a3d133d4bd5684cfc2 #v1.2.3
- uses: actions/cache@v5
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Setup environment
run: source ci_scripts/ci_common.sh && setup_github_actions_environment
- name: Run tests
run: bundle exec fastlane accessibility_tests
- name: Zip results # for faster upload
if: failure()
working-directory: fastlane/test_output
run: zip -r AccessibilityTests.xcresult.zip AccessibilityTests.xcresult
run: swift run tools ci accessibility-tests
- name: Archive artifacts
uses: actions/upload-artifact@v7
if: failure()
with:
name: Results
path: fastlane/test_output/AccessibilityTests.xcresult.zip
path: test_output/AccessibilityTests.xcresult.zip
retention-days: 7
if-no-files-found: ignore

View File

@@ -0,0 +1,40 @@
import ArgumentParser
import CommandLineTools
import Foundation
struct AccessibilityTests: AsyncParsableCommand {
static let configuration = CommandConfiguration(commandName: "accessibility-tests",
abstract: "Runs the accessibility test CI workflow.")
@Option(help: "Device name for tests.")
var device = "iPhone 17"
@Option(help: "iOS version for the simulator.")
var osVersion = "26.1"
func run() async throws {
var testsFailed = false
do {
logger.info("\n🧪 Running accessibility tests…\n")
try await RunTests.parse([
"--scheme", "AccessibilityTests",
"--device", device,
"--os-version", osVersion,
"--retries", "0"
]).run()
} catch {
testsFailed = true
logger.error("\n❌ Accessibility tests failed.\n")
}
// Zip results (best-effort, useful for CI artifact uploads)
await CI.zipResults(bundles: ["AccessibilityTests.xcresult"],
outputName: "AccessibilityTests.xcresult.zip")
if testsFailed {
throw ExitCode.failure
}
logger.info("\n✅ Accessibility tests passed.\n")
}
}

View File

@@ -5,6 +5,7 @@ import Subprocess
struct CI: ParsableCommand {
static let configuration = CommandConfiguration(abstract: "CI workflow commands that can be run both locally and in CI environments.",
subcommands: [
AccessibilityTests.self,
UnitTests.self,
RunTests.self,
ConfigureNightly.self

View File

@@ -33,7 +33,7 @@ struct UnitTests: AsyncParsableCommand {
// Run preview tests on a smaller device
do {
logger.info("\n🧪 Running preview tests…")
logger.info("\n🧪 Running preview tests…\n")
try await RunTests.parse([
"--scheme", "PreviewTests",
"--device", "iPhone SE (3rd generation)",

View File

@@ -88,22 +88,6 @@ lane :ui_tests do |options|
)
end
lane :accessibility_tests do |options|
reset_simulator = ENV.key?('CI')
run_tests(
scheme: "AccessibilityTests",
device: "iPhone 17 (#{simulator_version})",
ensure_devices_found: true,
prelaunch_simulator: false,
result_bundle: true,
number_of_retries: 0,
reset_simulator: reset_simulator,
xcodebuild_formatter: "xcbeautify --quiet --is-ci --renderer github-actions"
)
end
lane :integration_tests do
clear_derived_data()