Skip to content

Commit 861adb1

Browse files
authored
Merge pull request #3 from vania-pooh/master
Migrated to dep, added building Docker container (fixes #1, fixes #2)
2 parents b4db45c + 816bb32 commit 861adb1

File tree

9 files changed

+139
-27
lines changed

9 files changed

+139
-27
lines changed

.travis.yml

+41-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,47 @@
1+
sudo: required
12
language: go
23

34
go:
4-
- 1.7
5+
- 1.9.x
6+
7+
services:
8+
- docker
9+
510
script:
6-
- go test -coverprofile=coverage.txt -covermode=atomic -coverpkg .
11+
- go test -race -v github.com/seleniumkit/sctl/cmd -coverprofile=coverage.txt -covermode=atomic -coverpkg github.com/seleniumkit/sctl/cmd
12+
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X github.com/seleniumkit/sctl/cmd.buildStamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X github.com/seleniumkit/sctl/cmd.gitRevision=`git describe --tags || git rev-parse HEAD`"
13+
- gox -os "linux darwin" -arch "amd64" -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags "-X main.buildStamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X main.gitRevision=`git describe --tags || git rev-parse HEAD`"
14+
15+
before_install:
16+
- go get -u github.com/golang/dep/cmd/dep
17+
18+
install:
19+
- go get -u github.com/mitchellh/gox # cross compile
20+
- dep ensure
21+
22+
deploy:
23+
- provider: releases
24+
api-key: $GITHUB_TOKEN
25+
file_glob: true
26+
file: dist/*
27+
skip_cleanup: true
28+
on:
29+
tags: true
30+
- provider: script
31+
script: travis/docker-push.sh latest
32+
skip_cleanup: true
33+
on:
34+
branch: master
35+
- provider: script
36+
script: travis/docker-push.sh $TRAVIS_TAG
37+
skip_cleanup: true
38+
on:
39+
tags: true
40+
- provider: script
41+
script: travis/docker-push.sh latest-release
42+
skip_cleanup: true
43+
on:
44+
tags: true
745

846
after_success:
9-
- bash <(curl -s https://codecov.io/bash)
47+
- bash <(curl -s https://codecov.io/bash) -F unittests

Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM scratch
2+
3+
COPY sctl /
4+
5+
WORKDIR /root
6+
ENTRYPOINT ["/sctl"]

Godeps/Godeps.json

-19
This file was deleted.

Godeps/Readme

-5
This file was deleted.

Gopkg.lock

+31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# Gopkg.toml example
3+
#
4+
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
5+
# for detailed Gopkg.toml documentation.
6+
#
7+
# required = ["github.com/user/thing/cmd/thing"]
8+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
9+
#
10+
# [[constraint]]
11+
# name = "github.com/user/project"
12+
# version = "1.0.0"
13+
#
14+
# [[constraint]]
15+
# name = "github.com/user/project2"
16+
# branch = "dev"
17+
# source = "github.com/myfork/project2"
18+
#
19+
# [[override]]
20+
# name = "github.com/x/y"
21+
# version = "2.4.0"
22+
23+
24+
[[constraint]]
25+
branch = "master"
26+
name = "github.com/aandryashin/matchers"
27+
28+
[[constraint]]
29+
name = "github.com/spf13/cobra"

cmd/sctl.go

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var (
1919
func Execute() {
2020
sctlCmd.AddCommand(generateCmd)
2121
sctlCmd.AddCommand(statCmd)
22+
sctlCmd.AddCommand(versionCmd)
2223

2324
if _, err := sctlCmd.ExecuteC(); err != nil {
2425
os.Exit(1)

cmd/version.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"github.com/spf13/cobra"
6+
"os"
7+
)
8+
9+
var (
10+
gitRevision string = "HEAD"
11+
buildStamp string = "unknown"
12+
)
13+
14+
var versionCmd = &cobra.Command{
15+
Use: "version",
16+
Short: "Show version",
17+
Run: func(cmd *cobra.Command, args []string) {
18+
fmt.Printf("Git Revision: %s\n", gitRevision)
19+
fmt.Printf("UTC Build Time: %s\n", buildStamp)
20+
os.Exit(0)
21+
},
22+
}

travis/docker-push.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
docker build -t $TRAVIS_REPO_SLUG .
6+
docker tag $TRAVIS_REPO_SLUG $TRAVIS_REPO_SLUG:$1
7+
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
8+
docker push $TRAVIS_REPO_SLUG
9+
docker push $TRAVIS_REPO_SLUG:$1

0 commit comments

Comments
 (0)