1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-24 10:07:21 +02:00

Enable go vet for ci (#230)

* enable go vet for ci

* fix vet issues

* move `./.cli.sh` into `make release-cli`
This commit is contained in:
6543 2021-06-22 13:26:37 +02:00 committed by GitHub
parent b52ef5f270
commit d40a4a4b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 29 deletions

23
.cli.sh
View File

@ -1,23 +0,0 @@
#!/bin/sh
set -e
set -x
# disable CGO for cross-compiling
export CGO_ENABLED=0
# compile for all architectures
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/linux/amd64/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
GOOS=linux GOARCH=arm64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/linux/arm64/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
GOOS=linux GOARCH=arm go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/linux/arm/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/windows/amd64/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/darwin/amd64/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
# tar binary files prior to upload
tar -cvzf cli/release/woodpecker_linux_amd64.tar.gz -C cli/release/linux/amd64 woodpecker
tar -cvzf cli/release/woodpecker_linux_arm64.tar.gz -C cli/release/linux/arm64 woodpecker
tar -cvzf cli/release/woodpecker_linux_arm.tar.gz -C cli/release/linux/arm woodpecker
tar -cvzf cli/release/woodpecker_windows_amd64.tar.gz -C cli/release/windows/amd64 woodpecker
tar -cvzf cli/release/woodpecker_darwin_amd64.tar.gz -C cli/release/darwin/amd64 woodpecker
# generate shas for tar files
sha256sum cli/release/*.tar.gz > cli/release/woodpecker_checksums.txt

View File

@ -9,6 +9,7 @@ pipeline:
commands:
- make deps
- make test
- make vet
- make formatcheck
test-frontend:
@ -64,7 +65,7 @@ pipeline:
build-cli:
image: golang:1.16
commands: sh .cli.sh
commands: make release-cli
publish-server:
image: plugins/docker

View File

@ -79,6 +79,24 @@ release-agent:
release-server:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o release/drone-server github.com/woodpecker-ci/woodpecker/cmd/drone-server
release-cli:
# disable CGO for cross-compiling
export CGO_ENABLED=0
# compile for all architectures
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/linux/amd64/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
GOOS=linux GOARCH=arm64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/linux/arm64/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
GOOS=linux GOARCH=arm go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/linux/arm/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/windows/amd64/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/darwin/amd64/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
# tar binary files prior to upload
tar -cvzf cli/release/woodpecker_linux_amd64.tar.gz -C cli/release/linux/amd64 woodpecker
tar -cvzf cli/release/woodpecker_linux_arm64.tar.gz -C cli/release/linux/arm64 woodpecker
tar -cvzf cli/release/woodpecker_linux_arm.tar.gz -C cli/release/linux/arm woodpecker
tar -cvzf cli/release/woodpecker_windows_amd64.tar.gz -C cli/release/windows/amd64 woodpecker
tar -cvzf cli/release/woodpecker_darwin_amd64.tar.gz -C cli/release/darwin/amd64 woodpecker
# generate shas for tar files
sha256sum cli/release/*.tar.gz > cli/release/woodpecker_checksums.txt
release: release-agent release-server
install:

View File

@ -58,6 +58,4 @@ func (c *healthClient) Check(ctx context.Context) (bool, error) {
}
<-time.After(backoff)
}
return true, nil
}

View File

@ -145,9 +145,9 @@ func Test_parse(t *testing.T) {
g.It("Should return a Perm struct from a Gogs Perm", func() {
perms := []gogs.Permission{
{true, true, true},
{true, true, false},
{true, false, false},
{Admin: true, Pull: true, Push: true},
{Admin: true, Pull: true, Push: false},
{Admin: true, Push: false, Pull: false},
}
for _, from := range perms {
perm := toPerm(from)