File tree Expand file tree Collapse file tree 6 files changed +67
-4
lines changed
Expand file tree Collapse file tree 6 files changed +67
-4
lines changed Original file line number Diff line number Diff line change @@ -302,6 +302,26 @@ jobs:
302302 code-coverage : ${{ matrix.codecov }}
303303 action : ${{ matrix.action }}
304304
305+ verify-sanitizers :
306+ name : ${{ matrix.platform }} ${{ matrix.sanitizer }}
307+ runs-on : macos-latest
308+ needs : [verify-dist]
309+ strategy :
310+ matrix :
311+ platform :
312+ - macOS
313+ sanitizer :
314+ - thread
315+ - address
316+ steps :
317+ - uses : actions/checkout@v4
318+ - uses : ./
319+ with :
320+ platform : ${{ matrix.platform }}
321+ working-directory : fixtures/${{ matrix.platform }}
322+ sanitizer : ${{ matrix.sanitizer }}
323+ action : test
324+
305325 verify-dot-swift-version :
306326 name : .swift-version
307327 runs-on : macos-14
Original file line number Diff line number Diff line change 6565 platform : ${{ matrix.platform }}
6666 action : build # default = `test`
6767 code-coverage : true # default = `false`
68+ sanitizer : thread # options: `thread`, `address` (only one at a time)
6869 warnings-as-errors : true # default = `false`
6970 configuration : release # no default, ie. `xcodebuild` decides itself
7071` ` `
@@ -186,10 +187,38 @@ opened in Xcode:
186187
187188![img]
188189
189- You’ ll even get your coverage report!
190+ You' ll even get your coverage report!
190191
191192> Note this feature requires Xcode >= 11
192193
194+ # # Sanitizers
195+
196+ You can enable sanitizers to help detect bugs during testing. Only one sanitizer can be enabled at a time.
197+
198+ # ## Thread Sanitizer
199+
200+ Thread Sanitizer (TSan) detects data races and other threading issues :
201+
202+ ` ` ` yaml
203+ - uses: mxcl/xcodebuild@v3
204+ with:
205+ action: test
206+ sanitizer: thread
207+ ` ` `
208+
209+ # ## Address Sanitizer
210+
211+ Address Sanitizer (ASan) detects memory corruption issues like buffer overflows and use-after-free :
212+
213+ ` ` ` yaml
214+ - uses: mxcl/xcodebuild@v3
215+ with:
216+ action: test
217+ sanitizer: address
218+ ` ` `
219+
220+ Sanitizers are only applied for `test` and `build-for-testing` actions.
221+
193222# # `.swift-version` File
194223
195224If your repo has a `.swift-version` file and neither `swift` nor `xcode` is
Original file line number Diff line number Diff line change @@ -42,6 +42,13 @@ inputs:
4242 description : Enables code coverage
4343 required : false
4444 default : ' false'
45+ sanitizer :
46+ description : |
47+ Enable a sanitizer for testing. Options: `thread`, `address`.
48+ * `thread`: Thread Sanitizer (TSan) detects threading issues like data races
49+ * `address`: Address Sanitizer (ASan) detects memory issues like buffer overflows
50+ Only one sanitizer can be enabled at a time. Leave unset to disable.
51+ required : false
4552 authentication-key-base64 :
4653 description : |
4754 A Base64-encoded authentication key issued by App Store Connect. If
Original file line number Diff line number Diff line change @@ -225,11 +225,18 @@ async function main() {
225225 if ( warningsAsErrors ) args . push ( warningsAsErrorsFlags )
226226 break
227227 case 'test' :
228- case 'build-for-testing' :
228+ case 'build-for-testing' : {
229229 if ( core . getBooleanInput ( 'code-coverage' ) ) {
230230 args = args . concat ( [ '-enableCodeCoverage' , 'YES' ] )
231231 }
232+ const sanitizer = core . getInput ( 'sanitizer' )
233+ if ( sanitizer === 'thread' ) {
234+ args = args . concat ( [ '-enableThreadSanitizer' , 'YES' ] )
235+ } else if ( sanitizer === 'address' ) {
236+ args = args . concat ( [ '-enableAddressSanitizer' , 'YES' ] )
237+ }
232238 break
239+ }
233240 }
234241
235242 if ( core . getBooleanInput ( 'trust-plugins' ) ) {
You can’t perform that action at this time.
0 commit comments