mirror of https://github.com/goproxyio/goproxy
fix(subpath) & test:
1. resolve package-path contains subdir path 2. add test 3. adjust buildpull/49/head
parent
ffdf9f23eb
commit
cc1208f526
|
@ -5,10 +5,23 @@ version: 2
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
docker:
|
docker:
|
||||||
# specify the version
|
|
||||||
- image: circleci/golang:1.11
|
- image: circleci/golang:1.11
|
||||||
working_directory: /go/src/github.com/goproxyio/goproxy/
|
working_directory: /go/src/github.com/goproxyio/goproxy/
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
# specify any bash command here prefixed with `run: `
|
- run:
|
||||||
- run: bash circle-test.sh
|
name: install deps
|
||||||
|
command: make generate
|
||||||
|
- run:
|
||||||
|
name: test self
|
||||||
|
command: make test
|
||||||
|
- run:
|
||||||
|
name: build bin
|
||||||
|
command: make build
|
||||||
|
- run:
|
||||||
|
name: run proxy backgroud to test real
|
||||||
|
command: bin/goproxy
|
||||||
|
background: true
|
||||||
|
- run:
|
||||||
|
name: run real test
|
||||||
|
command: bash test/get_test.sh
|
||||||
|
|
10
Dockerfile
10
Dockerfile
|
@ -3,17 +3,15 @@ FROM golang:alpine AS build
|
||||||
RUN apk add --no-cache -U make
|
RUN apk add --no-cache -U make
|
||||||
|
|
||||||
COPY . /src/goproxy
|
COPY . /src/goproxy
|
||||||
WORKDIR /src/goproxy
|
RUN cd /src/goproxy &&\
|
||||||
|
export CGO_ENABLED=0 &&\
|
||||||
ENV CGO_ENABLED=0
|
make
|
||||||
|
|
||||||
RUN make
|
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
RUN apk add --no-cache -U git mercurial subversion bzr fossil
|
RUN apk add --no-cache -U git mercurial subversion bzr fossil
|
||||||
|
|
||||||
COPY --from=build /src/goproxy/goproxy /goproxy
|
COPY --from=build /src/goproxy/bin/goproxy /goproxy
|
||||||
|
|
||||||
VOLUME /go
|
VOLUME /go
|
||||||
|
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -1,15 +1,21 @@
|
||||||
.PHONY: build generate image clean
|
.PHONY: build generate image clean test
|
||||||
|
|
||||||
|
export GO111MODULE=on
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
build: generate
|
build: generate
|
||||||
@go build -tags "netgo static_build" -installsuffix netgo -ldflags -w .
|
@go build -o bin/goproxy -ldflags "-s -w" .
|
||||||
|
|
||||||
generate:
|
generate:
|
||||||
@go generate
|
@go generate
|
||||||
|
@go mod tidy
|
||||||
|
|
||||||
image:
|
image:
|
||||||
@docker build -t goproxy/goproxy .
|
@docker build -t goproxy/goproxy .
|
||||||
|
|
||||||
|
test: generate
|
||||||
|
@go test -v `(go list ./... | grep "pkg/proxy")`
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@git clean -f -d -X
|
@git clean -f -d -X
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
export GO111MODULE=on
|
|
||||||
|
|
||||||
go generate
|
|
||||||
go mod tidy
|
|
||||||
go test -v `(go list ./... | grep "pkg/proxy")`
|
|
||||||
# build
|
|
||||||
go build -o bin/goproxy
|
|
|
@ -58,6 +58,11 @@ func NewProxy(cache string) http.Handler {
|
||||||
ReturnBadRequest(w, err)
|
ReturnBadRequest(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if realMod.Path != info.Version.Path {
|
||||||
|
log.Printf("goproxy: mod %s@%s may have subpath, just return to make client recurse", info.Path, info.Version.Version)
|
||||||
|
ReturnSuccess(w, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
switch suf {
|
switch suf {
|
||||||
case ".info":
|
case ".info":
|
||||||
{
|
{
|
||||||
|
|
|
@ -156,6 +156,12 @@ var _modInfoTests = []struct {
|
||||||
"x.go",
|
"x.go",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "github.com/micro/go-api/resolver",
|
||||||
|
query: "v0.5.0",
|
||||||
|
version: "v0.5.0",
|
||||||
|
gomod: "module github.com/micro/go-api\n",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var _modListTests = []struct {
|
var _modListTests = []struct {
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
export GO111MODULE=on
|
||||||
|
export GOPROXY='http://127.0.0.1:8081'
|
||||||
|
|
||||||
|
datafile='test/testdata/get.txt'
|
||||||
|
|
||||||
|
while read -r line; do
|
||||||
|
go get -v ${line}
|
||||||
|
done < "${datafile}"
|
|
@ -0,0 +1,4 @@
|
||||||
|
golang.org/x/net@latest
|
||||||
|
github.com/oiooj/agent@v0.2.2
|
||||||
|
github.com/micro/go-api/resolver@v0.5.0
|
||||||
|
cloud.google.com/go
|
Loading…
Reference in New Issue