{before_,}{install,script} .travis.yml 选项之间有什么区别?
What are the differences between the {before_,}{install,script} .travis.yml options?
在 .travis.yml
配置文件中,before_install
、install
、before_script
和 script
选项之间的实际区别是什么?
我没有找到解释这些选项之间差异的文档。
你不需要使用这些部分,但如果你这样做,你就传达了你正在做的事情的意图:
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 年第 2 季度)说明了 commit 3c93b82 (08 Jan 2018) by SZEDER Gábor (szeder
).
(由 Junio C Hamano -- gitster
-- in commit c710d18 合并,2018 年 3 月 8 日)
这说明了 before_install
、install
、before_script
和 script
选项之间的实际区别
travis-ci
: build Git during the 'script
' phase
Ever since we started building and testing Git on Travis CI (522354d: Add Travis CI support, 2015-11-27, Git v2.7.0-rc0), we build Git in the
'before_script
' phase and run the test suite in the 'script
' phase
(except in the later introduced 32 bit Linux and Windows build jobs,
where we build in the 'script
' phase').
Contrarily, the Travis CI practice is to build and test in the
'script
' phase; indeed Travis CI's default build command for the
'script
' phase of C/C++ projects is:
./configure && make && make test
The reason why Travis CI does it this way and why it's a better
approach than ours lies in how unsuccessful build jobs are
categorized. After something went wrong in a build job, its state can
be:
'failed', if a command in the 'script
' phase returned an error.
This is indicated by a red 'X' on the Travis CI web interface.
'errored', if a command in the 'before_install
', 'install
', or
'before_script
' phase returned an error, or the build job exceeded
the time limit.
This is shown as a red '!' on the web interface.
This makes it easier, both for humans looking at the Travis CI web
interface and for automated tools querying the Travis CI API, to
decide when an unsuccessful build is our responsibility requiring
human attention, i.e. when a build job 'failed' because of a compiler
error or a test failure, and when it's caused by something beyond our
control and might be fixed by restarting the build job, e.g. when a
build job 'errored' because a dependency couldn't be installed due to
a temporary network error or because the OSX build job exceeded its
time limit.
The drawback of building Git in the 'before_script
' phase is that one
has to check the trace log of all 'errored' build jobs, too, to see
what caused the error, as it might have been caused by a compiler
error.
This requires additional clicks and page loads on the web interface and additional complexity and API requests in automated tools.
Therefore, move building Git from the 'before_script
' phase to the
'script
' phase, updating the script's name accordingly as well.
'ci/run-builds.sh
' now becomes basically empty, remove it.
Several of our build job configurations override our default 'before_script
' to do nothing; with this change our default 'before_script
' won't do
anything, either, so remove those overriding directives as well.
在 .travis.yml
配置文件中,before_install
、install
、before_script
和 script
选项之间的实际区别是什么?
我没有找到解释这些选项之间差异的文档。
你不需要使用这些部分,但如果你这样做,你就传达了你正在做的事情的意图:
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 年第 2 季度)说明了 commit 3c93b82 (08 Jan 2018) by SZEDER Gábor (szeder
).
(由 Junio C Hamano -- gitster
-- in commit c710d18 合并,2018 年 3 月 8 日)
这说明了 before_install
、install
、before_script
和 script
选项之间的实际区别
travis-ci
: build Git during the 'script
' phaseEver since we started building and testing Git on Travis CI (522354d: Add Travis CI support, 2015-11-27, Git v2.7.0-rc0), we build Git in the '
before_script
' phase and run the test suite in the 'script
' phase (except in the later introduced 32 bit Linux and Windows build jobs, where we build in the 'script
' phase').Contrarily, the Travis CI practice is to build and test in the '
script
' phase; indeed Travis CI's default build command for the 'script
' phase of C/C++ projects is:./configure && make && make test
The reason why Travis CI does it this way and why it's a better approach than ours lies in how unsuccessful build jobs are categorized. After something went wrong in a build job, its state can be:
'failed', if a command in the '
script
' phase returned an error.
This is indicated by a red 'X' on the Travis CI web interface.'errored', if a command in the '
before_install
', 'install
', or 'before_script
' phase returned an error, or the build job exceeded the time limit.
This is shown as a red '!' on the web interface.This makes it easier, both for humans looking at the Travis CI web interface and for automated tools querying the Travis CI API, to decide when an unsuccessful build is our responsibility requiring human attention, i.e. when a build job 'failed' because of a compiler error or a test failure, and when it's caused by something beyond our control and might be fixed by restarting the build job, e.g. when a build job 'errored' because a dependency couldn't be installed due to a temporary network error or because the OSX build job exceeded its time limit.
The drawback of building Git in the '
before_script
' phase is that one has to check the trace log of all 'errored' build jobs, too, to see what caused the error, as it might have been caused by a compiler error.
This requires additional clicks and page loads on the web interface and additional complexity and API requests in automated tools.Therefore, move building Git from the '
before_script
' phase to the 'script
' phase, updating the script's name accordingly as well.
'ci/run-builds.sh
' now becomes basically empty, remove it.
Several of our build job configurations override our default 'before_script
' to do nothing; with this change our default 'before_script
' won't do anything, either, so remove those overriding directives as well.