1个不稳定版本
使用旧的Rust 2015
0.1.0 | 2015年10月24日 |
---|
#797 在 开发工具
1KB
travis-cargo
此软件提供了一个独立的脚本travis-cargo
,用于在Travis CI(以及在一定程度上在AppVeyor)上管理运行cargo和其他相关功能。
功能
- 仅在特定版本的编译器上运行命令
- 当使用夜间编译器时,插入功能标志以启用不稳定功能的条件使用
- 当支持时,自动仅运行
cargo bench
- 使用hoverbear描述的技术上传文档,并通过我的修改避免
sudo
(特别是,它需要一个加密的GH_TOKEN
) - 记录crate内和外部测试的总覆盖率,并上传到coveralls.io。注意。这需要在Travis上运行
sudo
,并且test
配置文件必须具有debug = true
(这是默认值)
该脚本旨在与Python 2和Python 3自动配合工作。
我为此写了一些东西
安装
pip install 'travis-cargo<0.2' --user
export PATH=$HOME/.local/bin:$PATH
注意。 travis-cargo
遵循语义版本控制规则,因此0.x
和0.(x+1)
以及主要版本之间可能会发生破坏性更改。应使用上面演示的版本限制语法来防止这种情况。
示例
一个可能的.travis.yml
配置是
sudo: false
language: rust
# necessary for `travis-cargo coveralls --no-sudo`
addons:
apt:
packages:
- libcurl4-openssl-dev
- libelf-dev
- libdw-dev
- binutils-dev # optional: only required for the --verify flag of coveralls
# run builds for all the trains (and more)
rust:
- nightly
- beta
# check it compiles on the latest stable compiler
- stable
# and the first stable one (this should be bumped as the minimum
# Rust version required changes)
- 1.0.0
# load travis-cargo
before_script:
- |
pip install 'travis-cargo<0.2' --user &&
export PATH=$HOME/.local/bin:$PATH
# the main build
script:
- |
travis-cargo build &&
travis-cargo test &&
travis-cargo bench &&
travis-cargo --only stable doc
after_success:
# upload the documentation from the build with stable (automatically only actually
# runs on the master branch, not individual PRs)
- travis-cargo --only stable doc-upload
# measure code coverage and upload to coveralls.io (the verify
# argument mitigates kcov crashes due to malformed debuginfo, at the
# cost of some speed <https://github.com/huonw/travis-cargo/issues/12>)
- travis-cargo coveralls --no-sudo --verify
env:
global:
# override the default `--features unstable` used for the nightly branch (optional)
- TRAVIS_CARGO_NIGHTLY_FEATURE=nightly
# encrypted github token for doc upload (see `GH_TOKEN` link above)
- secure: "..."
可以在 cargo
调用中传递额外的参数,尽管以 -
为前缀的参数需要出现在 --
之后,例如 travis-cargo build -- --features something
。
如果您不想定义 unstable
或类似功能,设置 TRAVIS_CARGO_NIGHTLY_FEATURE=""
应该可以避免因未定义的功能而导致的错误。
帮助
usage: travis-cargo [-h] [-q] [--only VERSION] [--skip VERSION]
{coverage,coveralls,doc-upload,...} ...
Manages interactions between Travis and Cargo and common tooling tasks.
optional arguments:
-h, --help show this help message and exit
-q, --quiet don't pass --verbose to cargo subcommands
--only VERSION only run the given command if the specified version
matches `TRAVIS_RUST_VERSION`
subcommands:
travis-cargo supports all cargo subcommands, and selected others (listed
below). Cargo subcommands have `--verbose` added to their invocation by
default, and, when running with a nightly compiler, `--features unstable`
(or `--features $TRAVIS_CARGO_NIGHTLY_FEATURE` if that environment
variable is defined) if `--features` is a valid argument.
{coverage,coveralls,doc-upload,...}
coverage record code coverage
coveralls record and upload code coverage to coveralls.io
doc-upload upload documentation to Github pages.
覆盖率
usage: travis-cargo coverage [-h] [-m DIR] [--exclude-pattern PATTERN]
[--kcov-options OPTION] [--no-sudo] [--verify]
[ARGS [ARGS ...]]
Record coverage of `cargo test`, this runs all binaries that `cargo test` runs
but not doc tests. The results of all tests are merged into a single
directory.
positional arguments:
ARGS arguments to pass to `cargo test`
optional arguments:
-h, --help show this help message and exit
-m DIR, --merge-into DIR
the directory to put the final merged kcov result into
(default `target/kcov`)
--exclude-pattern PATTERN
pass additional comma-separated exclusionary patterns
to kcov. See <https://github.com/SimonKagstrom/kcov
#filtering-output> for how patterns work. By default,
the /.cargo pattern is ignored. Example: --exclude-
pattern="test/,bench/"
--kcov-options OPTION
pass additional arguments to kcov, apart from --verify
and --exclude-pattern, when recording coverage.
Specify multiple times for multiple arguments.
Example: --kcov-options="--debug=31"
--no-sudo don't use `sudo` to install kcov's deps. Requires that
libcurl4-openssl-dev, libelf-dev and libdw-dev are
installed (e.g. via `addons: apt: packages:`)
--verify pass `--verify` to kcov, to avoid some crashes. See
<https://github.com/huonw/travis-cargo/issues/12>.
This requires installing the `binutils-dev` package.
coveralls
usage: travis-cargo coveralls [-h] [--exclude-pattern PATTERN]
[--kcov-options OPTION] [--no-sudo] [--verify]
[ARGS [ARGS ...]]
Record coverage of `cargo test` and upload to coveralls.io with kcov, this
runs all binaries that `cargo test` runs but not doc tests. Merged kcov
results can be accessed in `target/kcov`.
positional arguments:
ARGS arguments to pass to `cargo test`
optional arguments:
-h, --help show this help message and exit
--exclude-pattern PATTERN
pass additional comma-separated exclusionary patterns
to kcov. See <https://github.com/SimonKagstrom/kcov
#filtering-output> for how patterns work. By default,
the /.cargo pattern is ignored. Example: --exclude-
pattern="test/,bench/"
--kcov-options OPTION
pass additional arguments to kcov, apart from --verify
and --exclude-pattern, when recording coverage.
Specify multiple times for multiple arguments.
Example: --kcov-options="--debug=31"
--no-sudo don't use `sudo` to install kcov's deps. Requires that
libcurl4-openssl-dev, libelf-dev and libdw-dev are
installed (e.g. via `addons: apt: packages:`)
--verify pass `--verify` to kcov, to avoid some crashes. See
<https://github.com/huonw/travis-cargo/issues/12>.
This requires installing the `binutils-dev` package.
文档上传
usage: travis_cargo.py doc-upload [-h] [--branch BRANCH]
Use ghp-import to upload cargo-rendered docs to Github Pages, from the master
branch.
optional arguments:
-h, --help show this help message and exit
--branch BRANCH upload docs when on this branch, defaults to master