Compare commits

..

No commits in common. "master" and "xcode_12" have entirely different histories.

17 changed files with 96 additions and 152 deletions

View File

@ -1,47 +0,0 @@
name: Swift
on:
pull_request:
branches: [ master ]
jobs:
build:
runs-on: macos-12
strategy:
fail-fast: false
matrix:
xcode: ["13.1", "13.3.1", "14.2"]
steps:
- uses: actions/checkout@v2
- name: Select Xcode
run: |
xcodebuild -version
ls -nt /Applications/ | grep "Xcode*"
sudo xcode-select -switch /Applications/Xcode_${{ matrix.xcode }}.app
xcodebuild -version
- name: Run tests
run: swift test
- name: Build
run: swift build --disable-sandbox -c release
- name: Create test release
run: ./.build/release/rocket 1.0.0 --rocket-file .test.yml
build-macos11:
runs-on: macos-11
strategy:
fail-fast: false
matrix:
xcode: ["12.5.1", "13.0"]
steps:
- uses: actions/checkout@v2
- name: Select Xcode
run: |
xcodebuild -version
ls -nt /Applications/ | grep "Xcode*"
sudo xcode-select -switch /Applications/Xcode_${{ matrix.xcode }}.app
xcodebuild -version
- name: Run tests
run: swift test
- name: Build
run: swift build --disable-sandbox -c release
- name: Create test release
run: ./.build/release/rocket 1.0.0 --rocket-file .test.yml

1
.gitignore vendored
View File

@ -2,4 +2,3 @@
/.build
/Packages
/*.xcodeproj
/.swiftpm/xcode

21
LICENSE
View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2022 Shiba Package Manager
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,13 +1,31 @@
{
"object": {
"pins": [
{
"package": "CwlCatchException",
"repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git",
"state": {
"branch": null,
"revision": "7cd2f8cacc4d22f21bc0b2309c3b18acf7957b66",
"version": "1.2.0"
}
},
{
"package": "CwlPreconditionTesting",
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state": {
"branch": null,
"revision": "c228db5d2ad1b01ebc84435e823e6cca4e3db98b",
"version": "1.2.0"
}
},
{
"package": "Komondor",
"repositoryURL": "https://github.com/shibapm/Komondor.git",
"state": {
"branch": null,
"revision": "90b087b1e39069684b1ff4bf915c2aae594f2d60",
"version": "1.1.3"
"revision": "3cd6d76887816ead5931ddbfb249c2935f518e17",
"version": "1.0.4"
}
},
{
@ -24,8 +42,8 @@
"repositoryURL": "https://github.com/Quick/Nimble",
"state": {
"branch": null,
"revision": "7a46a5fc86cb917f69e3daf79fcb045283d8f008",
"version": "8.1.2"
"revision": "6abeb3f5c03beba2b9e4dbe20886e773b5b629b6",
"version": "8.0.4"
}
},
{
@ -33,8 +51,8 @@
"repositoryURL": "https://github.com/shibapm/PackageConfig.git",
"state": {
"branch": null,
"revision": "7081db0a7ad0ce6002115944c26c915167dc0617",
"version": "1.1.2"
"revision": "fd0829aac9851434b3d2db0890e27bc489fc973a",
"version": "0.12.2"
}
},
{
@ -42,8 +60,8 @@
"repositoryURL": "https://github.com/Quick/Quick",
"state": {
"branch": null,
"revision": "8cce6acd38f965f5baa3167b939f86500314022b",
"version": "3.1.2"
"revision": "33682c2f6230c60614861dfc61df267e11a1602f",
"version": "2.2.0"
}
},
{
@ -51,8 +69,8 @@
"repositoryURL": "https://github.com/JohnSundell/ShellOut.git",
"state": {
"branch": null,
"revision": "e1577acf2b6e90086d01a6d5e2b8efdaae033568",
"version": "2.3.0"
"revision": "4ebf25863deb9c3c02696704fc3d39736183f258",
"version": "2.2.1"
}
},
{
@ -60,8 +78,8 @@
"repositoryURL": "https://github.com/nicklockwood/SwiftFormat.git",
"state": {
"branch": null,
"revision": "fab94f3ca17f0f75e87787ed83b3a9423348b14c",
"version": "0.49.1"
"revision": "b564570c139d1c36292e8a5bb08d4ba6818b0a91",
"version": "0.43.0"
}
},
{
@ -69,8 +87,8 @@
"repositoryURL": "https://github.com/kareman/SwiftShell",
"state": {
"branch": null,
"revision": "99680b2efc7c7dbcace1da0b3979d266f02e213c",
"version": "5.1.0"
"revision": "a6014fe94c3dbff0ad500e8da4f251a5d336530b",
"version": "5.1.0-beta.1"
}
},
{
@ -78,8 +96,8 @@
"repositoryURL": "https://github.com/f-meloni/TestSpy",
"state": {
"branch": null,
"revision": "63398d17c70ba7419cec78834f22be86b850643b",
"version": "0.5.0"
"revision": "e2970747d5d2d280367b446cbd8d1f8c154333b4",
"version": "0.4.1"
}
},
{
@ -87,8 +105,8 @@
"repositoryURL": "https://github.com/jpsim/Yams",
"state": {
"branch": null,
"revision": "f47ba4838c30dbd59998a4e4c87ab620ff959e8a",
"version": "5.0.5"
"revision": "c947a306d2e80ecb2c0859047b35c73b8e1ca27f",
"version": "2.0.0"
}
}
]

View File

@ -1,4 +1,4 @@
// swift-tools-version:5.4
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
@ -14,10 +14,10 @@ let package = Package(
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/jpsim/Yams", from: "5.0.0"),
.package(url: "https://github.com/jpsim/Yams", from: "2.0.0"),
.package(url: "https://github.com/shibapm/Logger", from: "0.2.2"),
.package(url: "https://github.com/kareman/SwiftShell", from: "5.1.0"),
.package(url: "https://github.com/shibapm/PackageConfig.git", from: "1.0.0"),
.package(url: "https://github.com/kareman/SwiftShell", .exact("5.1.0-beta.1")),
.package(url: "https://github.com/shibapm/PackageConfig.git", from: "0.10.0"),
// Dev Dependencies for testing.setup
.package(url: "https://github.com/Quick/Nimble", from: "8.0.0"), // dev
.package(url: "https://github.com/f-meloni/TestSpy", from: "0.3.1"), // dev
@ -31,7 +31,7 @@ let package = Package(
name: "RocketLib",
dependencies: ["Logger", "SwiftShell"]
),
.executableTarget(
.target(
name: "Rocket",
dependencies: ["Yams", "Logger", "PackageConfig", "RocketLib"]
),

View File

@ -29,7 +29,7 @@ steps:
```
#### With PackageConfig
With [PackageConfig](https://github.com/shibapm/PackageConfig) you can put the configuration at the end of your `Package.swift`
With PackageConfig (https://github.com/orta/PackageConfig) you can put the configuration at the end of your `Package.swift`
```swift
#if canImport(PackageConfig)

View File

@ -32,8 +32,7 @@ if let rocketYamlPath = RocketFileFinder.rocketFilePath() {
dictionary = loadedDictionary
} else if let packageConfig = try? PackageConfiguration.load().configuration,
let rocketConfig = packageConfig["rocket"] as? [String: Any]
{
let rocketConfig = packageConfig["rocket"] as? [String: Any] {
dictionary = rocketConfig
} else {
dictionary = [:]

View File

@ -12,8 +12,7 @@ public enum ChecksParser {
private static func parseElement(_ element: Any) -> Check? {
if let string = element as? String,
let check = PreReleseCheck(rawValue: string)
{
let check = PreReleseCheck(rawValue: string) {
return check.check(dictionary: nil)
} else {
return nil

View File

@ -4,8 +4,7 @@ import Logger
final class BranchExecutor: ScriptLauncherExecutor<BranchParameters> {
override func executeStep(version: String, logger: Logger) {
guard let branchName = parameters.name,
!branchName.isEmpty
else {
!branchName.isEmpty else {
logger.logError("Invalid branch name")
return
}

View File

@ -4,8 +4,7 @@ import Logger
final class ScriptExecutor: ScriptLauncherExecutor<ScriptParameters> {
override func executeStep(version: String, logger: Logger) {
guard let content = parameters.content,
!content.isEmpty
else {
!content.isEmpty else {
logger.logError("Invalid script content")
return
}

View File

@ -11,19 +11,20 @@ final class SwiftScriptExecutor: DefaultExecutor<SwiftScriptParameters> {
return
}
let supportedSwiftPaths = ["/usr/bin/swift", "/home/travis/.swiftenv/shims/swift"]
let supportedSwiftCPaths = ["/usr/bin/swiftc", "/home/travis/.swiftenv/shims/swiftc"]
let swiftPath = supportedSwiftPaths.first { fileManager.fileExists(atPath: $0) }
let swift = swiftPath ?? "swift"
let swiftCPath = supportedSwiftCPaths.first { fileManager.fileExists(atPath: $0) }
let swiftC = swiftCPath ?? "swiftc"
let args = [
"--driver-mode=swift",
scriptPath,
version,
] + parameters.arguments
logger.logInfo("Running: \(swift) \(args.joined(separator: " "))")
logger.logInfo("Running: \(swiftC) \(args.joined(separator: " "))")
let process = Process()
process.launchPath = swift
process.launchPath = swiftC
process.arguments = args
let standardOutput = FileHandle.standardOutput

View File

@ -2,6 +2,6 @@ import Foundation
extension Dictionary {
subscript<T: RawRepresentable, R>(rawRappresentable: T) -> R? where T.RawValue == Key {
self[rawRappresentable.rawValue] as? R
return self[rawRappresentable.rawValue] as? R
}
}

View File

@ -1,13 +1,12 @@
import Foundation
public enum RocketFileFinder {
public final class RocketFileFinder {
static let rocketFileParameter = "--rocket-file"
static let defaultRocketFilePath = ".rocket.yml"
public static func rocketFilePath(args: [String] = CommandLine.arguments, fileManager: FileManager = .default) -> String? {
if let index = args.firstIndex(of: rocketFileParameter),
index < args.count - 1
{
index < args.count - 1 {
return args[index + 1]
} else if fileManager.fileExists(atPath: defaultRocketFilePath) {
return defaultRocketFilePath

View File

@ -38,8 +38,7 @@ public enum StepsParser {
return Step.script.executor(dictionary: [ScriptParameters.CodingKeys.content.rawValue: string])
}
} else if let stepDict = element as? [String: Any],
let step = step(fromDictionary: stepDict)
{
let step = step(fromDictionary: stepDict) {
return step.executor(dictionary: stepDict[step.rawValue] as? [String: Any])
} else {
logger.logWarning("Invalid step found")
@ -62,8 +61,7 @@ public enum StepsParser {
private static func step(fromDictionary dictionary: [String: Any]) -> Step? {
guard let stepString = dictionary.keys.first,
dictionary.keys.count == 1
else {
dictionary.keys.count == 1 else {
return nil
}

View File

@ -17,7 +17,7 @@ public enum VersionBumpOption: String {
func newVersion(currentVersion: String) -> String {
var versionComponent = currentVersion.split(separator: ".").map { String($0) }
let componentIndex = index
let componentIndex = self.index
let newComponent = Int(versionComponent[componentIndex])?.advanced(by: 1) ?? 0
versionComponent[componentIndex] = newComponent.description

View File

@ -15,8 +15,9 @@ final class SwiftScriptExecutorTests: XCTestCase {
executor.executeStep(version: "1.0.0", logger: Logger.testLogger)
expect(processLauncher.receivedProcess?.launchPath) == "/usr/bin/swift"
expect(processLauncher.receivedProcess?.launchPath) == "/usr/bin/swiftc"
expect(processLauncher.receivedProcess?.arguments) == [
"--driver-mode=swift",
testPath,
"1.0.0",
]

View File

@ -2,8 +2,8 @@
import XCTest
extension BranchExecutorTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__BranchExecutorTests = [
("testItSendsEmptyScriptIfTheDictionaryIsNil", testItSendsEmptyScriptIfTheDictionaryIsNil),
@ -13,8 +13,8 @@
}
extension ChecksParserTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__ChecksParserTests = [
("testItIgnoresTheInvalidSteps", testItIgnoresTheInvalidSteps),
@ -23,8 +23,8 @@
}
extension CleanGitStatusCheckTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__CleanGitStatusCheckTests = [
("testReturnsFailureWhenThereIsAreModifiedFiles", testReturnsFailureWhenThereIsAreModifiedFiles),
@ -33,8 +33,8 @@
}
extension CommitExecutorTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__CommitExecutorTests = [
("testItSetsTheParameterIfTheGitHookFolderExists", testItSetsTheParameterIfTheGitHookFolderExists),
@ -45,8 +45,8 @@
}
extension CurrentVersionProviderTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__CurrentVersionProviderTests = [
("testItReturnsTheCorrectTag", testItReturnsTheCorrectTag),
@ -55,8 +55,8 @@
}
extension DefaultExecutorStepDescriptionTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__DefaultExecutorStepDescriptionTests = [
("testItShowsTheCorrectEndDescriptionWhenThereAreNoParameters", testItShowsTheCorrectEndDescriptionWhenThereAreNoParameters),
@ -67,8 +67,8 @@
}
extension DevDependenciesModifierTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__DevDependenciesModifierTests = [
("testItHidesTheDependenciesCorrectly", testItHidesTheDependenciesCorrectly),
@ -77,8 +77,8 @@
}
extension GitAddExecutorTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__GitAddExecutorTests = [
("testItDoesntSendAnyCommandToTheScriptLauncherIfTheDictionaryIsNil", testItDoesntSendAnyCommandToTheScriptLauncherIfTheDictionaryIsNil),
@ -88,8 +88,8 @@
}
extension HideDevDependenciesExecutorTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__HideDevDependenciesExecutorTests = [
("testItSendsTheHideDependenciesCallToTheDevDependenciesModifier", testItSendsTheHideDependenciesCallToTheDevDependenciesModifier),
@ -98,8 +98,8 @@
}
extension NewVersionProviderTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__NewVersionProviderTests = [
("testReturnsTheCorrectNewVersion", testReturnsTheCorrectNewVersion),
@ -107,8 +107,8 @@
}
extension PushExecutorTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__PushExecutorTests = [
("testItAddsTheNoVerifyParameterIfGitHookFolderIsPresent", testItAddsTheNoVerifyParameterIfGitHookFolderIsPresent),
@ -119,8 +119,8 @@
}
extension RocketFileFinderTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__RocketFileFinderTests = [
("testItReturnsNilIfThereAreNoArgumentsAndTheDefaultFileDoesntExist", testItReturnsNilIfThereAreNoArgumentsAndTheDefaultFileDoesntExist),
@ -130,8 +130,8 @@
}
extension ScriptExecutorTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__ScriptExecutorTests = [
("testItDoesntSendAnyCommandToTheScriptLauncherIfTheContentIsEmpty", testItDoesntSendAnyCommandToTheScriptLauncherIfTheContentIsEmpty),
@ -142,8 +142,8 @@
}
extension ScriptLauncherTestCase {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__ScriptLauncherTestCase = [
("testItUsesAWorkaroundToGenerateTheTestsOnLinux", testItUsesAWorkaroundToGenerateTheTestsOnLinux),
@ -151,8 +151,8 @@
}
extension StepsParserTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__StepsParserTests = [
("testItCreatesAScriptStepForNotRecognisedStrings", testItCreatesAScriptStepForNotRecognisedStrings),
@ -166,8 +166,8 @@
}
extension SwiftScriptExecutorTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__SwiftScriptExecutorTests = [
("testItCreatesTheCorrectProcess", testItCreatesTheCorrectProcess),
@ -177,8 +177,8 @@
}
extension TagExecutorTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__TagExecutorTests = [
("testItSendsTheCorrectScriptToTheScriptLauncher", testItSendsTheCorrectScriptToTheScriptLauncher),
@ -187,8 +187,8 @@
}
extension UnhideDevDependenciesExecutorTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__UnhideDevDependenciesExecutorTests = [
("testItSendsTheHideDependenciesCallToTheDevDependenciesModifier", testItSendsTheHideDependenciesCallToTheDevDependenciesModifier),