Add swift command for running accessibility tests
This commit is contained in:
committed by
Stefan Ceriu
parent
2d60a2b755
commit
17189bf968
16
.github/workflows/accessibility_tests.yml
vendored
16
.github/workflows/accessibility_tests.yml
vendored
@@ -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
|
||||
|
||||
40
Tools/Sources/Commands/CI/AccessibilityTests.swift
Normal file
40
Tools/Sources/Commands/CI/AccessibilityTests.swift
Normal 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")
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user