Skip to content

Commit

Permalink
feat(ci): run app tests for multiple devices
Browse files Browse the repository at this point in the history
  • Loading branch information
krystxf committed May 17, 2024
1 parent b475504 commit a394f88
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 41 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/app-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
5 changes: 2 additions & 3 deletions app/metro-now/metro-now-tests/jsonUtilsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
8 changes: 5 additions & 3 deletions app/metro-now/metro-now-types/metroStationsTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
}
4 changes: 0 additions & 4 deletions app/metro-now/metro-now-utils/metroUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 23 additions & 24 deletions app/metro-now/metro-now/Core/Map/MapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
)
}
}
}
}
}
}

Expand Down

0 comments on commit a394f88

Please sign in to comment.