Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit a8802c0

Browse files
authored
Merge pull request #996 from ebati/ci-make-version
Update CI and add version command
2 parents 5b1fe9e + 9217125 commit a8802c0

File tree

9 files changed

+162
-15
lines changed

9 files changed

+162
-15
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ everything here and write out the request, providing as much context as you can.
55
66
-->
77

8-
### What version of Go (`go version`) and `dep` (`git describe --tags`) are you using?
8+
### What version of `dep` are you using (`dep version`)?
9+
<!--
10+
If you installed `dep` via `go get`, report the version instead with
11+
`cd $GOPATH/src/github.com/golang/dep && git describe --tags`
12+
-->
913

1014
### What `dep` command did you run?
1115

@@ -20,4 +24,3 @@ The output of `dep hash-inputs` may also be helpful to include.
2024
### What did you expect to see?
2125

2226
### What did you see instead?
23-

.travis.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
---
21
language: go
32
sudo: false
43
notifications:
54
email: false
65
jobs:
76
include:
87
- stage: test
8+
go_import_path: github.com/golang/dep
99
install:
1010
- go get -u honnef.co/go/tools/cmd/{gosimple,staticcheck}
1111
- npm install -g codeclimate-test-reporter
@@ -15,20 +15,16 @@ jobs:
1515
go: 1.8.x
1616
script:
1717
- go build -v ./cmd/dep
18-
- PKGS=$(go list ./... | grep -v /vendor/)
19-
- go vet $PKGS
20-
- staticcheck $PKGS
21-
- gosimple $PKGS
18+
- ./hack/lint.bash
2219
- ./hack/validate-vendor.bash
23-
- go build ./hack/licenseok
24-
- find . -path ./vendor -prune -o -type f -name "*.go" -printf '%P\n' | xargs ./licenseok
25-
- set -e; for pkg in $PKGS; do go test -race -coverprofile=profile.out -covermode=atomic $pkg; if [[ -f profile.out ]]; then cat profile.out >> coverage.txt; rm profile.out; fi; done
20+
- ./hack/coverage.bash
2621
after_success:
2722
- codeclimate-test-reporter < coverage.txt
2823
# YAML alias, for settings shared across the simpler builds
2924
- &simple-test
3025
go: 1.9.x
3126
stage: test
27+
go_import_path: github.com/golang/dep
3228
install: skip
3329
env:
3430
- DEPTESTBYPASS501=1
@@ -53,3 +49,26 @@ jobs:
5349
# Related: https://superuser.com/questions/1044130/why-am-i-having-how-can-i-fix-this-error-shell-session-update-command-not-f
5450
- trap EXIT
5551
- go test -race $(go list ./... | grep -v vendor)
52+
- go: 1.8.x
53+
stage: deploy
54+
go_import_path: github.com/golang/dep
55+
install: skip
56+
script: skip
57+
before_deploy:
58+
- ./hack/build-all.bash
59+
deploy:
60+
- provider: releases
61+
api_key:
62+
secure: fL9GX11J3JLizEBTPZHN32wuAT91eAJsGl0kjlAdIc6Lb/9UCe1XZGgFnpQFN4qo/S+omhHBDbM6Ty1xhNy7xmjDecpQGDU8Rmap9Oll0TuxqMigG+njOuPp5VUYPofPP0PGKdxAcYg+KaFM7x0o2rK+qA046NHwo2gH1BbE+bn55TZglEajEfc8j9iX4jt96KC7zlu+WiKArLmfUtlrI8m8ZYgbYcvFmlYjeCiEqlNhvNL59ejug9Rl0PLtPbamqVXkGLafYtekgPCb4WSxBiCt8pq5Rb5svk9YcdXpiaWQhZjMPAuKN6BrmN2lw1PiXzADUG5fjvNc8eo2HY70GD2utU9cAsY8VIafhoH5n6uM1WI8MHwDfd7P1PiQA3ZGQ8CPwk4q/8HSfQU9ap7vZgSF63pTIbtlviyIG67orOJE9PWWncl9olYM946UylZu6m3hWI/rmJxOeJ1UJjym/3GNPMRfKubaGhV/TyRdM0bKX4M0cXHU6k/ESVFupGXdKRt4RpvkD4/1Km6b2OShW6PNI+ifFspnJr7obkI7dm7ubySdnNz4lMv9WWymxRpMVc8hUAhuoDvXeZJq7pSnkjBEWDxIRoTkA93CU3/Rf7MFYCJMnGSqjcxWUpIfCAk2/r4BqL9NQnqBvvVt+MYi64QaD5n7ZF3dVbr6HZ2zjSU=
63+
file:
64+
- release/dep-linux-amd64
65+
- release/dep-linux-amd64.sha256
66+
- release/dep-darwin-amd64
67+
- release/dep-darwin-amd64.sha256
68+
- release/dep-windows-amd64
69+
- release/dep-windows-amd64.sha256
70+
skip_cleanup: true
71+
on:
72+
repo: golang/dep
73+
branch: master
74+
tags: true

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ That said, keep in mind the following:
3939

4040
## Setup
4141

42-
Get the tool via
43-
44-
```sh
45-
$ go get -u github.com/golang/dep/cmd/dep
46-
```
42+
Grab the latest binary from the [releases](https://github.com/golang/dep/releases) page.
4743

4844
On macOS you can install or upgrade to the latest released version with Homebrew:
4945

@@ -52,6 +48,12 @@ $ brew install dep
5248
$ brew upgrade dep
5349
```
5450

51+
If you're interested in hacking on `dep`, you can install via `go get`:
52+
53+
```sh
54+
go get -u github.com/dep/cmd/dep
55+
```
56+
5557
To start managing dependencies using dep, run the following from your project's root directory:
5658

5759
```sh

cmd/dep/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func (c *Config) Run() (exitCode int) {
6262
&ensureCommand{},
6363
&hashinCommand{},
6464
&pruneCommand{},
65+
&versionCommand{},
6566
}
6667

6768
examples := [][2]string{

cmd/dep/version.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2016 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"flag"
9+
"runtime"
10+
11+
"github.com/golang/dep"
12+
)
13+
14+
var (
15+
version = "devel"
16+
buildDate string
17+
commitHash string
18+
)
19+
20+
const versionHelp = `Show the dep version information`
21+
22+
func (cmd *versionCommand) Name() string { return "version" }
23+
func (cmd *versionCommand) Args() string {
24+
return ""
25+
}
26+
func (cmd *versionCommand) ShortHelp() string { return versionHelp }
27+
func (cmd *versionCommand) LongHelp() string { return versionHelp }
28+
func (cmd *versionCommand) Hidden() bool { return false }
29+
30+
func (cmd *versionCommand) Register(fs *flag.FlagSet) {}
31+
32+
type versionCommand struct{}
33+
34+
func (cmd *versionCommand) Run(ctx *dep.Ctx, args []string) error {
35+
ctx.Out.Printf(`dep:
36+
version : %s
37+
build date : %s
38+
git hash : %s
39+
go version : %s
40+
go compiler : %s
41+
platform : %s/%s
42+
`, version, buildDate, commitHash,
43+
runtime.Version(), runtime.Compiler, runtime.GOOS, runtime.GOARCH)
44+
return nil
45+
}

hack/build-all.bash

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2017 The Go Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style
4+
# license that can be found in the LICENSE file.
5+
#
6+
# This script will build dep and calculate hash for each
7+
# (DEP_BUILD_PLATFORMS, DEP_BUILD_ARCHS) pair.
8+
# DEP_BUILD_PLATFORMS="linux" DEP_BUILD_ARCHS="amd64" ./hack/build-all.sh
9+
# can be called to build only for linux-amd64
10+
11+
set -e
12+
13+
VERSION=$(git describe --tags --dirty)
14+
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null)
15+
DATE=$(date --iso-8601)
16+
17+
GO_BUILD_CMD="go build -a -installsuffix cgo"
18+
GO_BUILD_LDFLAGS="-s -w -X main.commitHash=$COMMIT_HASH -X main.buildDate=$DATE -X main.version=$VERSION"
19+
20+
if [ -z "$DEP_BUILD_PLATFORMS" ]; then
21+
DEP_BUILD_PLATFORMS="linux windows darwin"
22+
fi
23+
24+
if [ -z "$DEP_BUILD_ARCHS" ]; then
25+
DEP_BUILD_ARCHS="amd64"
26+
fi
27+
28+
mkdir -p release
29+
30+
for OS in ${DEP_BUILD_PLATFORMS[@]}; do
31+
for ARCH in ${DEP_BUILD_ARCHS[@]}; do
32+
echo "Building for $OS/$ARCH"
33+
GOARCH=$ARCH GOOS=$OS CGO_ENABLED=0 $GO_BUILD_CMD -ldflags "$GO_BUILD_LDFLAGS"\
34+
-o "release/dep-$OS-$ARCH" ./cmd/dep/
35+
sha256sum "release/dep-$OS-$ARCH" > "release/dep-$OS-$ARCH".sha256
36+
done
37+
done

hack/coverage.bash

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2017 The Go Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style
4+
# license that can be found in the LICENSE file.
5+
#
6+
# This script will generate coverage.txt
7+
set -e
8+
9+
PKGS=$(go list ./... | grep -v /vendor/)
10+
for pkg in $PKGS; do
11+
go test -race -coverprofile=profile.out -covermode=atomic $pkg
12+
if [[ -f profile.out ]]; then
13+
cat profile.out >> coverage.txt
14+
rm profile.out
15+
fi
16+
done

hack/lint.bash

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2017 The Go Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style
4+
# license that can be found in the LICENSE file.
5+
#
6+
# This script will validate code with various linters
7+
set -e
8+
9+
PKGS=$(go list ./... | grep -v /vendor/)
10+
go vet $PKGS
11+
staticcheck $PKGS
12+
gosimple $PKGS

hack/validate-licence.bash

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2017 The Go Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style
4+
# license that can be found in the LICENSE file.
5+
#
6+
# This script will build licenseok and run it on all
7+
# source files to check licence
8+
set -e
9+
10+
go build ./hack/licenseok
11+
find . -path ./vendor -prune -o -type f -name "*.go"\
12+
-printf '%P\n' | xargs ./licenseok

0 commit comments

Comments
 (0)