{before_,}{install,script}.travis.yml选项之间有什么区别



.travis.yml配置文件中,before_installinstallbefore_scriptscript选项之间的实际区别是什么?

我没有发现任何文件解释这些选项之间的差异。

您不需要使用这些部分,但如果您使用了,您就可以传达您正在做的事情的意图:

before_install:
  # execute all of the commands which need to be executed 
  # before installing dependencies
  - composer self-update
  - composer validate
install:
  # install all of the dependencies you need here
  - composer install --prefer-dist
before_script:
  # execute all of the commands which need to be executed 
  # before running actual tests
  - mysql -u root -e 'CREATE DATABASE test'
  - bin/doctrine-migrations migrations:migrate
script:
  # execute all of the commands which 
  # should make the build pass or fail
  - vendor/bin/phpunit
  - vendor/bin/php-cs-fixer fix --verbose --diff --dry-run

例如,https://github.com/localheinz/composer-normalize/blob/0.8.0/.travis.yml.

不同之处在于出现问题时作业的状态。

Git 2.17(2018年第二季度)说明了SZEDER Gábor(szeder)提交的3c93b82(2018年1月8日)
(由Junio C Hamano合并——gitster——提交c710d182018年3月8日)

这说明了before_installinstallbefore_scriptscript选项之间的实际差异

travis-ci:在"script"阶段构建Git

自从我们开始在Travis CI上构建和测试Git(522354d:添加Travis Cl支持,2015-11-27,Git v2.7.0-rc0)以来,我们在"before_script"阶段,并在"script"阶段运行测试套件(除了在后来引入的32位Linux和Windows构建作业中,我们在"script"阶段中构建)。

相反,Travis CI实践是在‘script’阶段;实际上Travis CI的默认构建命令C/C++项目的"script"阶段是:

./configure && make && make test

Travis CI这样做的原因以及为什么它更好比我们的方法更重要的是,创造就业机会有多不成功分类。在生成作业出现问题后,其状态可以be:

  • "失败",如果"script"阶段的命令返回错误
    Travis CI web界面上的红色"X"表示这一点。

  • 'errored',如果'before_install'、'install'或"before_script"阶段返回错误,或者超出了生成作业时间限制
    这显示为红色"!"在web界面上。

这让它变得更容易,无论是对于查看Travis CI网络的人类来说接口,用于查询Travis CI API的自动化工具,以决定何时需要不成功的构建人为注意,即当生成作业由于编译器而"失败"时错误或测试失败,以及当它是由我们控件,并且可以通过重新启动构建作业来修复,例如当生成作业"errored",因为无法安装依赖项,原因是临时网络错误,或者因为OSX生成作业超出了时间限制。

在"before_script"阶段构建Git的缺点是还必须检查所有"错误"生成作业的跟踪日志,才能查看是什么导致了错误,因为它可能是由编译器引起的错误
这需要在web界面上进行额外的点击和页面加载,以及自动化工具中额外的复杂性和API请求。

因此,将构建Git从"before_script"阶段移到"script"阶段,并相应地更新脚本的名称
'ci/run-builds.sh'现在基本为空,请将其删除。
我们的几个构建作业配置覆盖了默认的"before_script",不执行任何操作;通过此更改,我们的默认"before_script"将无法执行任何东西,所以也要删除那些重写指令。

最新更新