Repository navigation
119 lines (111 loc) · 4.29 KB
/
Copy pathci.yml
File metadata and controls
119 lines (111 loc) · 4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: CI
on:
pull_request:
branches: [ master ]
push:
branches: [ master ]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
IOS_DESTINATION: platform=iOS Simulator,name=iPhone 17,OS=latest
# Minimum library line coverage in percent. Only ever raise it, to the level the latest test PR reaches.
COVERAGE_THRESHOLD: "71.7"
jobs:
lint:
name: SwiftLint
runs-on: ubuntu-latest
container: ghcr.io/realm/swiftlint:0.65.1
steps:
- uses: actions/checkout@v4
- name: Lint
run: swiftlint lint --strict --reporter github-actions-logging
release-guard:
name: Version / Changelog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Top CHANGELOG.md entry matches the release manifest
run: |
version=$(jq -r '."."' .release-please-manifest.json)
header=$(grep -m1 '^## ' CHANGELOG.md)
echo "manifest: $version, changelog: $header"
[[ "$header" =~ ^"## [$version] - "[0-9]{2}\.[0-9]{2}\.[0-9]{4}\.$ ]] || {
echo "::error file=CHANGELOG.md,line=1::Expected '## [$version] - dd.MM.yyyy.', got '$header'"
exit 1
}
package:
name: Package (iOS test, watchOS build)
runs-on: macos-26
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
# A freshly booted simulator's health daemon drops writes for a minute or two on CI machines.
# Booting it first lets that pass while the package builds; the tests then run on this device.
- name: Boot the test simulator
run: |
udid=$(xcrun simctl list devices available -j | jq -r '
.devices | to_entries
| map(select(.key | test("SimRuntime\\.iOS-")))
| sort_by(.key | capture("iOS-(?<v>[0-9-]+)$").v | split("-") | map(tonumber))
| last | .value[] | select(.name == "iPhone 17") | .udid' | head -1)
[[ -n "$udid" ]] || { echo "::error::No iPhone 17 simulator on the latest iOS runtime"; exit 1; }
xcrun simctl bootstatus "$udid" -b
echo "TEST_DESTINATION=platform=iOS Simulator,id=$udid" >> "$GITHUB_ENV"
- name: Validate manifest
run: swift package dump-package > /dev/null
- name: Test (iOS)
run: |
xcodebuild test -scheme HealthKitReporter \
-destination "$TEST_DESTINATION" \
-enableCodeCoverage YES \
-resultBundlePath TestResults.xcresult \
CODE_SIGNING_REQUIRED=NO
- name: Coverage gate
run: |
xcrun xccov view --report --only-targets TestResults.xcresult | tee coverage.txt
coverage=$(xcrun xccov view --report --json TestResults.xcresult \
| jq '.targets[] | select(.name == "HealthKitReporter") | .lineCoverage * 100')
echo "library coverage: $coverage%, threshold: $COVERAGE_THRESHOLD%"
awk -v c="$coverage" -v t="$COVERAGE_THRESHOLD" 'BEGIN { exit !(c >= t) }' || {
echo "::error::Library line coverage $coverage% is below the $COVERAGE_THRESHOLD% threshold"
exit 1
}
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
TestResults.xcresult
coverage.txt
if-no-files-found: ignore
- name: Build (watchOS)
run: |
xcodebuild build -scheme HealthKitReporter \
-destination "generic/platform=watchOS Simulator" \
CODE_SIGNING_REQUIRED=NO
example:
name: Example app
runs-on: macos-26
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Build
run: |
xcodebuild build -project Example/HealthKitReporter.xcodeproj \
-scheme HealthKitReporter_Example \
-destination "$IOS_DESTINATION" \
CODE_SIGNING_ALLOWED=NO
- name: Build (watch companion)
run: |
xcodebuild build -project Example/HealthKitReporter.xcodeproj \
-scheme HealthKitReporterWatch \
-destination "generic/platform=watchOS Simulator" \
CODE_SIGNING_ALLOWED=NO