Download this file
| 1 | package checks |
| 2 | |
| 3 | import ( |
| 4 | "path" |
| 5 | "strings" |
| 6 | ) |
| 7 | |
| 8 | // NeedsMacOS reports whether checking this change needs Apple's tools: |
| 9 | // the change touches Swift, Objective-C or Xcode files, or the gate |
| 10 | // itself calls Xcode's tools. A Linux runner cannot check those, so it |
| 11 | // says so rather than pass or fail. |
| 12 | func NeedsMacOS(changed []string, gateText string) bool { |
| 13 | for _, f := range changed { |
| 14 | switch strings.ToLower(path.Ext(f)) { |
| 15 | case ".swift", ".m", ".mm", ".xib", ".storyboard", ".xcconfig", ".entitlements": |
| 16 | return true |
| 17 | } |
| 18 | if strings.Contains(f, ".xcodeproj/") || strings.Contains(f, ".xcworkspace/") || path.Base(f) == "Package.swift" || path.Base(f) == "Podfile" { |
| 19 | return true |
| 20 | } |
| 21 | } |
| 22 | for _, tool := range []string{"xcodebuild", "xcrun", "swift build", "swift test", "fastlane"} { |
| 23 | if strings.Contains(gateText, tool) { |
| 24 | return true |
| 25 | } |
| 26 | } |
| 27 | return false |
| 28 | } |
| 29 | |