Skip to content

Commit

Permalink
readme changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianKahnert committed Jan 17, 2020
1 parent f875e4e commit b8a00b3
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 16 deletions.
58 changes: 54 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,55 @@
# chia - Check It All
# 🌱 chia - Check It All

## Usage
`chia` is a command line tool that lets you run some checks.
It can be easily integrated into your CI process.

## 🕹 Usage

You can run `chia` in your terminal, but keep in mind to also install all **required dependencies**.
Otherwise, the check might fail!
```bash
# detect language and run all available tests
chia

# specify a config for chia (local/remote)
chia --config /PATH/TO/.chia.yml
chia --config https://PATH/TO/.chia.yml

# only detect and return the language of the project
chia --only-language-detection
```

Instead of keeping track of your dependencies, you can use our [Docker Image](https://hub.docker.com/r/worldiety/chia).
It contains all the required binaries and is ready to use:
```bash
# run docker container with all dependencies and mount the current folder for analysis
docker run -it -v ${PWD}:/project worldiety/chia:latest
docker run -it -v ${PWD}:/project worldiety/chia:latest
```

You can also add this to your [GitLab CI config](https://docs.gitlab.com/ce/ci/yaml/) ...
```yml
...

stages:
- lint
- build
- deploy

chia:
stage: lint
image: worldiety/chia:latest
allow_failure: false
script:
- chia

...
```

... or use our [:octocat: Github Action](https://github.com/marketplace/actions/github-action-for-chia).

## Installation
## ⌨️🖱Installation

There are 2 ways to install `chia`. Choose the one that fits your needs.

Using [Mint](https://github.com/yonaskolb/mint):
```bash
Expand All @@ -24,3 +62,15 @@ git clone https://github.com/worldiety/chia && cd chia
swift build --configuration release
mv `swift build --configuration release --show-bin-path`/chia /usr/local/bin
```


## :octocat: Contributions

All contributions are welcome!
Feel free to contribute to this project.
Submit pull requests or contribute tutorials - whatever you have to offer, it would be appreciated!

If a check is missing, the [`CheckProvider`](https://github.com/worldiety/chia/blob/master/Sources/chiaLib/Internal/CheckProvider.swift) is the right places to start.
Just add another implemention and have a look at all the [other checks](https://github.com/worldiety/chia/tree/master/Sources/chiaLib/Internal/CheckProviders).

If your favorite programming language is missing, have a look at the [`Language`](https://github.com/worldiety/chia/blob/master/Sources/chiaLib/API/Language.swift).
15 changes: 15 additions & 0 deletions Sources/chiaLib/API/Chia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation
import FoundationNetworking
#endif
import Logging
import ShellOut
import Yams

/// Main part of `Chia`.
Expand Down Expand Up @@ -122,6 +123,12 @@ public struct Chia {
for provider in filteredProviders {
do {

// validate if all dependencies (e.g. "swiftlint") exist
for dependency in provider.dependencies {
try canFindDependency(binary: dependency)
}

// run the check
let checkResults = try provider.run(with: config, at: projectRootFolder)
results.append(contentsOf: checkResults)

Expand Down Expand Up @@ -149,6 +156,14 @@ public struct Chia {
}
}

private func canFindDependency(binary: String) throws {
do {
try shellOut(to: "which", arguments: [binary])
} catch {
throw CheckError.dependencyNotFound(dependency: binary)
}
}

private func log(_ results: [CheckResult]) {

logger?.info("\n\nCheck Results:\n")
Expand Down
9 changes: 1 addition & 8 deletions Sources/chiaLib/Internal/CheckProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import ShellOut

protocol CheckProvider {
static var type: Language { get }
static var dependencies: [String] { get }
static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult]
}

Expand All @@ -24,14 +25,6 @@ extension CheckProvider {
Logger(label: "CheckProvider")
}

static func canFindDependency(binary: String) throws {
do {
try shellOut(to: "which", arguments: [binary])
} catch {
throw CheckError.dependencyNotFound(dependency: binary)
}
}

static func isPart(of providers: [String]) -> Bool {
let selfDescription = String(describing: Self.self).lowercased()
return providers.contains { selfDescription.contains($0.lowercased()) }
Expand Down
1 change: 1 addition & 0 deletions Sources/chiaLib/Internal/CheckProviders/LicenseCheck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Files
struct LicenseCheck: CheckProvider {

static let type: Language = .generic
static let dependencies: [String] = []
private static let missingFileResult = [CheckResult(severity: .error, message: "LICENSE file could not be found.", metadata: nil)]

static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] {
Expand Down
1 change: 1 addition & 0 deletions Sources/chiaLib/Internal/CheckProviders/ReadmeCheck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Files
struct ReadmeCheck: CheckProvider {

static let type: Language = .generic
static let dependencies: [String] = []
private static let missingFileResult = [CheckResult(severity: .error, message: "README.md file could not be found.", metadata: nil)]

static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] {
Expand Down
6 changes: 2 additions & 4 deletions Sources/chiaLib/Internal/CheckProviders/SwiftLintCheck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ import ShellOut

struct SwiftLintCheck: CheckProvider {
static let type: Language = .swift

static let dependencies: [String] = ["swiftlint"]
private static let configFilename = ".swiftlint.yml"
static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] {

// validate if swiftlint exists
try canFindDependency(binary: "swiftlint")
static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] {

// get config, if not already exists
var customSwiftLintConfigUrl: URL?
Expand Down

0 comments on commit b8a00b3

Please sign in to comment.