Skip to content

Commit c4e0ed9

Browse files
authored
Build and test on both macos and ubuntu (#3)
1 parent efde4e2 commit c4e0ed9

File tree

5 files changed

+31
-16
lines changed

5 files changed

+31
-16
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
name: Build and test
1+
name: Build and test on macOS and Ubuntu
22

33
on:
44
pull_request:
55
branches: [ "main" ]
66

77
jobs:
8-
build:
8+
build-and-test-macos:
99
runs-on: macos-13
1010
steps:
11-
- uses: actions/checkout@v3
12-
- name: Build
13-
run: swift build
14-
15-
test:
16-
runs-on: macos-13
11+
- uses: actions/checkout@v3
12+
- name: Build on macOS
13+
run: swift build
14+
- name: Test on macOS
15+
run: swift test
16+
17+
build-and-test-ubuntu:
18+
runs-on: ubuntu-latest
1719
steps:
18-
- uses: actions/checkout@v3
19-
- name: Run tests
20-
run: swift test
20+
- uses: actions/checkout@v3
21+
- name: Set up Swift on Ubuntu
22+
uses: fwal/setup-swift@v1
23+
with:
24+
swift-version: '5.9'
25+
- name: Build on Ubuntu
26+
run: swift build
27+
- name: Test on Ubuntu
28+
run: swift test

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.7.1
1+
// swift-tools-version:5.9
22
import PackageDescription
33

44
let package = Package(

Sources/Grodt/BusinessLogic/PriceService.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class CachedPriceService: PriceService {
4949

5050
var quote = quotes.datedQuotes.first(where: { $0.date == date })
5151
var calendar = Calendar.current
52-
calendar.timeZone = TimeZone.gmt
52+
calendar.timeZone = TimeZone.universalGMT
5353
var dateToCheck = date
5454

5555
for _ in 0..<7 {
@@ -64,7 +64,7 @@ class CachedPriceService: PriceService {
6464

6565
private func liveHistoricalPrices(for ticker: String) async throws -> [DatedQuote] {
6666
let dateFormatter = DateFormatter()
67-
dateFormatter.timeZone = TimeZone.gmt
67+
dateFormatter.timeZone = TimeZone.universalGMT
6868
dateFormatter.dateFormat = "yyyy-MM-dd"
6969

7070
let result = await alphavantage.dailyAdjustedTimeSeries(for: ticker, outputSize: .full)

Sources/Grodt/Persistency/YearMonthDayDate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ struct YearMonthDayDate: Codable, Equatable, Hashable, Comparable {
55

66
init(_ date: Date) {
77
var calendar = Calendar.current
8-
calendar.timeZone = TimeZone.gmt
8+
calendar.timeZone = TimeZone.universalGMT
99
let components = calendar.dateComponents([.year, .month, .day], from: date)
1010
self.date = calendar.date(from: components)!
1111
}
1212

1313
static func == (lhs: YearMonthDayDate, rhs: YearMonthDayDate) -> Bool {
1414
var calendar = Calendar.current
15-
calendar.timeZone = TimeZone.gmt
15+
calendar.timeZone = TimeZone.universalGMT
1616
let lhsComponents = calendar.dateComponents([.year, .month, .day], from: lhs.date)
1717
let rhsComponents = calendar.dateComponents([.year, .month, .day], from: rhs.date)
1818
return lhsComponents.year == rhsComponents.year &&
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Foundation
2+
3+
extension TimeZone {
4+
public static var universalGMT: TimeZone {
5+
return TimeZone(secondsFromGMT: 0)!
6+
}
7+
}

0 commit comments

Comments
 (0)