Skip to content

Commit

Permalink
Merge pull request #140 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 7.2.0
  • Loading branch information
andyone authored May 14, 2023
2 parents 77c9bc3 + 4f03f18 commit 9f1df0f
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 65 deletions.
39 changes: 39 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "2"

checks:
argument-count:
enabled: true
config:
threshold: 6
complex-logic:
enabled: true
config:
threshold: 6
file-lines:
enabled: true
config:
threshold: 1000
method-complexity:
enabled: true
config:
threshold: 8
method-count:
enabled: true
config:
threshold: 20
method-lines:
enabled: true
config:
threshold: 100
nested-control-flow:
enabled: true
config:
threshold: 6
return-statements:
enabled: true
config:
threshold: 6
similar-code:
enabled: false
identical-code:
enabled: false
44 changes: 22 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
SRC_DIR: src/github.com/${{ github.repository }}

jobs:
Go:
name: Go
Expand All @@ -30,34 +27,28 @@ jobs:
go: [ '1.19.x', '1.20.x' ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}

- name: Checkout
uses: actions/checkout@v3
with:
path: ${{env.SRC_DIR}}

- name: Download dependencies
working-directory: ${{env.SRC_DIR}}
run: make deps

- name: Build binary
working-directory: ${{env.SRC_DIR}}
run: make all

- name: Run tests
working-directory: ${{env.SRC_DIR}}
run: go test -covermode=count ./parser ./recipe -coverprofile=cover.out

- name: Send coverage data
uses: essentialkaos/goveralls-action@v1
uses: essentialkaos/goveralls-action@v2
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: ${{env.SRC_DIR}}
profile: cover.out
parallel: true
flag-name: linux-${{ matrix.go }}
Expand All @@ -70,7 +61,7 @@ jobs:

steps:
- name: Finish parallel tests
uses: essentialkaos/goveralls-action@v1
uses: essentialkaos/goveralls-action@v2
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -83,24 +74,20 @@ jobs:
needs: Go

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.19.x'

- name: Checkout
uses: actions/checkout@v3
with:
path: ${{env.SRC_DIR}}

- name: Download dependencies
working-directory: ${{env.SRC_DIR}}
run: make deps

- name: Check Golang sources with Aligo
uses: essentialkaos/aligo-action@v1
uses: essentialkaos/aligo-action@v2
with:
path: ${{env.SRC_DIR}}
files: ./...

Shellcheck:
Expand Down Expand Up @@ -133,6 +120,19 @@ jobs:
with:
files: .docker/centos7.docker .docker/ol7.docker .docker/ol8.docker .docker/ol9.docker

Typos:
name: Typos
runs-on: ubuntu-latest

needs: Go

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Check spelling
uses: crate-ci/typos@master

DockerBuild:
name: Docker Build Check
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[files]
extend-exclude = ["go.sum"]
20 changes: 19 additions & 1 deletion COOKBOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* [`wait-output`](#wait-output)
* [`output-match`](#output-match)
* [`output-contains`](#output-contains)
* [`output-empty`](#output-empty)
* [`output-trim`](#output-trim)
* [Filesystem](#filesystem)
* [`chdir`](#chdir)
Expand Down Expand Up @@ -310,7 +311,7 @@ command "echo 'ABCD'" "Simple echo command"
```

```yang
command "USER=john ID=123 echo 'ABCD'" "Simple echo command with enviroment variables"
command "USER=john ID=123 echo 'ABCD'" "Simple echo command with environment variables"
expect "ABCD"
exit 0
```
Expand Down Expand Up @@ -602,6 +603,23 @@ command "echo 'ABCD'" "Simple echo command"

<a href="#"><img src="https://gh.kaos.st/separator.svg"/></a>

##### `output-empty`

Checks if the output is empty.

**Syntax:** `output-empty`

**Negative form:** Yes

**Example:**

```yang
command "echo 'ABCD'" "Simple echo command"
!output-empty
```

<a href="#"><img src="https://gh.kaos.st/separator.svg"/></a>

##### `output-trim`

Trims output (_remove output data from store_).
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################

# This Makefile generated by GoMakeGen 2.1.0 using next command:
# This Makefile generated by GoMakeGen 2.2.0 using next command:
# gomakegen --mod .
#
# More info: https://kaos.sh/gomakegen
Expand Down Expand Up @@ -105,6 +105,6 @@ help: ## Show this info
| sed 's/ifdef //' \
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}'
@echo -e ''
@echo -e '\033[90mGenerated by GoMakeGen 2.1.0\033[0m\n'
@echo -e '\033[90mGenerated by GoMakeGen 2.2.0\033[0m\n'

################################################################################
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<p align="center"><img src="https://gh.kaos.st/bibop.svg"/></p>

<p align="center">
<a href="https://kaos.sh/w/bibop/ci"><img src="https://kaos.sh/w/bibop/ci.svg" alt="GitHub Actions CI Status" /></a>
<a href="https://kaos.sh/r/bibop"><img src="https://kaos.sh/r/bibop.svg" alt="GoReportCard" /></a>
<a href="https://kaos.sh/l/bibop"><img src="https://kaos.sh/l/d306c6b094eae9f6ade7.svg" alt="Code Climate Maintainability" /></a>
<a href="https://kaos.sh/b/bibop"><img src="https://kaos.sh/b/a03d5074-eea9-48a7-848c-dacbe7a9bf04.svg" alt="codebeat badge" /></a>
<a href="https://kaos.sh/w/bibop/codeql"><img src="https://kaos.sh/w/bibop/codeql.svg" alt="GitHub Actions CodeQL Status" /></a>
<br/>
<a href="COOKBOOK.md"><img src="https://gh.kaos.st/cookbook.svg"></a>
<a href="https://kaos.sh/w/bibop/ci"><img src="https://kaos.sh/w/bibop/ci.svg" alt="GitHub Actions CI Status" /></a>
<a href="https://kaos.sh/w/bibop/codeql"><img src="https://kaos.sh/w/bibop/codeql.svg" alt="GitHub Actions CodeQL Status" /></a>
<a href="#license"><img src="https://gh.kaos.st/apache2.svg"></a>
</p>

Expand All @@ -25,7 +27,7 @@ Information about bibop recipe syntax you can find in our [cookbook](COOKBOOK.md

#### From source

To build the `bibop` from scratch, make sure you have a working Go 1.18+ workspace ([instructions](https://golang.org/doc/install)), then:
To build the `bibop` from scratch, make sure you have a working Go 1.18+ workspace ([instructions](https://go.dev/doc/install)), then:

```
go install github.com/essentialkaos/bibop@latest
Expand Down
12 changes: 12 additions & 0 deletions action/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ func OutputContains(action *recipe.Action, output *OutputContainer) error {
return nil
}

// OutputEmpty is action processor for "output-empty"
func OutputEmpty(action *recipe.Action, output *OutputContainer) error {
switch {
case !action.Negative && !output.IsEmpty():
return fmt.Errorf("Output contains data")
case action.Negative && output.IsEmpty():
return fmt.Errorf("Output is empty")
}

return nil
}

// OutputTrim is action processor for "output-trim"
func OutputTrim(action *recipe.Action, output *OutputContainer) error {
output.Purge()
Expand Down
16 changes: 8 additions & 8 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
// Application info
const (
APP = "bibop"
VER = "7.1.0"
VER = "7.2.0"
DESC = "Utility for testing command-line tools"
)

Expand All @@ -58,7 +58,7 @@ const (
OPT_ERROR_DIR = "e:error-dir"
OPT_TAG = "t:tag"
OPT_QUIET = "q:quiet"
OPT_INGORE_PACKAGES = "ip:ignore-packages"
OPT_IGNORE_PACKAGES = "ip:ignore-packages"
OPT_NO_CLEANUP = "nl:no-cleanup"
OPT_NO_COLOR = "nc:no-color"
OPT_HELP = "h:help"
Expand All @@ -83,11 +83,11 @@ var optMap = options.Map{
OPT_ERROR_DIR: {},
OPT_TAG: {Mergeble: true},
OPT_QUIET: {Type: options.BOOL},
OPT_INGORE_PACKAGES: {Type: options.BOOL},
OPT_IGNORE_PACKAGES: {Type: options.BOOL},
OPT_NO_CLEANUP: {Type: options.BOOL},
OPT_NO_COLOR: {Type: options.BOOL},
OPT_HELP: {Type: options.BOOL},
OPT_VER: {Type: options.BOOL},
OPT_VER: {Type: options.MIXED},

OPT_VERB_VER: {Type: options.BOOL},
OPT_COMPLETION: {},
Expand Down Expand Up @@ -119,7 +119,7 @@ func Run(gitRev string, gomod []byte) {
printMan()
os.Exit(0)
case options.GetB(OPT_VER):
genAbout(gitRev).Print()
genAbout(gitRev).Print(options.GetS(OPT_VER))
os.Exit(0)
case options.GetB(OPT_VERB_VER):
support.Print(APP, VER, gitRev, gomod)
Expand Down Expand Up @@ -352,7 +352,7 @@ func getValidationConfig(tags []string) *executor.ValidationConfig {
vc.IgnorePrivileges = true
}

if options.GetB(OPT_INGORE_PACKAGES) {
if options.GetB(OPT_IGNORE_PACKAGES) {
vc.IgnoreDependencies = true
}

Expand Down Expand Up @@ -403,7 +403,7 @@ func printWarn(f string, a ...interface{}) {
}
}

// printErrorAndExit print error mesage and exit with exit code 1
// printErrorAndExit print error message and exit with exit code 1
func printErrorAndExit(f string, a ...interface{}) {
printError(f, a...)
os.Exit(1)
Expand Down Expand Up @@ -456,7 +456,7 @@ func genUsage() *usage.Info {
info.AddOption(OPT_ERROR_DIR, "Path to directory for errors data", "dir")
info.AddOption(OPT_TAG, "One or more command tags to run", "tag")
info.AddOption(OPT_QUIET, "Quiet mode")
info.AddOption(OPT_INGORE_PACKAGES, "Do not check system for installed packages")
info.AddOption(OPT_IGNORE_PACKAGES, "Do not check system for installed packages")
info.AddOption(OPT_NO_CLEANUP, "Disable deleting files created during tests")
info.AddOption(OPT_NO_COLOR, "Disable colors in output")
info.AddOption(OPT_HELP, "Show this help message")
Expand Down
Loading

0 comments on commit 9f1df0f

Please sign in to comment.