-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (135 loc) · 5.25 KB
/
swift-test.yml
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test-spm:
strategy:
matrix:
os: [ macos-13 ]
swift-version: [ '' ]
xcode-version: [ '^14.3' ]
include:
- os: ubuntu-20.04
swift-version: 5.8
xcode-version: ''
- os: ubuntu-22.04
swift-version: 5.8
xcode-version: ''
runs-on: ${{ matrix.os }}
steps:
- if: ${{ runner.os == 'macOS' }}
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Install Swift
if: ${{ runner.os == 'Linux' }}
uses: sersoft-gmbh/swifty-linux-action@v2
with:
release-version: ${{ matrix.swift-version }}
platform: ${{ matrix.os }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Read OS Version
uses: sersoft-gmbh/os-version-action@v2
id: os-version
- name: Read Swift Version
uses: sersoft-gmbh/swift-version-action@v2
id: swift-version
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: .build
key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-version.outputs.version }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-version.outputs.version }}-
- name: Build & Test
run: swift test -v --parallel --enable-code-coverage
- name: Generate Coverage Files
uses: sersoft-gmbh/swift-coverage-action@v4
id: coverage-files
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ join(fromJSON(steps.coverage-files.outputs.files), ',') }}
fail_ci_if_error: true
test-xcode:
runs-on: macos-13
strategy:
matrix:
platform:
- macOS
env:
XCODE_SCHEME: route-docs
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ^14.3
- name: Read OS Version
uses: sersoft-gmbh/os-version-action@v2
id: os-version
- name: Read Swift Version
uses: sersoft-gmbh/swift-version-action@v2
id: swift-version
- name: Select destination
id: destination
env:
PLATFORM: ${{ matrix.platform }}
run: |
DESTINATION=''
case "${PLATFORM}" in
'macOS') DESTINATION='platform=macOS';;
'iOS') DESTINATION='platform=iOS Simulator,OS=latest,name=iPhone 13 Pro';;
'iPadOS') DESTINATION='platform=iOS Simulator,OS=latest,name=iPad Pro (11-inch) (3rd generation)';;
'tvOS') DESTINATION='platform=tvOS Simulator,OS=latest,name=Apple TV 4K (2nd generation)';;
'watchOS') DESTINATION='platform=watchOS Simulator,OS=latest,name=Apple Watch Series 7 (45mm)';;
*) echo "::error title=Unknown platform!::Unknown platform: ${PLATFORM}" && exit 1;;
esac
echo "xcode=${DESTINATION}" >> "${GITHUB_OUTPUT}"
- uses: actions/checkout@v4
# PIF ISSUES: https://github.com/apple/swift-package-manager/issues/5767
- uses: actions/cache@v3
with:
path: .build
key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-version.outputs.version }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-version.outputs.version }}-
- name: Work around PIF issues
env:
DESTINATION: ${{ steps.destination.outputs.xcode }}
run: |
swift package dump-pif > /dev/null
ATTEMPT=0
while [ -z "${SUCCESS}" ] && [ "${ATTEMPT}" -le 5 ]; do
xcodebuild clean -scheme "${XCODE_SCHEME}" -destination "${DESTINATION}" | grep -q "CLEAN SUCCEEDED" && SUCCESS=true
ATTEMPT=$((ATTEMPT + 1))
done
# END PIF ISSUES
- uses: actions/cache@v3
with:
path: .derived-data
key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-xcode-${{ steps.swift-version.outputs.version }}-${{ matrix.platform }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ steps.os-version.outputs.version }}-xcode-${{ steps.swift-version.outputs.version }}-${{ matrix.platform }}-
- uses: sersoft-gmbh/xcodebuild-action@v2
with:
spm-package: './'
scheme: ${{ env.XCODE_SCHEME }}
destination: ${{ steps.destination.outputs.xcode }}
action: test
parallel-testing-enabled: ${{ matrix.platform != 'watchOS' }}
enable-code-coverage: true
derived-data-path: .derived-data
- uses: sersoft-gmbh/swift-coverage-action@v4
id: coverage-files
with:
search-paths: |
./.build
./.derived-data
$HOME/Library/Developer/Xcode/DerivedData
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ join(fromJSON(steps.coverage-files.outputs.files), ',') }}
fail_ci_if_error: true