Skip to content

Commit

Permalink
Merge pull request #7 from k1LoW/use-github-actions
Browse files Browse the repository at this point in the history
Use GitHub Actions
  • Loading branch information
k1LoW authored Nov 2, 2019
2 parents ba8477f + cb690e9 commit 7f27f29
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 26 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: build

on: push

jobs:
job-test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
go_version: [1.12, 1.13]
steps:
- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go_version }}

- name: Install codecov
run: sudo pip install codecov

- name: Check out source code
uses: actions/checkout@v1

- name: Test
run: env PATH=`go env GOPATH`/bin:$PATH make ci
env:
SHELL: /bin/bash
GOPROXY: "https://proxy.golang.org"

- name: Run codecov
run: codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# evry [![Build Status](https://travis-ci.org/k1LoW/evry.svg?branch=master)](https://travis-ci.org/k1LoW/evry) [![GitHub release](https://img.shields.io/github/release/k1LoW/evry.svg)](https://github.com/k1LoW/evry/releases)
# evry [![Build Status](https://github.com/k1LoW/evry/workflows/build/badge.svg)](https://github.com/k1LoW/evry/actions) [![GitHub release](https://img.shields.io/github/release/k1LoW/evry.svg)](https://github.com/k1LoW/evry/releases)

`evry` split STDIN stream and execute specified command **every** N lines/seconds.

Expand Down
34 changes: 26 additions & 8 deletions evry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ var tests = []struct {

func TestCat(t *testing.T) {
for _, tt := range tests {
want := execCmd(tt.cmd)
got := execCmd(fmt.Sprintf("%s | %s", tt.cmd, tt.evryCmd))
want, err := execCmd(tt.cmd)
if err != nil {
t.Fatal(err)
}
got, err := execCmd(fmt.Sprintf("%s | %s", tt.cmd, tt.evryCmd))
if err != nil {
t.Fatal(err)
}
if got != want {
t.Errorf("\nwant %q\ngot %q", want, got)
}
Expand All @@ -40,7 +46,10 @@ func TestCat(t *testing.T) {
func TestMutex(t *testing.T) {
cmd := `echo -e "2\n0\n1" | ./evry -l 1 -c 'xargs -I@ sh -c "sleep @; echo sleep @"'`
want := "sleep 2\nsleep 0\nsleep 1\n"
got := execCmd(cmd)
got, err := execCmd(cmd)
if err != nil {
t.Fatal(err)
}
if got != want {
t.Errorf("\nwant %q\ngot %q", want, got)
}
Expand All @@ -49,7 +58,10 @@ func TestMutex(t *testing.T) {
func TestPipe(t *testing.T) {
cmd := `echo -e "b\nc\na\ne\nd" | ./evry -l 10 -c 'cat | sort | head -3'`
want := "a\nb\nc\n"
got := execCmd(cmd)
got, err := execCmd(cmd)
if err != nil {
t.Fatal(err)
}
if got != want {
t.Errorf("\nwant %q\ngot %q", want, got)
}
Expand All @@ -58,13 +70,19 @@ func TestPipe(t *testing.T) {
func TestPipeWithArgs(t *testing.T) {
cmd := `echo -e "b\nc\na\ne\nd" | ./evry -l 10 -- sh -c 'cat | sort | head -3'`
want := "a\nb\nc\n"
got := execCmd(cmd)
got, err := execCmd(cmd)
if err != nil {
t.Fatal(err)
}
if got != want {
t.Errorf("\nwant %q\ngot %q", want, got)
}
}

func execCmd(cmd string) string {
b, _ := exec.Command(os.Getenv("SHELL"), "-c", cmd).Output()
return string(b)
func execCmd(cmd string) (string, error) {
b, err := exec.Command(os.Getenv("SHELL"), "-c", cmd).CombinedOutput()
if err != nil {
return "", err
}
return string(b), nil
}

0 comments on commit 7f27f29

Please sign in to comment.