How to configure Travis-CI to build pull requests & merges to master w/o redundancy

前端 未结 6 505
一整个雨季
一整个雨季 2021-01-30 08:20

To put it in \"BDD\" terms:

Background:
Given I\'m contributing to a GH repo

When I create a pull request
Then Travis shou

6条回答
  •  青春惊慌失措
    2021-01-30 08:44

    You can use next workflow if you want to test not only master branch but some others branches too:

    • Keep both "Build pushes" and "Build pull requests" ON
    • Add branches:except directive to your .travis.yml:

      branches:
        except:
          - /^pr\..*/
      

    In this configuration:

    • any commit to branch feature-A will trigger the build
    • any commit to branch pr.feature-A will not trigger the build
    • if branch pr.feature-A is used in opened pull request then build will be triggered

    Workflow example

    • temporary WIP branch shared between several developers: wip.feature-A, any commit to this branch will trigger the build
    • when branch is ready to be merged to master you can rename it from wip.feature-A to pr.feature-A and open pull request
    • if while reviewing pull request you want to apply new fixes, just push to pr.feature-A

    On all the steps above only one build will be triggered.

提交回复
热议问题