-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#552] Correct logic for choosing the CICD service #553
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,34 +7,44 @@ struct SetUpCICDService { | |
case github, bitrise, codemagic, later | ||
|
||
init?(_ name: String) { | ||
switch name.lowercased() { | ||
case "g", "github": | ||
self = .github | ||
case "b", "bitrise": | ||
self = .bitrise | ||
case "c", "codemagic": | ||
self = .codemagic | ||
case "l", "later": | ||
self = .later | ||
default: | ||
let name = name.lowercased() | ||
let mappings: [String: Self] = [ | ||
"g": .github, | ||
"github": .github, | ||
"b": .bitrise, | ||
"bitrise": .bitrise, | ||
"c": .codemagic, | ||
"codemagic": .codemagic, | ||
"l": .later, | ||
"later": .later | ||
] | ||
|
||
if let matchedCase = mappings[name] { | ||
self = matchedCase | ||
} else { | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
enum GithubRunnerType { | ||
|
||
case macOSLatest, selfHosted, later | ||
|
||
init?(_ name: String) { | ||
switch name.lowercased() { | ||
case "m", "macOS": | ||
self = .macOSLatest | ||
case "s", "self-hosted": | ||
self = .selfHosted | ||
case "l", "later": | ||
self = .later | ||
default: | ||
let mappings: [String: Self] = [ | ||
"m": .macOSLatest, | ||
"macos": .macOSLatest, | ||
"s": .selfHosted, | ||
"self-hosted": .selfHosted, | ||
"l": .later, | ||
"later": .later | ||
] | ||
|
||
let name = name.lowercased() | ||
if let matchedCase = mappings[name] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here 🙏 |
||
self = matchedCase | ||
} else { | ||
return nil | ||
} | ||
} | ||
|
@@ -63,10 +73,12 @@ struct SetUpCICDService { | |
fileManager.createDirectory(path: ".github/workflows") | ||
switch runnerType { | ||
case .macOSLatest: | ||
print("Configured to run on the latest macOS.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove print |
||
fileManager.moveFiles(in: ".github/project_workflows", to: ".github/workflows") | ||
fileManager.removeItems(in: ".github/project_workflows") | ||
fileManager.removeItems(in: ".github/self_hosted_project_workflows") | ||
case .selfHosted: | ||
print("Configured to run on self-hosted.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove print |
||
fileManager.moveFiles(in: ".github/self_hosted_project_workflows", to: ".github/workflows") | ||
fileManager.removeItems(in: ".github/project_workflows") | ||
fileManager.removeItems(in: ".github/self_hosted_project_workflows") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use
guard
here 🙏