gitgogithubtravis-citravis-ci-cli

How to run Integration just when merging to master


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`

Solution

  • 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