-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (146 loc) · 5.7 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
141
142
143
144
145
146
147
148
149
150
151
name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test-spm:
strategy:
matrix:
os: [ macos-12 ]
swift-version: [ '' ]
xcode-version: [ '^13.4' ]
include:
- os: macos-12
swift-version: ''
xcode-version: '^14.1'
runs-on: ${{ matrix.os }}
steps:
- uses: maxim-lobanov/setup-xcode@v1
if: ${{ runner.os == 'macOS' }}
with:
xcode-version: ${{ matrix.xcode-version }}
- uses: swift-actions/[email protected]
if: ${{ runner.os == 'Linux' }}
id: swift-setup-linux
with:
swift-version: ${{matrix.swift-version}}
# Workaround for https://github.com/swift-actions/setup-swift/issues/406
- uses: sersoft-gmbh/swift-version-action@v3
if: ${{ runner.os == 'macOS' }}
id: swift-setup-macos
- id: swift-setup
env:
RUNNER_OS: ${{ runner.os }}
MACOS_SWIFT_VERSION: ${{ steps.swift-setup-macos.outputs.swift-version }}
LINUX_SWIFT_VERSION: ${{ steps.swift-setup-linux.outputs.swift-version }}
run: |
if [ "${RUNNER_OS}" == 'macOS' ]; then
echo "version=${MACOS_SWIFT_VERSION}" >> "${GITHUB_OUTPUT}"
else
echo "version=${LINUX_SWIFT_VERSION}" >> "${GITHUB_OUTPUT}"
fi
- name: Read OS Version
uses: sersoft-gmbh/os-version-action@v3
id: os-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-12
strategy:
matrix:
platform:
- macOS
- iOS
- iPadOS
- tvOS
- watchOS
env:
XCODE_SCHEME: app-groups
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ^14.1
- name: Read OS Version
uses: sersoft-gmbh/os-version-action@v3
id: os-version
- name: Read Swift Version
uses: sersoft-gmbh/swift-version-action@v3
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@v3
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