0

I've Travis CI which is working as expected for Go application

language: go
go:

- "1.10.x"

script:

- go get -v -t -d ./...
- go test -v ./...

This CI takes about a 60-80 sec to run.

The CI is triggered in two scenarios

  1. Submitting to new branch
  2. Merging to the master

Now I've new file which is called integration_test.go which is running integration test which takes about 10 min (deployment etc) and I want to run this test only when merging to the master (since its more heavy) , and not run when submitting to branches, how it can be done it Travis?

I've tried with

on:
    branch: master
    condition: `go test -v integration_test.go`
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
  • Have you tried reading the Travis docs on conditional functionality? – jonrsharpe Nov 17 '18 at 19:17
  • @jonrsharpe - yep I try it without success, see my edit please, do you know what am I missing here ? –  Nov 17 '18 at 19:22
  • That's just not how conditional stages work; see https://docs.travis-ci.com/user/conditional-builds-stages-jobs – jonrsharpe Nov 17 '18 at 19:27
  • @jonrsharpe - Ok thanks but How should I tell it run only this test `if: branch = master `go test -v integration_test.go`` ? –  Nov 17 '18 at 19:29
  • @jonrsharpe - can you provide a reference for my issue please? –  Nov 17 '18 at 19:30
  • Please *read the docs I've linked to*, they explain exactly how to run a stage conditionally. If you still have an issue after making an honest attempt to implement that, [edit] to clarify. – jonrsharpe Nov 17 '18 at 19:30
  • @jonrsharpe - I read it , so it should be like this , isnt it ? `if: branch = master go test -v integration_test.go` –  Nov 17 '18 at 19:31

1 Answers1

2

What you're likely looking for here is a 'Conditional job'. Using the example here: https://docs.travis-ci.com/user/build-stages/matrix-expansion/

try:

language: go

go:
    - "1.10.x"

script:
    - go get -v -t -d ./...
    - go test -v ./...

jobs:
    include:
        - stage: integration
          if: branch = master
          script: go test -v integration_test.go
nbp
  • 38
  • 3