mirror of
https://github.com/wagoodman/dive
synced 2024-06-11 16:42:11 +02:00
adding goreleaser
This commit is contained in:
parent
dddb2e6b97
commit
9802546b60
26
.goreleaser.yml
Normal file
26
.goreleaser.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
release:
|
||||
prerelease: true
|
||||
|
||||
builds:
|
||||
- binary: dive
|
||||
goos:
|
||||
- darwin
|
||||
- linux
|
||||
goarch:
|
||||
- amd64
|
||||
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.buildTime={{.Date}}`.
|
||||
|
||||
archive:
|
||||
format: tar.gz
|
||||
|
||||
fpm:
|
||||
license: MIT
|
||||
homepage: https://github.com/wagoodman/dive/
|
||||
formats:
|
||||
- deb
|
||||
- rpm
|
||||
|
||||
brew:
|
||||
github:
|
||||
owner: wagoodman
|
||||
name: homebrew-dive
|
37
.scripts/tag.sh
Executable file
37
.scripts/tag.sh
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
set -u
|
||||
|
||||
BOLD=$(tput bold)
|
||||
NORMAL=$(tput sgr0)
|
||||
|
||||
echo "${BOLD}Tagging${NORMAL}"
|
||||
|
||||
#get highest tag number
|
||||
VERSION=`git describe --abbrev=0 --tags`
|
||||
|
||||
#replace . with space so can split into an array
|
||||
VERSION_BITS=(${VERSION//./ })
|
||||
|
||||
#get number parts and increase last one by 1
|
||||
VNUM1=${VERSION_BITS[0]}
|
||||
VNUM2=${VERSION_BITS[1]}
|
||||
VNUM3=${VERSION_BITS[2]}
|
||||
VNUM3=$((VNUM3+1))
|
||||
|
||||
#create new tag
|
||||
NEW_TAG="$VNUM1.$VNUM2.$VNUM3"
|
||||
|
||||
echo "Updating $VERSION to $NEW_TAG"
|
||||
|
||||
#get current hash and see if it already has a tag
|
||||
GIT_COMMIT=`git rev-parse HEAD`
|
||||
NEEDS_TAG=`git describe --contains $GIT_COMMIT`
|
||||
|
||||
#only tag if no tag already (would be better if the git describe command above could have a silent option)
|
||||
if [ -z "$NEEDS_TAG" ]; then
|
||||
echo "Tagged with $NEW_TAG (Ignoring fatal:cannot describe - this means commit is untagged) "
|
||||
git tag $NEW_TAG
|
||||
git push --tags
|
||||
else
|
||||
echo "Already a tag on this commit"
|
||||
fi
|
6
Makefile
6
Makefile
|
@ -9,6 +9,10 @@ run: build
|
|||
build:
|
||||
go build -o build/$(BIN)
|
||||
|
||||
release: test
|
||||
./.scripts/tag.sh
|
||||
goreleaser --rm-dist
|
||||
|
||||
install:
|
||||
go install ./...
|
||||
|
||||
|
@ -23,4 +27,4 @@ clean:
|
|||
rm -rf vendor
|
||||
go clean
|
||||
|
||||
.PHONY: build install test lint clean
|
||||
.PHONY: build install test lint clean release
|
||||
|
|
|
@ -6,6 +6,7 @@ A tool for interrogating docker images.
|
|||
|
||||
|
||||
|
||||
|
||||
## Installing
|
||||
```
|
||||
docker build -t die-test:latest .
|
||||
|
|
50
filetree/efficiency_test.go
Normal file
50
filetree/efficiency_test.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package filetree
|
||||
|
||||
// TODO: rewrite this to be weighted by file size
|
||||
|
||||
// func TestEfficencyMap(t *testing.T) {
|
||||
// trees := make([]*FileTree, 3)
|
||||
// for ix, _ := range trees {
|
||||
// tree := NewFileTree()
|
||||
// tree.AddPath("/etc/nginx/nginx.conf", FileInfo{})
|
||||
// tree.AddPath("/etc/nginx/public", FileInfo{})
|
||||
// trees[ix] = tree
|
||||
// }
|
||||
// var expectedMap = map[string]int{
|
||||
// "/etc/nginx/nginx.conf": 3,
|
||||
// "/etc/nginx/public": 3,
|
||||
// }
|
||||
// actualMap := EfficiencyMap(trees)
|
||||
// if !reflect.DeepEqual(expectedMap, actualMap) {
|
||||
// t.Fatalf("Expected %v but go %v", expectedMap, actualMap)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func TestEfficiencyScore(t *testing.T) {
|
||||
// trees := make([]*FileTree, 3)
|
||||
// for ix, _ := range trees {
|
||||
// tree := NewFileTree()
|
||||
// tree.AddPath("/etc/nginx/nginx.conf", FileInfo{})
|
||||
// tree.AddPath("/etc/nginx/public", FileInfo{})
|
||||
// trees[ix] = tree
|
||||
// }
|
||||
// expected := 2.0 / 6.0
|
||||
// actual := CalculateEfficiency(trees)
|
||||
// if math.Abs(expected-actual) > 0.0001 {
|
||||
// t.Fatalf("Expected %f but got %f", expected, actual)
|
||||
// }
|
||||
//
|
||||
// trees = make([]*FileTree, 1)
|
||||
// for ix, _ := range trees {
|
||||
// tree := NewFileTree()
|
||||
// tree.AddPath("/etc/nginx/nginx.conf", FileInfo{})
|
||||
// tree.AddPath("/etc/nginx/public", FileInfo{})
|
||||
// trees[ix] = tree
|
||||
// }
|
||||
// expected = 1.0
|
||||
// actual = CalculateEfficiency(trees)
|
||||
// if math.Abs(expected-actual) > 0.0001 {
|
||||
// t.Fatalf("Expected %f but got %f", expected, actual)
|
||||
// }
|
||||
// }
|
||||
|
|
@ -2,8 +2,6 @@ package filetree
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -526,49 +524,3 @@ func TestRemoveOnIterate(t *testing.T) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
func TestEfficencyMap(t *testing.T) {
|
||||
trees := make([]*FileTree, 3)
|
||||
for ix, _ := range trees {
|
||||
tree := NewFileTree()
|
||||
tree.AddPath("/etc/nginx/nginx.conf", FileInfo{})
|
||||
tree.AddPath("/etc/nginx/public", FileInfo{})
|
||||
trees[ix] = tree
|
||||
}
|
||||
var expectedMap = map[string]int{
|
||||
"/etc/nginx/nginx.conf": 3,
|
||||
"/etc/nginx/public": 3,
|
||||
}
|
||||
actualMap := EfficiencyMap(trees)
|
||||
if !reflect.DeepEqual(expectedMap, actualMap) {
|
||||
t.Fatalf("Expected %v but go %v", expectedMap, actualMap)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEfficiencyScore(t *testing.T) {
|
||||
trees := make([]*FileTree, 3)
|
||||
for ix, _ := range trees {
|
||||
tree := NewFileTree()
|
||||
tree.AddPath("/etc/nginx/nginx.conf", FileInfo{})
|
||||
tree.AddPath("/etc/nginx/public", FileInfo{})
|
||||
trees[ix] = tree
|
||||
}
|
||||
expected := 2.0 / 6.0
|
||||
actual := CalculateEfficiency(trees)
|
||||
if math.Abs(expected-actual) > 0.0001 {
|
||||
t.Fatalf("Expected %f but got %f", expected, actual)
|
||||
}
|
||||
|
||||
trees = make([]*FileTree, 1)
|
||||
for ix, _ := range trees {
|
||||
tree := NewFileTree()
|
||||
tree.AddPath("/etc/nginx/nginx.conf", FileInfo{})
|
||||
tree.AddPath("/etc/nginx/public", FileInfo{})
|
||||
trees[ix] = tree
|
||||
}
|
||||
expected = 1.0
|
||||
actual = CalculateEfficiency(trees)
|
||||
if math.Abs(expected-actual) > 0.0001 {
|
||||
t.Fatalf("Expected %f but got %f", expected, actual)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue