Initial commit
This commit is contained in:
commit
c0ad6e2164
|
@ -0,0 +1,93 @@
|
|||
local notify = {
|
||||
name: 'notify',
|
||||
image: 'appleboy/drone-telegram',
|
||||
settings: {
|
||||
token: { from_secret: 'telegram_token' },
|
||||
to: { from_secret: 'telegram_chat' }
|
||||
}
|
||||
};
|
||||
|
||||
local swift(name, commands) = {
|
||||
name: name,
|
||||
image: 'swift:5.2.3',
|
||||
commands: commands,
|
||||
};
|
||||
|
||||
local build(configuration='debug') = swift(
|
||||
'build_%(configuration)s' % { configuration: configuration },
|
||||
[
|
||||
'swift package clean',
|
||||
'swift build -c %(configuration)s --enable-test-discovery' % { configuration: configuration },
|
||||
]
|
||||
);
|
||||
|
||||
local test = swift('test', [
|
||||
'swift test --enable-test-discovery',
|
||||
]);
|
||||
|
||||
local codecov = swift('codecov', [
|
||||
'swift package clean',
|
||||
'swift test --enable-test-discovery --enable-code-coverage',
|
||||
'BINARY_PATH=$(find .build/debug/ -maxdepth 1 -name "*.xctest" | head -1)',
|
||||
'PROF_DATA_PATH=.build/debug/codecov/default.profdata',
|
||||
'IGNORE_FILENAME_REGEX="(.build|TestUtils|Tests)"',
|
||||
'llvm-cov report "$BINARY_PATH" --format=text -instr-profile="$PROF_DATA_PATH" -ignore-filename-regex="$IGNORE_FILENAME_REGEX"',
|
||||
]);
|
||||
|
||||
|
||||
local lint = {
|
||||
name: 'lint',
|
||||
image: 'norionomura/swiftlint:0.39.2',
|
||||
commands: [
|
||||
'scripts/lint.sh',
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
local whenCommitToNonMaster(step) = step {
|
||||
when: {
|
||||
event: ['push'],
|
||||
branch: { exclude: ['master'] },
|
||||
}
|
||||
};
|
||||
|
||||
local commitToNonMasterSteps = std.map(whenCommitToNonMaster, [
|
||||
build('debug'),
|
||||
test,
|
||||
]);
|
||||
|
||||
local whenUpdatePR(step) = step {
|
||||
when: {
|
||||
event: ['pull_request']
|
||||
},
|
||||
};
|
||||
|
||||
local whenUpdatePRSteps = std.map(whenUpdatePR, [
|
||||
codecov,
|
||||
notify
|
||||
]);
|
||||
|
||||
|
||||
local whenMergeToMaster(step) = step {
|
||||
when: {
|
||||
event: ['push'],
|
||||
branch: ['master'],
|
||||
},
|
||||
};
|
||||
|
||||
local mergeToMasterSteps = std.map(whenMergeToMaster, [
|
||||
build('release'),
|
||||
]);
|
||||
|
||||
local pipelines = std.flattenArrays([
|
||||
[lint],
|
||||
commitToNonMasterSteps,
|
||||
whenUpdatePRSteps,
|
||||
mergeToMasterSteps,
|
||||
]);
|
||||
|
||||
{
|
||||
name: 'default',
|
||||
kind: 'pipeline',
|
||||
steps: pipelines
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
# ---> Swift
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
## User settings
|
||||
xcuserdata/
|
||||
|
||||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
|
||||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
|
||||
build/
|
||||
DerivedData/
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
|
||||
## Obj-C/Swift specific
|
||||
*.hmap
|
||||
|
||||
## App packaging
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
|
||||
## Playgrounds
|
||||
timeline.xctimeline
|
||||
playground.xcworkspace
|
||||
|
||||
# Swift Package Manager
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||
# Packages/
|
||||
# Package.pins
|
||||
# Package.resolved
|
||||
# *.xcodeproj
|
||||
#
|
||||
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
|
||||
# hence it is not needed unless you have added a package configuration file to your project
|
||||
# .swiftpm
|
||||
|
||||
.build/
|
||||
|
||||
# CocoaPods
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
# Pods/
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from the Xcode workspace
|
||||
# *.xcworkspace
|
||||
|
||||
# Carthage
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Build/
|
||||
|
||||
# Accio dependency management
|
||||
Dependencies/
|
||||
.accio/
|
||||
|
||||
# fastlane
|
||||
#
|
||||
# It is recommended to not store the screenshots in the git repo.
|
||||
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
|
||||
# For more information about the recommended setup visit:
|
||||
# https://docs.fastlane.tools/best-practices/source-control/#source-control
|
||||
|
||||
fastlane/report.xml
|
||||
fastlane/Preview.html
|
||||
fastlane/screenshots/**/*.png
|
||||
fastlane/test_output
|
||||
|
||||
# Code Injection
|
||||
#
|
||||
# After new code Injection tools there's a generated folder /iOSInjectionProject
|
||||
# https://github.com/johnno1962/injectionforxcode
|
||||
|
||||
iOSInjectionProject/
|
||||
|
||||
.DS_Store
|
||||
|
||||
*.xcodeproj
|
|
@ -0,0 +1,22 @@
|
|||
type_name:
|
||||
min_length: 3
|
||||
|
||||
line_length:
|
||||
warning: 150
|
||||
error: 500
|
||||
ignores_comments: true
|
||||
|
||||
nesting:
|
||||
type_level:
|
||||
warning: 3
|
||||
|
||||
type_body_length:
|
||||
warning: 250
|
||||
error: 500
|
||||
|
||||
identifier_name:
|
||||
excluded:
|
||||
- id
|
||||
|
||||
disabled_rules:
|
||||
- large_tuple
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
// Running executables
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Run",
|
||||
"program": "${workspaceFolder}/.build/debug/App",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"preLaunchTask": "swift-build"
|
||||
},
|
||||
// Running unit tests
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug tests on macOS",
|
||||
"program": "/Applications/Xcode.app/Contents/Developer/usr/bin/xctest",
|
||||
"args": [
|
||||
"${workspaceFolder}/.build/debug/${workspaceFolderBasename}PackageTests.xctest"
|
||||
],
|
||||
"preLaunchTask": "swift-build-tests"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug tests on Linux",
|
||||
"program": "${workspaceFolder}/.build/x86_64-unknown-linux/debug/${workspaceFolderBasename}PackageTests.xctest",
|
||||
"preLaunchTask": "swift-build-tests"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
// compile your SPM project
|
||||
{
|
||||
"label": "swift-build",
|
||||
"type": "shell",
|
||||
"command": "swift build"
|
||||
},
|
||||
// compile your SPM tests
|
||||
{
|
||||
"label": "swift-build-tests",
|
||||
"type": "process",
|
||||
"command": "swift",
|
||||
"group": "build",
|
||||
"args": [
|
||||
"build",
|
||||
"--build-tests",
|
||||
"--enable-test-discovery"
|
||||
// for TensorFlow add "-Xlinker", "-ltensorflow"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
MIT License Copyright (c) <year> <copyright holders>
|
||||
|
||||
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 (including the next
|
||||
paragraph) 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.
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"object": {
|
||||
"pins": [
|
||||
{
|
||||
"package": "swift-argument-parser",
|
||||
"repositoryURL": "https://github.com/apple/swift-argument-parser",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "223d62adc52d51669ae2ee19bdb8b7d9fd6fcd9c",
|
||||
"version": "0.0.6"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"version": 1
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// swift-tools-version:5.2
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "cli-template",
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
// .package(url: /* package url */, from: "1.0.0"),
|
||||
.package(url: "https://github.com/apple/swift-argument-parser", from: "0.0.1"),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
|
||||
.target(
|
||||
name: "App",
|
||||
dependencies: [
|
||||
.product(name: "ArgumentParser", package: "swift-argument-parser"),
|
||||
"Lib",
|
||||
]),
|
||||
.testTarget(
|
||||
name: "AppTests",
|
||||
dependencies: ["App"]),
|
||||
.target(
|
||||
name: "Lib",
|
||||
dependencies: [
|
||||
]),
|
||||
.testTarget(
|
||||
name: "LibTests",
|
||||
dependencies: ["Lib"]),
|
||||
]
|
||||
)
|
|
@ -0,0 +1,4 @@
|
|||
# cli-template
|
||||
[![Build Status](http://ci.merlin.local/api/badges/Templates/cli-template/status.svg)](http://ci.merlin.local/Templates/cli-template)
|
||||
|
||||
Base template for cli project
|
|
@ -0,0 +1,12 @@
|
|||
import ArgumentParser
|
||||
import Lib
|
||||
// struct Random: ParsableCommand {
|
||||
// @Argument() var highValue: Int
|
||||
|
||||
// func run() {
|
||||
// print(Int.random(in: 1...highValue))
|
||||
// }
|
||||
// }
|
||||
// Random.main()
|
||||
_ = foo()
|
||||
print("Hello, world!")
|
|
@ -0,0 +1,3 @@
|
|||
public func foo() -> Int {
|
||||
return 42
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
import XCTest
|
||||
import class Foundation.Bundle
|
||||
|
||||
final class OutputTests: XCTestCase {
|
||||
func testExample() throws {
|
||||
// This is an example of a functional test case.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct
|
||||
// results.
|
||||
|
||||
// Some of the APIs that we use below are available in macOS 10.13 and above.
|
||||
guard #available(macOS 10.13, *) else {
|
||||
return
|
||||
}
|
||||
|
||||
let fooBinary = productsDirectory.appendingPathComponent("App")
|
||||
|
||||
let process = Process()
|
||||
process.executableURL = fooBinary
|
||||
|
||||
let pipe = Pipe()
|
||||
process.standardOutput = pipe
|
||||
|
||||
try process.run()
|
||||
process.waitUntilExit()
|
||||
|
||||
let data = pipe.fileHandleForReading.readDataToEndOfFile()
|
||||
let output = String(data: data, encoding: .utf8)
|
||||
|
||||
XCTAssertEqual(output, "Hello, world!\n")
|
||||
}
|
||||
|
||||
/// Returns path to the built products directory.
|
||||
var productsDirectory: URL {
|
||||
#if os(macOS)
|
||||
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
|
||||
return bundle.bundleURL.deletingLastPathComponent()
|
||||
}
|
||||
fatalError("couldn't find the products directory")
|
||||
#else
|
||||
return Bundle.main.bundleURL
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import XCTest
|
||||
@testable import Lib
|
||||
|
||||
final class FooTests: XCTestCase {
|
||||
|
||||
func testFoo() throws {
|
||||
XCTAssertEqual(42, foo())
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
import XCTest
|
||||
fatalError("Run the tests with `swift test --enable-test-discovery`.")
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
swiftlint lint --path Sources --config ../.swiftlint.yml --strict
|
||||
swiftlint lint --path Tests --config ../.swiftlint.yml --strict
|
Loading…
Reference in New Issue