From a394f88fadfd40c7d871184dc19b4397e03e8b22 Mon Sep 17 00:00:00 2001 From: Krystof Date: Thu, 16 May 2024 22:54:44 +0200 Subject: [PATCH] feat(ci): run app tests for multiple devices --- .github/workflows/app-ci.yaml | 15 +++--- .../metro-now-tests/jsonUtilsTests.swift | 5 +- .../metro-now-types/metroStationsTypes.swift | 8 ++-- .../metro-now-utils/metroUtils.swift | 4 -- .../metro-now/Core/Map/MapView.swift | 47 +++++++++---------- 5 files changed, 38 insertions(+), 41 deletions(-) diff --git a/.github/workflows/app-ci.yaml b/.github/workflows/app-ci.yaml index 4ebb149d..499d0e39 100644 --- a/.github/workflows/app-ci.yaml +++ b/.github/workflows/app-ci.yaml @@ -4,20 +4,21 @@ on: push jobs: ci: - name: App CI 🚀 runs-on: macos-latest + strategy: + fail-fast: false + matrix: + device: [14, 15] + iOS: [17.5] + name: App CI 🚀 (iPhone ${{ matrix.device }}, iOS ${{ matrix.iOS }} ) + steps: - uses: swift-actions/setup-swift@65540b95f51493d65f5e59e97dcef9629ddf11bf with: swift-version: 5.10 - uses: actions/checkout@v4 - - name: Unit tests - run: | - cd ./app/metro-now - xcodebuild test -scheme metro-now -project metro-now.xcodeproj -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.5' | xcpretty && exit ${PIPESTATUS[0]} - - name: Build and test run: | cd ./app/metro-now - xcodebuild test -scheme metro-now -project metro-now.xcodeproj -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.5' | xcpretty && exit ${PIPESTATUS[0]} + xcodebuild test -scheme metro-now -project metro-now.xcodeproj -destination 'platform=iOS Simulator,name=iPhone ${{ matrix.device }},OS=${{ matrix.iOS }}' | xcpretty && exit ${PIPESTATUS[0]} diff --git a/app/metro-now/metro-now-tests/jsonUtilsTests.swift b/app/metro-now/metro-now-tests/jsonUtilsTests.swift index 78abf7b2..9836023d 100644 --- a/app/metro-now/metro-now-tests/jsonUtilsTests.swift +++ b/app/metro-now/metro-now-tests/jsonUtilsTests.swift @@ -12,14 +12,13 @@ final class jsonUtilsTests: XCTestCase { // MARK: - check if JSON data loads successfully func testMetroRoutesGeoJSON() { - let result: MetroRoutesGeoJSON! = getParsedJSONFile(.METRO_ROUTES_FILE) + let result: MetroRoutesGeoJSON? = getParsedJSONFile(.METRO_ROUTES_FILE) XCTAssertNotNil(result) } func testMetroStationsGeoJSON() { - let result: MetroStationsGeoJSON! = getParsedJSONFile(.METRO_STATIONS_FILE) - + let result: MetroStationsGeoJSON? = getParsedJSONFile(.METRO_STATIONS_FILE) XCTAssertNotNil(result) } } diff --git a/app/metro-now/metro-now-types/metroStationsTypes.swift b/app/metro-now/metro-now-types/metroStationsTypes.swift index 04f96961..87eb0d91 100644 --- a/app/metro-now/metro-now-types/metroStationsTypes.swift +++ b/app/metro-now/metro-now-types/metroStationsTypes.swift @@ -21,10 +21,12 @@ struct MetroStationsGeoJSONFeatureGeometry: Codable { } struct MetroStationsGeoJSONFeatureGeometryProperties: Codable { - let name: String? - let platforms: [MetroStationsGeoJSONFeatureGeometryPropertiesPlatform?]? + let name: String + let platforms: [MetroStationsGeoJSONFeatureGeometryPropertiesPlatform] } struct MetroStationsGeoJSONFeatureGeometryPropertiesPlatform: Codable { - let gtfsID, name, direction: String? + let gtfsID: String? + let name: String? + let direction: String? } diff --git a/app/metro-now/metro-now-utils/metroUtils.swift b/app/metro-now/metro-now-utils/metroUtils.swift index c0710271..c0f38bf0 100644 --- a/app/metro-now/metro-now-utils/metroUtils.swift +++ b/app/metro-now/metro-now-utils/metroUtils.swift @@ -8,10 +8,6 @@ import Foundation import SwiftUI -let metroRoutesGeoJSON: MetroRoutesGeoJSON! = getParsedJSONFile(.METRO_STATIONS_FILE) - -let metroStationsGeoJSON: MetroStationsGeoJSON! = getParsedJSONFile(.METRO_STATIONS_FILE) - enum MetroLine: String { case A case B diff --git a/app/metro-now/metro-now/Core/Map/MapView.swift b/app/metro-now/metro-now/Core/Map/MapView.swift index 32dde9a5..209feb80 100644 --- a/app/metro-now/metro-now/Core/Map/MapView.swift +++ b/app/metro-now/metro-now/Core/Map/MapView.swift @@ -9,32 +9,31 @@ import MapKit import SwiftUI struct MapView: View { - let stations: MetroRoutesGeoJSON! = getParsedJSONFile(.METRO_STATIONS_FILE) + let metroStationsGeoJSON: MetroStationsGeoJSON! = getParsedJSONFile(.METRO_STATIONS_FILE) var body: some View { - Map() - // Map { -// ForEach(stations.features, id: \.properties.na) { station in -// Annotation( -// station.name, -// coordinate: CLLocationCoordinate2D( -// latitude: station.avgLat, -// longitude: station.avgLon -// ) -// ) { -// ZStack { -// RoundedRectangle(cornerRadius: .infinity) -// .foregroundColor( -// .white -// ) -// Image(systemName: "\(station.platforms[0].name!.lowercased()).circle.fill") -// .foregroundColor( -// getMetroLineColor(station.platforms[0].name!) -// ) -// } -// } -// } -// } + Map { + ForEach(metroStationsGeoJSON!.features, id: \.properties.name) { feature in + Annotation( + feature.properties.name, + coordinate: CLLocationCoordinate2D( + latitude: feature.geometry.coordinates[1], + longitude: feature.geometry.coordinates[0] + ) + ) { + ZStack { + RoundedRectangle(cornerRadius: .infinity) + .foregroundColor( + .white + ) + Image(systemName: "\(feature.properties.platforms[0].name!.lowercased()).circle.fill") + .foregroundColor( + getMetroLineColor(feature.properties.platforms[0].name!) + ) + } + } + } + } } }