Skip to content

Commit

Permalink
Fixing broken CircleCI build
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
  • Loading branch information
hairyhenderson committed Oct 14, 2019
1 parent 49ea6c3 commit bc55871
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 12 deletions.
10 changes: 4 additions & 6 deletions .circleci/config.yml
Expand Up @@ -10,8 +10,8 @@ jobs:
test-vendoring:
executor: build-executor
environment:
- GO111MODULE=on
- GOFLAGS=-mod=vendor
GO111MODULE: 'on'
GOFLAGS: -mod=vendor
steps:
- checkout
- run: go mod tidy
Expand Down Expand Up @@ -76,15 +76,13 @@ jobs:
steps:
- checkout
- setup_remote_docker:
version: 18.06.0-ce
docker_layer_caching: true
version: 18.09.3
- run: make artifacts.tag latest.tag alpine.tag slim.tag

workflows:
version: 2.1
build-and-test:
jobs:
- test-vendoring
# - test-vendoring
- build
- test:
requires:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -121,7 +121,7 @@ gen-changelog:
github_changelog_generator --no-filter-by-milestone --exclude-labels duplicate,question,invalid,wontfix,admin

lint:
golangci-lint run -j $(LINT_PROCS)
golangci-lint run --disable wsl

.PHONY: gen-changelog clean test build-x compress-all build-release build test-integration-docker gen-docs lint clean-images clean-containers docker-images
.DELETE_ON_ERROR:
Expand Down
7 changes: 7 additions & 0 deletions cmd/which/main.go
Expand Up @@ -37,24 +37,31 @@ func main() {

if all {
found := which.All(programs...)

if len(found) == 0 {
os.Exit(1)
}

fmt.Println(strings.Join(found, "\n"))

return
}

if silent {
found := which.Found(programs...)

if found {
return
}

os.Exit(1)
}

found := which.Which(programs...)

if found == "" {
os.Exit(1)
}

fmt.Println(found)
}
2 changes: 2 additions & 0 deletions internal/tests/integration/basic_test.go
@@ -1,3 +1,5 @@
// +build integration

package integration

import (
Expand Down
2 changes: 2 additions & 0 deletions internal/tests/integration/integration_test.go
@@ -1,3 +1,5 @@
// +build integration

package integration

import (
Expand Down
19 changes: 14 additions & 5 deletions which.go
Expand Up @@ -32,6 +32,7 @@ func which(fs afero.Fs, program ...string) string {
}
}
}

return ""
}

Expand All @@ -43,6 +44,7 @@ func All(program ...string) []string {

func all(fs afero.Fs, program ...string) []string {
out := []string{}

for _, prog := range program {
for _, p := range getPath() {
candidate := filepath.Join(p, prog)
Expand All @@ -51,6 +53,7 @@ func all(fs afero.Fs, program ...string) []string {
}
}
}

return out
}

Expand All @@ -64,16 +67,19 @@ func found(fs afero.Fs, program ...string) bool {
count := 0
for _, prog := range program {
count = 0

for _, p := range getPath() {
candidate := filepath.Join(p, prog)
if isExec(fs, candidate) {
count++
}
}

if count == 0 {
return false
}
}

return count > 0
}

Expand All @@ -87,29 +93,32 @@ func getPath() []string {
}
}
}

return strings.Split(pathVar, string(os.PathListSeparator))
}

func keys(env []string) []string {
out := make([]string, len(env))

for i, v := range env {
parts := strings.SplitN(v, "=", 2)
out[i] = parts[0]
}

return out
}

// isExec returns true when the file at the given path is a regular file with
// the execute bit set (if on UNIX)
func isExec(fs afero.Fs, path string) bool {
fi, err := fs.Stat(path)
if os.IsNotExist(err) {

switch {
case os.IsNotExist(err):
return false
}
if fi.IsDir() {
case fi.IsDir():
return false
}
if fi.Mode()&0111 != 0 {
case fi.Mode()&0111 != 0:
return true
}
// Windows filesystems have no execute bit...
Expand Down
1 change: 1 addition & 0 deletions which_test.go
Expand Up @@ -106,6 +106,7 @@ func init() {
if err != nil {
panic(err)
}

_, err = f.WriteString("#!/bin/sh\necho hello world\n")
if err != nil {
panic(err)
Expand Down

0 comments on commit bc55871

Please sign in to comment.