Skip to content

Commit

Permalink
Merge pull request #79 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 4.8.0
  • Loading branch information
andyone authored Sep 27, 2021
2 parents ca080ff + 5e17bb9 commit e4513af
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 27 deletions.
40 changes: 39 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: '10.x'
node-version: '14.x'

- name: Install codeclimate-test-reporter
run: npm install -g codeclimate-test-reporter
Expand All @@ -77,6 +77,44 @@ jobs:
CODECLIMATE_REPO_TOKEN: ${{ secrets.CODECLIMATE_TOKEN }}
run: codeclimate-test-reporter < cover.out

Aligo:
name: Aligo
runs-on: ubuntu-latest

needs: Go

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

steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.16.x'
id: go

- name: Setup PATH
run: |
echo "GOPATH=${{ github.workspace }}" >> "$GITHUB_ENV"
echo "GOBIN=${{ github.workspace }}/bin" >> "$GITHUB_ENV"
echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH"
- name: Checkout
uses: actions/checkout@v2
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
with:
path: ${{env.SRC_DIR}}
files: ./...

Shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Official Docker images with bibop:

### Recipe syntax highlighting

* [Sublime Text 3](https://kaos.sh/blackhole-theme-sublime/bibop-recipe.sublime-syntax)
* [Sublime Text 3/4](https://kaos.sh/blackhole-theme-sublime/bibop-recipe.sublime-syntax)
* [nano](https://kaos.sh/blackhole-theme-nano/bibop.nanorc)

### Command-line completion
Expand Down
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
// Application info
const (
APP = "bibop"
VER = "4.7.0"
VER = "4.8.0"
DESC = "Utility for testing command-line tools"
)

Expand Down
2 changes: 1 addition & 1 deletion cli/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ type Executor struct {

// ExecutorConfig contains executor configuration
type Config struct {
ErrsDir string
Quiet bool
DisableCleanup bool
ErrsDir string
}

// ValidationConfig is config for validation
Expand Down
19 changes: 10 additions & 9 deletions recipe/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,44 +27,45 @@ const TEARDOWN_TAG = "teardown"
// ////////////////////////////////////////////////////////////////////////////////// //

// Recipe contains recipe data
// aligo:ignore
type Recipe struct {
Packages []string // Package list
Commands []*Command // Commands
File string // Path to recipe
Dir string // Working dir
Delay float64 // Delay between commands
UnsafeActions bool // Allow unsafe actions
RequireRoot bool // Require root privileges
FastFinish bool // Fast finish flag
LockWorkdir bool // Locking workdir flag
Unbuffer bool // Disabled IO buffering
HTTPSSkipVerify bool // Disable certificate verification
Delay float64 // Delay between commands
Packages []string // Package list
Commands []*Command // Commands

variables map[string]*Variable // Variables
}

// Command contains command with all actions
// aligo:ignore
type Command struct {
Actions []*Action // Slice with actions
User string // User name
Tag string // Tag
Cmdline string // Command line
Description string // Description
Actions []*Action // Slice with actions
Recipe *Recipe // Link to recipe
Line uint16 // Line in recipe

props map[string]interface{} // Properties

Recipe *Recipe // Link to recipe
}

// Action contains action name and slice with arguments
type Action struct {
Name string // Name
Arguments []string // Arguments
Negative bool // Is negative
Name string // Name
Command *Command // Link to command
Line uint16 // Line in recipe
Negative bool // Negative check flag

Command *Command // Link to command
}

type Variable struct {
Expand Down
24 changes: 20 additions & 4 deletions recipe/recipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,22 @@ func (s *RecipeSuite) TestBasicRecipe(c *C) {
c.Assert(c2.Tag, Equals, "special")
c.Assert(c2.Description, Equals, "Echo command for service nginx")

a1 := &Action{"copy", []string{"file1", "file2"}, true, 0, nil}
a2 := &Action{"touch", []string{"{service}"}, false, 0, nil}
a3 := &Action{"print", []string{"1.53", "4000", "ABCD"}, false, 0, nil}
a1 := &Action{Name: "copy",
Arguments: []string{"file1", "file2"},
Negative: true, Line: 0, Command: nil,
}

a2 := &Action{
Name: "touch",
Arguments: []string{"{service}"},
Negative: false, Line: 0, Command: nil,
}

a3 := &Action{
Name: "print",
Arguments: []string{"1.53", "4000", "ABCD"},
Negative: false, Line: 0, Command: nil,
}

c1.AddAction(a1)
c2.AddAction(a2)
Expand Down Expand Up @@ -207,7 +220,10 @@ func (s *RecipeSuite) TestIndex(c *C) {

c.Assert(c1.Index(), Equals, 0)

a1 := &Action{"abcd", []string{}, true, 0, nil}
a1 := &Action{
Name: "abcd", Arguments: []string{},
Negative: true, Line: 0, Command: nil,
}

c.Assert(a1.Index(), Equals, -1)

Expand Down
8 changes: 4 additions & 4 deletions render/renderer_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ type recipeInfo struct {
}

type command struct {
Actions []*action `json:"actions"`
User string `json:"user,omitempty"`
Tag string `json:"tag,omitempty"`
Cmdline string `json:"cmdline"`
Description string `json:"description"`
IsFailed bool `json:"is_failed"`
ErrorMessage string `json:"error_message,omitempty"`
Actions []*action `json:"actions"`
IsFailed bool `json:"is_failed"`
}

type action struct {
Name string `json:"name"`
Arguments []string `json:"arguments"`
IsFailed bool `json:"is_failed"`
Name string `json:"name"`
ErrorMessage string `json:"error_message,omitempty"`
IsFailed bool `json:"is_failed"`
}

// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
60 changes: 54 additions & 6 deletions render/renderer_terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,20 @@ import (

// ////////////////////////////////////////////////////////////////////////////////// //

const (
_ANIMATION_STARTED uint8 = 1
_ANIMATION_STOP uint8 = 2
)

// ////////////////////////////////////////////////////////////////////////////////// //

// TerminalRenderer renders info to terminal
type TerminalRenderer struct {
start time.Time
curAction *recipe.Action
syncChan chan uint8
isStarted bool
isFinished bool
start time.Time
}

// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down Expand Up @@ -101,15 +110,19 @@ func (rr *TerminalRenderer) ActionStarted(a *recipe.Action) {
return
}

rr.renderTmpMessage(
" {s-}└─{!} {s~-}● {!}"+rr.formatActionName(a)+" {s}%s{!} {s-}[%s]{!}",
rr.formatActionArgs(a),
rr.formatDuration(time.Since(rr.start), false),
)
rr.curAction = a
rr.syncChan = make(chan uint8)

go rr.renderCurrentActionProgress()

// Wait until animation started
<-rr.syncChan
}

// ActionFailed prints info about failed action
func (rr *TerminalRenderer) ActionFailed(a *recipe.Action, err error) {
rr.syncChan <- _ANIMATION_STOP

rr.renderTmpMessage(
" {s-}└─{!} {r}✖ {!}"+rr.formatActionName(a)+" {s}%s{!}",
rr.formatActionArgs(a),
Expand All @@ -124,6 +137,8 @@ func (rr *TerminalRenderer) ActionFailed(a *recipe.Action, err error) {

// ActionDone prints info about successfully finished action
func (rr *TerminalRenderer) ActionDone(a *recipe.Action, isLast bool) {
rr.syncChan <- _ANIMATION_STOP

if isLast {
rr.renderTmpMessage(
" {s-}└─{!} {g}✔ {!}"+rr.formatActionName(a)+" {s}%s{!}",
Expand Down Expand Up @@ -252,6 +267,39 @@ func (rr *TerminalRenderer) renderTmpMessage(f string, a ...interface{}) {
fmtc.Printf("{s}…{!}")
}

// renderCurrentActionProgress renders info about current action
func (rr *TerminalRenderer) renderCurrentActionProgress() {
frame := 0

ticker := time.NewTicker(time.Second / 4)
defer ticker.Stop()

rr.syncChan <- _ANIMATION_STARTED

for {
select {
case <-rr.syncChan:
return
case <-ticker.C:
dot := " "
frame++

switch frame {
case 2:
dot = "{s-}●{!}"
case 3:
dot, frame = "{s}●{!}", 0
}

rr.renderTmpMessage(
" {s-}└─{!} "+dot+" {!}"+rr.formatActionName(rr.curAction)+" {s}%s{!} {s-}[%s]{!}",
rr.formatActionArgs(rr.curAction),
rr.formatDuration(time.Since(rr.start), false),
)
}
}
}

// renderMessage prints message limited by window size
func (rr *TerminalRenderer) renderMessage(f string, a ...interface{}) {
ww := window.GetWidth()
Expand Down

0 comments on commit e4513af

Please sign in to comment.