-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite swift-docker on top of swift-argument-parse & swift-tools-sup…
…port-core Goals: * Improve testability * Windows support * Better documentation
- Loading branch information
Showing
42 changed files
with
1,282 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/.build | ||
/Packages | ||
/*.xcodeproj | ||
**/*/xcuserdata/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4.0.3 | ||
5.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
language: generic | ||
dist: bionic | ||
sudo: required | ||
osx_image: xcode11.4 | ||
os: | ||
- linux | ||
- osx | ||
env: | ||
- SWIFT_VERSION=5.1 | ||
- SWIFT_VERSION=5.2.1 | ||
install: | ||
- if [ "$TRAVIS_OS_NAME" = "linux" ] || [ "$SWIFT_VERSION" = "5.1" ]; then eval "$(curl -sL https://swiftenv.fuller.li/en/latest/install.sh)"; fi; | ||
script: | ||
- set -o pipefail | ||
- swift test --filter TravisClientTests.JSONTests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## Docker Labels | ||
|
||
[Docker Guide](https://docs.docker.com/config/labels-custom-metadata/) | ||
|
||
our prefix is com.swiftdockercli | ||
|
||
LABEL com.swiftdockercli.action="test"/"build" | ||
LABEL com.swiftdockercli.folder="name-of-your-project" | ||
* "com.swiftdockercli.action"= - images created from the test command | ||
* "com.swiftdockercli.build" - images created from the build command | ||
|
||
LABEL "com.example.vendor"="ACME Incorporated" | ||
LABEL com.example.label-with-value="foo" | ||
|
||
Identifying test images created with `swift-docker` = `docker images --filter "com.swiftdockercli.action=bar"` | ||
|
||
## Docker Tags | ||
|
||
https://docs.docker.com/engine/reference/commandline/tag/ | ||
|
||
## Ideas | ||
|
||
* `swift docker test -s 4.1` | ||
* `swift docker test -s 4.0` | ||
* `swift docker test --configuration release` | ||
* `swift docker test --swift 4.0 --configuration release` | ||
* `swift docker test --image swiftdocker/swift:latest` | ||
* `swift docker build --tag my-tag` | ||
* `swift docker run ./build/hello --interactive` | ||
* `swift docker run --daemon/--background` | ||
* `swift docker test --log docker.log` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,40 @@ | ||
// swift-tools-version:4.0 | ||
// swift-tools-version:5.1 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "SwiftDockerCLI", | ||
products: [ | ||
.executable(name: "swift-docker", targets: ["SwiftDocker"]), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/iainsmith/ShellOut", from: "2.2.0"), | ||
.package(url: "https://github.com/kylef/Commander", from: "0.8.0"), | ||
.package(url: "https://github.com/onevcat/Rainbow", from: "3.1.1"), | ||
], | ||
targets: [ | ||
.target( | ||
name: "SwiftDocker", | ||
dependencies: ["SwiftDockerLib"]), | ||
.target( | ||
name: "SwiftDockerLib", | ||
dependencies: ["ShellOut", "Commander", "Rainbow"]), | ||
.testTarget( | ||
name: "SwiftDockerLibTests", | ||
dependencies: ["SwiftDockerLib"] | ||
), | ||
] | ||
name: "swift-docker-cli", | ||
platforms: [.macOS(.v10_14)], | ||
products: [ | ||
.executable(name: "swift-docker", targets: ["SwiftDocker"]), | ||
.library(name: "SwiftDocker", targets: ["SwiftDocker"]), | ||
], | ||
dependencies: [ | ||
.package( | ||
url: "https://github.com/apple/swift-tools-support-core", | ||
.upToNextMinor(from: "0.1.1") | ||
), | ||
.package( | ||
url: "https://github.com/apple/swift-argument-parser", | ||
.upToNextMinor(from: "0.0.5") | ||
), | ||
], | ||
targets: [ | ||
.target( | ||
name: "SwiftDocker", | ||
dependencies: ["SwiftDockerLib"] | ||
), | ||
.target( | ||
name: "SwiftDockerLib", | ||
dependencies: [ | ||
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"), | ||
.product(name: "ArgumentParser", package: "swift-argument-parser"), | ||
] | ||
), | ||
.testTarget( | ||
name: "SwiftDockerLibTests", | ||
dependencies: ["SwiftDockerLib"] | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,3 @@ | ||
import Commander | ||
import Foundation | ||
import SwiftDockerLib | ||
|
||
Group() { | ||
let version = Option("swift", | ||
default: "4.1", | ||
flag: "s", | ||
description: "The swift version to test against. e.g 4.0") | ||
// Ideally we could represent this as an optional. | ||
let image = Option("image", | ||
default: "", | ||
flag: "i", | ||
description: "(Optional) The docker image to test against. e.g swiftdocker/swift:4.0") | ||
|
||
let writeDockerfile = Flag("write-dockerfile", | ||
default: false, | ||
flag: "w", | ||
description: "Write the dockerfile to the current directory") | ||
|
||
/// swift docker test -s 4.1 | ||
/// swift docker test -s 4.0 | ||
/// swift docker test -s 4.0 -w | ||
/// swift docker test --swift 4.0 --write-dockerfile | ||
/// swift docker test --image swiftdocker/swift:latest | ||
$0.command("test", | ||
version, image, writeDockerfile, | ||
description: "Build and test the SPM package") { version, image, shouldWriteToLocalDir in | ||
try runDockerTests(version: version, image: image, writeDockerFile: shouldWriteToLocalDir) | ||
} | ||
/// swift docker test cleanup | ||
$0.command("cleanup", description: "Remove docker images created with swift docker") { | ||
try runDockerRemoveImages() | ||
} | ||
|
||
/// swift docker test write-dockerfile | ||
$0.command("write-dockerfile", version, description: "Write the default dockerfile to ./Dockerfile") { version in | ||
try writeDefaultDockerFile(version: version) | ||
} | ||
}.run() | ||
SwiftDockerCLI.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import protocol ArgumentParser.ExpressibleByArgument | ||
import class Foundation.NSString | ||
import struct Foundation.URL | ||
|
||
extension URL: ExpressibleByArgument { | ||
public init?(argument: String) { | ||
let expanded = NSString(string: argument).expandingTildeInPath | ||
self = URL(fileURLWithPath: expanded) | ||
} | ||
|
||
public var defaultValueDescription: String { | ||
self.relativeString | ||
} | ||
} |
Oops, something went wrong.