From 17189bf968f4da735d43394adf3a24f500310aa2 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Fri, 27 Feb 2026 10:02:58 +0200 Subject: [PATCH] Add swift command for running accessibility tests --- .github/workflows/accessibility_tests.yml | 16 +------- .../Commands/CI/AccessibilityTests.swift | 40 +++++++++++++++++++ Tools/Sources/Commands/CI/CI.swift | 1 + Tools/Sources/Commands/CI/UnitTests.swift | 2 +- fastlane/Fastfile | 16 -------- 5 files changed, 44 insertions(+), 31 deletions(-) create mode 100644 Tools/Sources/Commands/CI/AccessibilityTests.swift diff --git a/.github/workflows/accessibility_tests.yml b/.github/workflows/accessibility_tests.yml index 1926e4a99..cfbe22155 100644 --- a/.github/workflows/accessibility_tests.yml +++ b/.github/workflows/accessibility_tests.yml @@ -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 diff --git a/Tools/Sources/Commands/CI/AccessibilityTests.swift b/Tools/Sources/Commands/CI/AccessibilityTests.swift new file mode 100644 index 000000000..54c2dc62e --- /dev/null +++ b/Tools/Sources/Commands/CI/AccessibilityTests.swift @@ -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") + } +} diff --git a/Tools/Sources/Commands/CI/CI.swift b/Tools/Sources/Commands/CI/CI.swift index ca6165aed..b96102a9e 100644 --- a/Tools/Sources/Commands/CI/CI.swift +++ b/Tools/Sources/Commands/CI/CI.swift @@ -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 diff --git a/Tools/Sources/Commands/CI/UnitTests.swift b/Tools/Sources/Commands/CI/UnitTests.swift index a9e69f78d..122999469 100644 --- a/Tools/Sources/Commands/CI/UnitTests.swift +++ b/Tools/Sources/Commands/CI/UnitTests.swift @@ -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)", diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 0ac690f1f..07a29bec6 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -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()