1
1
name : Build and Test
2
2
3
- on :
3
+ on :
4
4
push :
5
5
paths :
6
- - ' .github/workflows/test-and-coverage.yml'
7
- - ' .test-and-coverage.yml'
8
- - ' **/*.sh'
9
- - ' **/*.swift'
10
- - ' mpvx/**'
11
- - ' mpvx.xcodeproj/**'
6
+ - " .github/workflows/test-and-coverage.yml"
7
+ - " .test-and-coverage.yml"
8
+ - " **/*.sh"
9
+ - " **/*.swift"
10
+ - " mpvx/**"
11
+ - " mpvx.xcodeproj/**"
12
12
13
13
jobs :
14
14
build_and_test :
@@ -19,136 +19,136 @@ jobs:
19
19
fail-fast : false
20
20
runs-on : ${{ matrix.os }}
21
21
steps :
22
- - uses : actions/checkout@v3
23
- with :
24
- fetch-depth : 0
25
- - uses : maxim-lobanov/setup-xcode@v1
26
- with :
27
- xcode-version : latest-stable
28
- - name : Install Dependencies
29
- run : |
30
- brew install --formula mpv
31
- which mpv
32
- brew info mpv --formula
33
- - name : Setup
34
- run : |
35
- ./setup.sh
36
- - name : Run Tests
37
- run : |
38
- xcodebuild clean test \
39
- -scheme mpvx \
40
- -configuration Debug \
41
- -derivedDataPath build \
42
- -destination "platform=macOS,arch=${{ matrix.arch }}" \
43
- -resultBundlePath "artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
44
- - name : Upload Result Bundle
45
- uses : actions/upload-artifact@v4
46
- with :
47
- name : " ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
48
- path : " artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
49
- if : always()
50
- - name : Install Dependencies
51
- run : |
52
- brew install --formula xcresultparser
53
- - name : Convert Merged Result to Coverage
54
- run : |
55
- xcresultparser \
56
- --output-format cobertura \
57
- artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult > artifacts/coverage-${{ matrix.os }}-${{ matrix.arch }}.xml
58
- - name : Upload Coverage to Codecov
59
- uses : codecov/codecov-action@v5
60
- with :
61
- files : artifacts/coverage.xml
62
- token : ${{ secrets.CODECOV_TOKEN }}
63
- flags : ${{ matrix.os }}_${{ matrix.arch }}_tests
64
- fail_ci_if_error : true
22
+ - uses : actions/checkout@v3
23
+ with :
24
+ fetch-depth : 0
25
+ - uses : maxim-lobanov/setup-xcode@v1
26
+ with :
27
+ xcode-version : latest-stable
28
+ - name : Install Dependencies
29
+ run : |
30
+ brew install --formula mpv
31
+ which mpv
32
+ brew info mpv --formula
33
+ - name : Setup
34
+ run : |
35
+ ./setup.sh
36
+ - name : Run Tests
37
+ run : |
38
+ xcodebuild clean test \
39
+ -scheme mpvx \
40
+ -configuration Debug \
41
+ -derivedDataPath build \
42
+ -destination "platform=macOS,arch=${{ matrix.arch }}" \
43
+ -resultBundlePath "artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
44
+ - name : Upload Result Bundle
45
+ uses : actions/upload-artifact@v4
46
+ with :
47
+ name : " ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
48
+ path : " artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
49
+ if : always()
50
+ - name : Install Dependencies
51
+ run : |
52
+ brew install --formula xcresultparser
53
+ - name : Convert Merged Result to Coverage
54
+ run : |
55
+ xcresultparser \
56
+ --output-format cobertura \
57
+ artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult > artifacts/coverage-${{ matrix.os }}-${{ matrix.arch }}.xml
58
+ - name : Upload Coverage to Codecov
59
+ uses : codecov/codecov-action@v5
60
+ with :
61
+ files : artifacts/coverage.xml
62
+ token : ${{ secrets.CODECOV_TOKEN }}
63
+ flags : ${{ matrix.os }}_${{ matrix.arch }}_tests
64
+ fail_ci_if_error : true
65
65
66
66
merge :
67
67
runs-on : macos-latest
68
68
needs : build_and_test
69
69
steps :
70
- - name : List and download all .xcresult artifacts
71
- run : |
72
- # Get a list of all artifacts for the current run
73
- ARTS=$(curl -s \
74
- -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
75
- -H "Accept: application/vnd.github+json" \
76
- "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" \
77
- | jq -r '.artifacts[] | select(.name | endswith(".xcresult")) | [.name, .archive_download_url] | @tsv')
78
- mkdir -p artifacts
79
- # Loop through each artifact and download it
80
- while IFS=$'\t' read -r NAME URL; do
81
- echo "Downloading artifact: $NAME"
82
- curl -L \
70
+ - name : List and download all .xcresult artifacts
71
+ run : |
72
+ # Get a list of all artifacts for the current run
73
+ ARTS=$(curl -s \
83
74
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
84
- -o "$NAME.zip" "$URL"
85
- unzip "$NAME.zip" -d "artifacts/$NAME"
86
- rm "$NAME.zip"
87
- done <<< "$ARTS"
88
- - uses : maxim-lobanov/setup-xcode@v1
89
- with :
90
- xcode-version : latest-stable
91
- - name : Merge Result Bundles
92
- run : |
93
- # Dynamically find all .xcresult directories in artifacts
94
- XCBUNDLES=($(find artifacts -type d -name '*.xcresult'))
95
- if [ ${#XCBUNDLES[@]} -gt 1 ]; then
96
- xcrun xcresulttool merge "${XCBUNDLES[@]}" --output-path artifacts/ResultBundle.xcresult
97
- else
98
- # If there's only one bundle, just rename it as the merged output
99
- mv "${XCBUNDLES[0]}" artifacts/ResultBundle.xcresult
100
- fi
101
- - name : Cleanup Old Artifacts from GitHub
102
- run : |
103
- curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
104
- -H 'Accept: application/vnd.github+json' \
105
- "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" \
106
- | jq -r '.artifacts[] | select(.name | endswith(".xcresult")) | .id' \
107
- | while read artifact_id; do
108
- echo "Deleting artifact ID: $artifact_id"
109
- curl -X DELETE -s \
110
- -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
111
- -H 'Accept: application/vnd.github+json' \
112
- "https://api.github.com/repos/${{ github.repository }}/actions/artifacts/$artifact_id"
113
- done
114
- - name : Re-upload Merged Result
115
- uses : actions/upload-artifact@v4
116
- with :
117
- name : ResultBundle.xcresult
118
- path : artifacts/ResultBundle.xcresult
75
+ -H "Accept: application/vnd.github+json" \
76
+ "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" \
77
+ | jq -r '.artifacts[] | select(.name | endswith(".xcresult")) | [.name, .archive_download_url] | @tsv')
78
+ mkdir -p artifacts
79
+ # Loop through each artifact and download it
80
+ while IFS=$'\t' read -r NAME URL; do
81
+ echo "Downloading artifact: $NAME"
82
+ curl -L \
83
+ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
84
+ -o "$NAME.zip" "$URL"
85
+ unzip "$NAME.zip" -d "artifacts/$NAME"
86
+ rm "$NAME.zip"
87
+ done <<< "$ARTS"
88
+ - uses : maxim-lobanov/setup-xcode@v1
89
+ with :
90
+ xcode-version : latest-stable
91
+ - name : Merge Result Bundles
92
+ run : |
93
+ # Dynamically find all .xcresult directories in artifacts
94
+ XCBUNDLES=($(find artifacts -type d -name '*.xcresult'))
95
+ if [ ${#XCBUNDLES[@]} -gt 1 ]; then
96
+ xcrun xcresulttool merge "${XCBUNDLES[@]}" --output-path artifacts/ResultBundle.xcresult
97
+ else
98
+ # If there's only one bundle, just rename it as the merged output
99
+ mv "${XCBUNDLES[0]}" artifacts/ResultBundle.xcresult
100
+ fi
101
+ - name : Cleanup Old Artifacts from GitHub
102
+ run : |
103
+ curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
104
+ -H 'Accept: application/vnd.github+json' \
105
+ "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" \
106
+ | jq -r '.artifacts[] | select(.name | endswith(".xcresult")) | .id' \
107
+ | while read artifact_id; do
108
+ echo "Deleting artifact ID: $artifact_id"
109
+ curl -X DELETE -s \
110
+ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
111
+ -H 'Accept: application/vnd.github+json' \
112
+ "https://api.github.com/repos/${{ github.repository }}/actions/artifacts/$artifact_id"
113
+ done
114
+ - name : Re-upload Merged Result
115
+ uses : actions/upload-artifact@v4
116
+ with :
117
+ name : ResultBundle.xcresult
118
+ path : artifacts/ResultBundle.xcresult
119
119
120
120
coverage :
121
121
runs-on : macos-latest
122
122
needs : merge
123
123
steps :
124
- - uses : actions/checkout@v3
125
- with :
126
- fetch-depth : 0
127
- - name : Download Merged Artifact
128
- uses : actions/download-artifact@v4
129
- with :
130
- name : ResultBundle.xcresult
131
- path : artifacts/ResultBundle.xcresult
132
- - uses : maxim-lobanov/setup-xcode@v1
133
- with :
134
- xcode-version : latest-stable
135
- -
uses :
slidoapp/[email protected]
136
- with :
137
- path : artifacts/ResultBundle.xcresult
138
- show-passed-tests : false
139
- upload-bundles : never
140
- - name : Install Dependencies
141
- run : |
142
- brew install --formula xcresultparser
143
- - name : Convert Merged Result to Coverage
144
- run : |
145
- xcresultparser \
146
- --output-format cobertura \
147
- artifacts/ResultBundle.xcresult > artifacts/coverage.xml
148
- - name : Upload Coverage to Codecov
149
- uses : codecov/codecov-action@v5
150
- with :
151
- files : artifacts/coverage.xml
152
- token : ${{ secrets.CODECOV_TOKEN }}
153
- flags : all_tests
154
- fail_ci_if_error : true
124
+ - uses : actions/checkout@v3
125
+ with :
126
+ fetch-depth : 0
127
+ - name : Download Merged Artifact
128
+ uses : actions/download-artifact@v4
129
+ with :
130
+ name : ResultBundle.xcresult
131
+ path : artifacts/ResultBundle.xcresult
132
+ - uses : maxim-lobanov/setup-xcode@v1
133
+ with :
134
+ xcode-version : latest-stable
135
+ -
uses :
slidoapp/[email protected]
136
+ with :
137
+ path : artifacts/ResultBundle.xcresult
138
+ show-passed-tests : false
139
+ upload-bundles : never
140
+ - name : Install Dependencies
141
+ run : |
142
+ brew install --formula xcresultparser
143
+ - name : Convert Merged Result to Coverage
144
+ run : |
145
+ xcresultparser \
146
+ --output-format cobertura \
147
+ artifacts/ResultBundle.xcresult > artifacts/coverage.xml
148
+ - name : Upload Coverage to Codecov
149
+ uses : codecov/codecov-action@v5
150
+ with :
151
+ files : artifacts/coverage.xml
152
+ token : ${{ secrets.CODECOV_TOKEN }}
153
+ flags : all_tests
154
+ fail_ci_if_error : true
0 commit comments