-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.travis.yml
56 lines (45 loc) · 1.85 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
dist: trusty
sudo: required
notifications:
email: false
language: go
go_import_path: github.com/HewlettPackard/terraform-provider-oneview
go:
- 1.11
env:
global:
- BUILDNAME=terraform-provider-oneview
- TF_DOWNLOAD_PATH=./bins
- TF_PLATFORMS="linux"
- CGO_ENABLED=0
- GOARCH=amd64
- REPO=$DOCKER_USERNAME/terraform-provider-oneview
- TAG=$(if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo "branch-${TRAVIS_BRANCH}"; fi)
- UNFORMATTED=$(find . -type f -name "*.go" -not -path "./vendor/*" | sed "s|^\./||" | xargs gofmt -l)
install:
- mkdir -p $TF_DOWNLOAD_PATH
- bash <(curl -s https://raw.githubusercontent.com/patrickdappollonio/download-terraform-binaries/master/download_terraform_binaries.sh)
before_script:
- if ! [ -z "$UNFORMATTED" ]; then
echo -e "Go files must be formatted with gofmt. Please run:";
for fn in $UNFORMATTED; do
echo -e " gofmt -w $PWD/$fn";
done;
exit 1;
fi
script:
# Standard Go testing avoiding the testing of the vendor folder.
- go vet $(go list ./... | grep -v '/vendor/')
- go test -v $(go list ./... | grep -v '/vendor/')
# Build disabling CGO and getting a statically linked binary.
- GOOS=linux go build -a -tags netgo -ldflags '-s -w' -o $TF_DOWNLOAD_PATH/linux/$BUILDNAME
# Create the docker image from the Dockerfile.
- docker build -f Dockerfile -t $REPO .
# Run a Sanity Check against an empty terraform file. When
# ran, it should fail if the compilation was unsuccessful.
- docker run -it --rm=true $REPO /bin/bash -c "echo '' >> /demo.tf && cd / && /usr/local/terraform/terraform plan"
after_success:
- if [ "$TRAVIS_BRANCH" == "master" ]; then
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
docker push $REPO;
fi