-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (105 loc) · 3.35 KB
/
pull-request.yml
File metadata and controls
116 lines (105 loc) · 3.35 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
name: Pull request
on: pull_request
env:
XCODE_VERSION: "16.3"
jobs:
prepare:
runs-on: macos-15
outputs:
platforms: ${{ steps.platforms.outputs.platforms }}
scheme: ${{ steps.scheme.outputs.scheme }}
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
run: sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app
- name: Setup mise
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl https://mise.run | sh
mise install
- name: Run linters
run: mise lint
- name: Extract platforms
id: platforms
run: |
platforms=$(swift package dump-package | jq -r '[.platforms[].platformName] | unique | @json')
echo "Platforms: $platforms"
echo "platforms=$platforms" >> $GITHUB_OUTPUT
- name: Extract scheme
id: scheme
run: |
repo=$(basename $GITHUB_REPOSITORY)
schemes=$(xcodebuild -list)
echo "$schemes"
if echo "$schemes" | grep -q "$repo-Package"; then
scheme="$repo-Package"
elif echo "$schemes" | grep -q "$repo"; then
scheme="$repo"
else
echo "Unable to select a scheme"
exit 1
fi
echo "Selected scheme: $scheme"
echo "scheme=$scheme" >> $GITHUB_OUTPUT
build-and-test:
needs: prepare
runs-on: macos-15
strategy:
fail-fast: false
matrix:
platform: ${{ fromJSON(needs.prepare.outputs.platforms) }}
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
run: sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app
- name: Map destinations
if: ${{ matrix.platform != 'macos' }}
id: destination
run: |
case "${{ matrix.platform }}" in
ios)
destination="platform=iOS Simulator,name=iPhone 16 Pro Max,OS=latest"
;;
maccatalyst)
destination="platform=macOS,variant=Mac Catalyst"
;;
tvos)
destination="platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=latest"
;;
visionos)
destination="platform=visionOS Simulator,name=Apple Vision Pro,OS=latest"
;;
watchos)
destination="platform=watchOS Simulator,name=Apple Watch Series 10 (46mm),OS=latest"
;;
*)
echo "Unknown platform: ${{ matrix.platform }}"
exit 1
;;
esac
echo "destination=$destination" >> $GITHUB_OUTPUT
- name: Build (SPM)
if: ${{ matrix.platform == 'macos' }}
run: swift build
- name: Build (Xcode)
if: ${{ matrix.platform != 'macos' }}
run: |
set -o pipefail
xcodebuild build \
-scheme ${{ needs.prepare.outputs.scheme }} \
-destination "${{ steps.destination.outputs.destination }}" | \
xcbeautify --renderer github-actions
- name: Test (SPM)
if: ${{ matrix.platform == 'macos' }}
run: |
set -o pipefail
swift test | xcbeautify --renderer github-actions
- name: Test (Xcode)
if: ${{ matrix.platform != 'macos' }}
run: |
set -o pipefail
xcodebuild test \
-scheme ${{ needs.prepare.outputs.scheme }} \
-destination "${{ steps.destination.outputs.destination }}" | \
xcbeautify --renderer github-actions