-
Notifications
You must be signed in to change notification settings - Fork 2
122 lines (122 loc) · 4.8 KB
/
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
name: Test
on:
pull_request:
paths:
- .github/workflows/test.yml
- Package.*
- Sources/**/*.swift
- Tests/**/*.swift
- .github/matrix.json
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
extract-matrix:
name: Extract latest Xcode version from matrix
runs-on: ubuntu-latest
outputs:
xcode-versions: ${{ steps.extract-matrix.outputs.xcode-versions }}
latest: ${{ steps.extract-matrix.outputs.latest-xcode-version }}
swift-versions: ${{ steps.extract-matrix.outputs.swift-versions }}
platforms: ${{ steps.extract-matrix.outputs.platforms }}
steps:
- uses: actions/checkout@v4
- id: extract-matrix
run: |
echo "xcode-versions=$(cat .github/matrix.json | jq -rc '.xcode_version')" >> $GITHUB_OUTPUT
echo "latest-xcode-version=$(cat .github/matrix.json | jq -r '.xcode_version | max')" >> $GITHUB_OUTPUT
echo "swift-versions=$(cat .github/matrix.json | jq -rc '.swift_version')" >> $GITHUB_OUTPUT
echo "platforms=$(cat .github/matrix.json | jq -rc '.platform')" >> $GITHUB_OUTPUT
- name: dump matrix
run: |
echo 'xcode-versions = ${{ steps.extract-matrix.outputs.xcode-versions }}'
echo 'latest-xcode-version = ${{ steps.extract-matrix.outputs.latest-xcode-version }}'
echo 'swift-versions = ${{ steps.extract-matrix.outputs.swift-versions }}'
echo 'platforms = ${{ steps.extract-matrix.outputs.platforms }}'
test-macos:
name: Test
needs: extract-matrix
runs-on: macOS-14
concurrency:
group: ${{ github.head_ref }}-${{ github.workflow }}-${{ matrix.xcode }}-${{ matrix.destination }}
cancel-in-progress: true
strategy:
matrix:
xcode: ${{ fromJson(needs.extract-matrix.outputs.xcode-versions) }}
destination: ${{ fromJson(needs.extract-matrix.outputs.platforms) }}
fail-fast: false
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
steps:
- uses: actions/checkout@v4
- id: create-destination-key
name: Create destination key for cache
run: echo "destination-key=$(echo "${{ matrix.destination }}" | sed -r 's/[, ]/_/g')" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: |
.build/SourcePackages/checkouts
key: ${{ runner.os }}-xcode-${{ matrix.xcode }}-${{ steps.create-destination-key.outputs.destination-key }}-${{ hashFiles('Package.swift') }}
restore-keys: |
${{ runner.os }}-xcode-${{ matrix.xcode }}-${{ steps.create-destination-key.outputs.destination-key }}-
- name: test
run: |
defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
set -o pipefail && \
rm -rf 'MultipartFormDataParser.xcodeproj' && \
xcrun xcodebuild \
-enableCodeCoverage YES \
-scheme MultipartFormDataParser \
-destination "${{ matrix.destination }}" \
-derivedDataPath '.build' \
-resultBundlePath 'test_output/TestResult.xcresult' \
clean test | xcpretty
- name: Upload test result
uses: actions/upload-artifact@v4
if: ${{ matrix.xcode == needs.extract-matrix.outputs.latest && (success() || failure()) }}
with:
name: ${{ steps.create-destination-key.outputs.destination-key }}
path: test_output
if-no-files-found: error
retention-days: 1
xcodebuild_result:
name: Export xcodebuild test result
needs: test-macos
runs-on: macOS-14
steps:
- uses: actions/download-artifact@v4
with:
path: test_output
- name: Merge xcresult files
run:
xcrun xcresulttool merge test_output/**/*.xcresult --output-path test_output/TestResults.xcresult
- uses: kishikawakatsumi/xcresulttool@v1
if: success() || failure()
with:
path: test_output/TestResults.xcresult
show-passed-tests: false
show-code-coverage: false
upload-bundles: true
test-linux:
name: Test
needs: extract-matrix
runs-on: ubuntu-latest
container: swift:${{ matrix.swift }}
concurrency:
group: ${{ github.head_ref }}-${{ github.workflow }}-${{ matrix.swift }}
cancel-in-progress: true
strategy:
matrix:
swift: ${{ fromJson(needs.extract-matrix.outputs.swift-versions) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
.build/SourcePackages/checkouts
key: ${{ runner.os }}-xcode-${{ matrix.swift }}-${{ hashFiles('Package.swift') }}
restore-keys: |
${{ runner.os }}-xcode-${{ matrix.swift }}-
- name: test
run: swift test