Skip to content
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

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Copy link
Contributor

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 🙏

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] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here 🙏

self = matchedCase
} else {
return nil
}
}
Expand Down Expand Up @@ -63,10 +73,12 @@ struct SetUpCICDService {
fileManager.createDirectory(path: ".github/workflows")
switch runnerType {
case .macOSLatest:
print("Configured to run on the latest macOS.")
Copy link
Contributor

Choose a reason for hiding this comment

The 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.")
Copy link
Contributor

Choose a reason for hiding this comment

The 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")
Expand Down
Loading