Skip to content

Commit

Permalink
Merge branch 'master' into feature/mysql-client
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnavarro authored Mar 20, 2019
2 parents 67c57d5 + 0a56208 commit 4c568c6
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 8 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ jobs:
services: [docker]

before_deploy:
- make packages
- echo "${TRAVIS_TAG}" > version.txt
- make static-package
- make docker-push-latest-release

deploy:
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ FROM golang:1.11-alpine as builder
ENV GITBASE_REPO=github.com/src-d/gitbase
ENV GITBASE_PATH=$GOPATH/src/$GITBASE_REPO

RUN apk add --no-cache git
RUN apk add --update --no-cache libxml2-dev git make bash gcc g++ curl oniguruma-dev oniguruma

COPY . $GITBASE_PATH
WORKDIR $GITBASE_PATH
RUN go build -ldflags="-X main.version=$(cat version.txt || echo "undefined") -X main.build=$(date +"%m-%d-%Y_%H_%M_%S") -X main.commit=$(git rev-parse --short HEAD) -s -w" -o /bin/gitbase ./cmd/gitbase

ENV GO_BUILD_ARGS="-o /bin/gitbase"
ENV GO_BUILD_PATH="./cmd/gitbase"
RUN make static-build

#=================================
# Stage 2: Start Gitbase Server
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pipeline {
nodeSelector 'srcd.host/type=jenkins-worker'
containerTemplate {
name 'regression-gitbase'
image 'srcd/regression-gitbase:v0.2.0'
image 'srcd/regression-gitbase:v0.2.1'
ttyEnabled true
command 'cat'
}
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ static-package:
docker rm gitbase-temp

# target used in the Dockerfile to build the static binary
static-build: VERSION = $(shell git describe --exact-match --tags 2>/dev/null || dev-$(git rev-parse --short HEAD)$(test -n "`git status --porcelain`" && echo "-dirty" || true))
static-build: LD_FLAGS += -linkmode external -extldflags '-static -lz'
static-build: VERSION ?= $(shell git describe --exact-match --tags 2>/dev/null || "dev-$(git rev-parse --short HEAD)$(test -n "`git status --porcelain`" && echo "-dirty" || true)")
static-build: LD_FLAGS += -linkmode external -extldflags '-static -lz' -s -w
static-build: GO_BUILD_ARGS += -tags oniguruma
static-build: GO_BUILD_PATH ?= github.com/src-d/gitbase/...
static-build:
go install -v $(GO_BUILD_ARGS) github.com/src-d/gitbase/...
go build -ldflags="$(LD_FLAGS)" -v $(GO_BUILD_ARGS) $(GO_BUILD_PATH)

ci-e2e: packages
go test ./e2e -gitbase-version="$(TRAVIS_TAG)" \
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions cmd/gitbase/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ func (c *Server) addMatch(match string) error {
initDepth := strings.Count(root, string(os.PathSeparator))
return filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
if os.IsPermission(err) {
return filepath.SkipDir
}
return err
}

Expand Down
11 changes: 11 additions & 0 deletions cmd/gitbase/command/server_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package command

import (
"os"
"testing"

"github.com/src-d/gitbase"
Expand All @@ -10,12 +11,22 @@ import (
func TestAddMatch(t *testing.T) {
require := require.New(t)

notPermissionDir := "../../../_testdata/not-permission/"
fi, err := os.Stat(notPermissionDir)
require.NoError(err)

require.NoError(os.Chmod(notPermissionDir, 0))
defer func() {
require.NoError(os.Chmod(notPermissionDir, fi.Mode()))
}()

expected := []struct {
path string
err func(error, ...interface{})
}{
{"../../../_testdata/repositories/", require.NoError},
{"../../../_testdata/repositories-link/", require.NoError},
{notPermissionDir, require.NoError},
{"../../../_testdata/repositories-not-exist/", require.Error},
}
c := &Server{pool: gitbase.NewRepositoryPool(0)}
Expand Down

0 comments on commit 4c568c6

Please sign in to comment.