Skip to content

Commit

Permalink
Add github actions
Browse files Browse the repository at this point in the history
Add github actions workflow descriptor
Remove mage dependency
Add Makefile
  • Loading branch information
pavlo-v-chernykh committed Jun 13, 2020
1 parent 9c8ef67 commit c3fb2ea
Show file tree
Hide file tree
Showing 13 changed files with 254 additions and 63 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: GitHub Actions Workflow
on: [push]
jobs:
fmt:
name: Fmt
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.14.4'
- name: Fmt
run: go fmt github.com/pavel-v-chernykh/keystore-go/...
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Lint
uses: golangci/golangci-lint-action@v1.2.1
with:
args: --timeout=5m0s -c .golangci.yaml
version: v1.27
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.14.4'
- name: Test
run: go test -cover -count=1 -v github.com/pavel-v-chernykh/keystore-go/...
28 changes: 28 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
modules-download-mode: readonly

linters:
enable-all: true
disable:
- gochecknoglobals
- funlen
- goerr113

linters-settings:
gomnd:
settings:
mnd:
checks: case,condition,return

issues:
exclude-rules:
- path: _test\.go
linters:
- testpackage
- maligned
- dupl
- linters:
- gosec
text: "G401: "
- linters:
- gosec
text: "G505: "
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fmt:
go fmt github.com/pavel-v-chernykh/keystore-go/...

lint:
golangci-lint run -c .golangci.yaml

test:
go test -cover -count=1 -v ./...

all: fmt lint test

.PHONY: fmt lint test all
.DEFAULT_GOAL := all
1 change: 1 addition & 0 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func passwordBytes(password []byte) []byte {
for _, b := range password {
result = append(result, 0, b)
}

return result
}

Expand Down
19 changes: 15 additions & 4 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@ import (
)

func TestZeroing(t *testing.T) {
type zeroingItem struct {
input []byte
}
type zeroingTable []zeroingItem
type (
zeroingItem struct {
input []byte
}
zeroingTable []zeroingItem
)

var table zeroingTable

for i := 0; i < 20; i++ {
buf := make([]byte, 4096)
if _, err := rand.Read(buf); err != nil {
t.Errorf("read random bytes: %v", err)
}

table = append(table, zeroingItem{input: buf})
}

for _, tt := range table {
zeroing(tt.input)

for i := range tt.input {
if tt.input[i] != 0 {
t.Errorf("fill input with zeros '%v'", tt.input)
Expand All @@ -36,19 +41,25 @@ func TestPasswordBytes(t *testing.T) {
input []byte
output []byte
}

var table []passwordBytesItem

for i := 0; i < 20; i++ {
input := make([]byte, 1024)
if _, err := rand.Read(input); err != nil {
t.Errorf("read random bytes: %v", err)
}

output := make([]byte, len(input)*2)

for j, k := 0, 0; j < len(output); j, k = j+2, k+1 {
output[j] = 0
output[j+1] = input[k]
}

table = append(table, passwordBytesItem{input: input, output: output})
}

for _, tt := range table {
output := passwordBytes(tt.input)
if !reflect.DeepEqual(output, tt.output) {
Expand Down
Loading

0 comments on commit c3fb2ea

Please sign in to comment.