1# Use the newer Travis-CI build templates based on the
2# Debian Linux distribution "Trusty" release.
3os:             linux
4dist:           trusty
5
6# Disable sudo for all builds by default. This ensures all jobs use
7# Travis-CI's containerized build environment unless specified otherwise.
8# The container builds have *much* shorter queue times than the VM-based
9# build environment on which the sudo builds depend.
10sudo:           false
11services:       false
12
13# Set the version of Go.
14language:       go
15go:             1.11
16
17# Always set the project's Go import path to ensure that forked
18# builds get cloned to the correct location.
19go_import_path: github.com/vmware/govmomi
20
21# Ensure all the jobs know where the temp directory is.
22env:
23  global: TMPDIR=/tmp
24
25jobs:
26  include:
27
28    # The "lint" stage runs the various linters against the project.
29    - &lint-stage
30      stage:         lint
31      env:           LINTER=govet
32      install:       true
33      script:        make "${LINTER}"
34
35    - <<:            *lint-stage
36      env:           LINTER=goimports
37
38    # The "build" stage verifies the program can be built against the
39    # various GOOS and GOARCH combinations found in the Go releaser
40    # config file, ".goreleaser.yml".
41    - &build-stage
42      stage:         build
43      env:           GOOS=linux GOARCH=amd64
44      install:       true
45      script:        make install
46
47    - <<:            *build-stage
48      env:           GOOS=linux   GOARCH=386
49
50    - <<:            *build-stage
51      env:           GOOS=darwin  GOARCH=amd64
52    - <<:            *build-stage
53      env:           GOOS=darwin  GOARCH=386
54
55    - <<:            *build-stage
56      env:           GOOS=freebsd GOARCH=amd64
57    - <<:            *build-stage
58      env:           GOOS=freebsd GOARCH=386
59
60    - <<:            *build-stage
61      env:           GOOS=windows GOARCH=amd64
62    - <<:            *build-stage
63      env:           GOOS=windows GOARCH=386
64
65    # The test stage executes the test target.
66    - stage:         test
67      install:       true
68      script:        make test
69
70    # The deploy stage deploys the build artifacts using goreleaser.
71    #
72    # This stage will only be activated when there is an annotated tag present
73    # or when the text "/ci-deploy" is present in the commit message. However,
74    # the "deploy" phase of the build will still only be executed on non-PR
75    # builds as that restriction is baked into Travis-CI.
76    #
77    # Finally, this stage requires the Travis-CI VM infrastructure in order to
78    # leverage Docker. This will increase the amount of time the jobs sit
79    # in the queue, waiting to be built. However, it's a necessity as Travis-CI
80    # only allows the use of Docker with VM builds.
81    - stage:         deploy
82      if:            tag IS present OR commit_message =~ /\/ci-deploy/
83      sudo:          required
84      services:      docker
85      install:       true
86      script:        make install
87      after_success: docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
88      deploy:
89      - provider:     script
90        skip_cleanup: true
91        script:       curl -sL http://git.io/goreleaser | bash
92      addons:
93        apt:
94          update:     true
95          packages:   xmlstarlet
96