mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-04-26 13:34:45 +00:00
Merge branch 'master' into azure-storage
This commit is contained in:
commit
18ed28867f
7 changed files with 37 additions and 16 deletions
|
@ -5,10 +5,13 @@ env:
|
||||||
- GOROOT=/usr/local/go
|
- GOROOT=/usr/local/go
|
||||||
- PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
- PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
||||||
script:
|
script:
|
||||||
|
- sudo add-apt-repository ppa:git-core/ppa 1> /dev/null 2> /dev/null
|
||||||
- sudo apt-get update 1> /dev/null 2> /dev/null
|
- sudo apt-get update 1> /dev/null 2> /dev/null
|
||||||
- sudo apt-get -y install zip libsqlite3-dev sqlite3 rpm 1> /dev/null 2> /dev/null
|
- sudo apt-get update 1> /dev/null 2> /dev/null
|
||||||
|
- sudo apt-get -y install git zip libsqlite3-dev sqlite3 rpm 1> /dev/null 2> /dev/null
|
||||||
- gem install fpm
|
- gem install fpm
|
||||||
- rbenv rehash
|
- rbenv rehash
|
||||||
|
- make docker
|
||||||
- make deps
|
- make deps
|
||||||
- make test
|
- make test
|
||||||
- make test_postgres
|
- make test_postgres
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -5,10 +5,13 @@ ITTERATION := $(shell date +%s)
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
# which npm && npm -g install uglify-js less autoprefixer
|
|
||||||
go get github.com/GeertJohan/go.rice/rice
|
go get github.com/GeertJohan/go.rice/rice
|
||||||
go get -t -v ./...
|
go get -t -v ./...
|
||||||
|
|
||||||
|
docker:
|
||||||
|
mkdir -p $$GOPATH/src/github.com/docker/docker
|
||||||
|
git clone --depth=1 --branch=v1.5.0 git://github.com/docker/docker.git $$GOPATH/src/github.com/docker/docker
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@test -z "$(shell find . -name '*.go' | xargs gofmt -l)" || (echo "Need to run 'go fmt ./...'"; exit 1)
|
@test -z "$(shell find . -name '*.go' | xargs gofmt -l)" || (echo "Need to run 'go fmt ./...'"; exit 1)
|
||||||
go vet ./...
|
go vet ./...
|
||||||
|
|
|
@ -24,7 +24,7 @@ const (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DescPending = "this build is pending"
|
DescPending = "this build is pending"
|
||||||
DescSuccess = "the build was succcessful"
|
DescSuccess = "the build was successful"
|
||||||
DescFailure = "the build failed"
|
DescFailure = "the build failed"
|
||||||
DescError = "oops, something went wrong"
|
DescError = "oops, something went wrong"
|
||||||
)
|
)
|
||||||
|
|
|
@ -33,6 +33,7 @@ type Docker struct {
|
||||||
KeepBuild bool `yaml:"keep_build"`
|
KeepBuild bool `yaml:"keep_build"`
|
||||||
Tag string `yaml:"tag"`
|
Tag string `yaml:"tag"`
|
||||||
Tags []string `yaml:"tags"`
|
Tags []string `yaml:"tags"`
|
||||||
|
ForceTags bool `yaml:"force_tags"`
|
||||||
|
|
||||||
Condition *condition.Condition `yaml:"when,omitempty"`
|
Condition *condition.Condition `yaml:"when,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -100,7 +101,11 @@ func (d *Docker) Write(f *buildfile.Buildfile) {
|
||||||
// Tag and push all tags
|
// Tag and push all tags
|
||||||
for _, tag := range d.Tags {
|
for _, tag := range d.Tags {
|
||||||
if tag != buildImageTag {
|
if tag != buildImageTag {
|
||||||
f.WriteCmd(fmt.Sprintf("docker tag %s:%s %s:%s", d.ImageName, buildImageTag, d.ImageName, tag))
|
var options string
|
||||||
|
if d.ForceTags {
|
||||||
|
options = "-f"
|
||||||
|
}
|
||||||
|
f.WriteCmd(fmt.Sprintf("docker tag %s %s:%s %s:%s", options, d.ImageName, buildImageTag, d.ImageName, tag))
|
||||||
}
|
}
|
||||||
|
|
||||||
f.WriteCmd(fmt.Sprintf("docker push %s:%s", d.ImageName, tag))
|
f.WriteCmd(fmt.Sprintf("docker push %s:%s", d.ImageName, tag))
|
||||||
|
|
|
@ -214,7 +214,7 @@ func TestTagsNoSingle(t *testing.T) {
|
||||||
if !strings.Contains(response, "docker build --pull -t username/image:release-0.2") {
|
if !strings.Contains(response, "docker build --pull -t username/image:release-0.2") {
|
||||||
t.Fatalf("Response: " + response + " isn't tagging images using our first custom tag\n\n")
|
t.Fatalf("Response: " + response + " isn't tagging images using our first custom tag\n\n")
|
||||||
}
|
}
|
||||||
if !strings.Contains(response, "docker tag username/image:release-0.2 username/image:release-latest") {
|
if !strings.Contains(response, "docker tag username/image:release-0.2 username/image:release-latest") {
|
||||||
t.Fatalf("Response: " + response + " isn't tagging images using our second custom tag\n\n")
|
t.Fatalf("Response: " + response + " isn't tagging images using our second custom tag\n\n")
|
||||||
}
|
}
|
||||||
if !strings.Contains(response, "docker push username/image:release-0.2") {
|
if !strings.Contains(response, "docker push username/image:release-0.2") {
|
||||||
|
@ -256,10 +256,10 @@ func TestTagsWithSingle(t *testing.T) {
|
||||||
if !strings.Contains(response, "docker build --pull -t username/image:release-0.3") {
|
if !strings.Contains(response, "docker build --pull -t username/image:release-0.3") {
|
||||||
t.Fatalf("Response: " + response + " isn't tagging images using our first custom tag\n\n")
|
t.Fatalf("Response: " + response + " isn't tagging images using our first custom tag\n\n")
|
||||||
}
|
}
|
||||||
if !strings.Contains(response, "docker tag username/image:release-0.3 username/image:release-0.2") {
|
if !strings.Contains(response, "docker tag username/image:release-0.3 username/image:release-0.2") {
|
||||||
t.Fatalf("Response: " + response + " isn't tagging images using our second custom tag\n\n")
|
t.Fatalf("Response: " + response + " isn't tagging images using our second custom tag\n\n")
|
||||||
}
|
}
|
||||||
if !strings.Contains(response, "docker tag username/image:release-0.3 username/image:release-latest") {
|
if !strings.Contains(response, "docker tag username/image:release-0.3 username/image:release-latest") {
|
||||||
t.Fatalf("Response: " + response + " isn't tagging images using our third custom tag\n\n")
|
t.Fatalf("Response: " + response + " isn't tagging images using our third custom tag\n\n")
|
||||||
}
|
}
|
||||||
if !strings.Contains(response, "docker push username/image:release-0.2") {
|
if !strings.Contains(response, "docker push username/image:release-0.2") {
|
||||||
|
|
|
@ -5,14 +5,24 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// bash header
|
// bash header plus an embedded perl script that can be used
|
||||||
const header = "#!/bin/bash\n"
|
// as an alternative to socat to proxy tcp traffic.
|
||||||
|
const header = `#!/bin/bash
|
||||||
|
set +e
|
||||||
|
`
|
||||||
|
|
||||||
|
// TODO(bradrydzewski) probably going to remove this
|
||||||
|
//echo H4sICGKv1VQAA3NvY2F0LnBsAH1SXUvDQBB8Tn7FipUmkpr6gWBKgyIiBdGixVeJ6RZP00u4S6wi8be7t3exFsWEhNzO7M7MXba34kar+FHIuEJV+I1GmNwkyV2Zv2A9Wq+xwJzWfk/IqqlhDM+lkEEf+tHp2e3lfTj6Rj5hGc/Op4Oryd3s4joJ9nbDaFGqF6Air/gVU0M2nyua1Dug76pUZmrvkDSW79ATpUZTWIsPUomrkQF3NLt7WGaVY2tUr6g6OqNJMrm+mHFT4HtXZZ4VZ6yXQn+4x3c/csCUxVNgF1S8RcrdsfcNS+gapWdWw6HPYY2/QUoRAqdOVX/1JAqEYD+ED9+j0MDm2A8EXU+eyQeF2ZxJnlgQ4ijjcRfFYp5pzwuBkvfGQiSa51jRYTiCwmVZ4z/h6Zoiqi4Q73v0Xd4Ib6ohT95IaD38AVhtB6yP5cN1tMa25fym2DpTLNtQWnqwoL+O80t8q6GRBWoN+EaHoGFjhP1uf2/Fv6zHZrFA9aMpm69bBql+16YUOF4ER8OTYxfRCjBnpUSNHSl03lu/9b8ACaSZylQDAAA= | base64 -d | gunzip > /tmp/socat && chmod +x /tmp/socat
|
||||||
|
|
||||||
// this command string will check if the socat utility
|
// this command string will check if the socat utility
|
||||||
// exists, and if it does, will proxy connections to
|
// exists, and if it does, will proxy connections to
|
||||||
// the external IP address.
|
// the external IP address.
|
||||||
const command = "[ -x /usr/bin/socat ] && socat TCP-LISTEN:%s,fork TCP:%s:%s &\n"
|
const command = "[ -x /usr/bin/socat ] && socat TCP-LISTEN:%s,fork TCP:%s:%s &\n"
|
||||||
|
|
||||||
|
// alternative command that acts as a "polyfill" for socat
|
||||||
|
// in the event that it isn't installed on the server
|
||||||
|
const polyfill = "[ -x /tmp/socat ] && /tmp/socat TCP-LISTEN:%s,fork TCP:%s:%s &\n"
|
||||||
|
|
||||||
// Proxy stores proxy configuration details mapping
|
// Proxy stores proxy configuration details mapping
|
||||||
// a local port to an external IP address with the
|
// a local port to an external IP address with the
|
||||||
// same port number.
|
// same port number.
|
||||||
|
@ -29,6 +39,9 @@ func (p Proxy) String() string {
|
||||||
buf.WriteString(header)
|
buf.WriteString(header)
|
||||||
for port, ip := range p {
|
for port, ip := range p {
|
||||||
buf.WriteString(fmt.Sprintf(command, port, ip, port))
|
buf.WriteString(fmt.Sprintf(command, port, ip, port))
|
||||||
|
|
||||||
|
// TODO(bradrydzewski) probably going to remove this
|
||||||
|
//buf.WriteString(fmt.Sprintf(polyfill, port, ip, port))
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf.String()
|
return buf.String()
|
||||||
|
|
|
@ -12,19 +12,16 @@ func TestProxy(t *testing.T) {
|
||||||
p.Set("8080", "172.1.4.5")
|
p.Set("8080", "172.1.4.5")
|
||||||
b := p.Bytes()
|
b := p.Bytes()
|
||||||
|
|
||||||
expected := `#!/bin/bash
|
expected := header + "[ -x /usr/bin/socat ] && socat TCP-LISTEN:8080,fork TCP:172.1.4.5:8080 &\n"
|
||||||
[ -x /usr/bin/socat ] && socat TCP-LISTEN:8080,fork TCP:172.1.4.5:8080 &
|
|
||||||
`
|
|
||||||
if string(b) != expected {
|
if string(b) != expected {
|
||||||
t.Errorf("Invalid proxy \n%s", expected)
|
t.Errorf("Invalid proxy got:\n%s\nwant:\n%s", string(b), expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
// test creating a proxy script when there
|
// test creating a proxy script when there
|
||||||
// are no proxy addresses added to the map
|
// are no proxy addresses added to the map
|
||||||
p = Proxy{}
|
p = Proxy{}
|
||||||
b = p.Bytes()
|
b = p.Bytes()
|
||||||
expected = "#!/bin/bash\n"
|
if string(b) != header {
|
||||||
if string(b) != expected {
|
t.Errorf("Invalid empty proxy file. Expected\n%s", header)
|
||||||
t.Errorf("Invalid proxy \n%s", expected)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue