Skip to content

Commit 9c7d176

Browse files
committed
Refine CI
Signed-off-by: Ana Hobden <[email protected]>
1 parent c33bc13 commit 9c7d176

File tree

5 files changed

+103
-36
lines changed

5 files changed

+103
-36
lines changed

.travis.yml

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,64 @@
1-
branches:
2-
only:
3-
# This is where pull requests from "bors r+" are built.
4-
- staging
5-
# This is where pull requests from "bors try" are built.
6-
- trying
7-
# Enable building pull requests.
8-
- master
1+
sudo: false
92

103
language: rust
11-
sudo: false
4+
os:
5+
rust:
6+
cache: cargo
7+
stages:
8+
129
env:
1310
global:
1411
- RUST_BACKTRACE=1
1512
- RUSTFLAGS="-D warnings"
16-
cache: cargo
17-
18-
rust:
19-
os:
20-
- linux
21-
- windows
22-
- osx
2313

2414
matrix:
2515
include:
26-
# This build uses stable and checks rustfmt and clippy.
27-
# We don't check them on nightly since their lints and formatting may differ.
28-
- rust: stable
29-
install:
30-
- rustup component add rustfmt-preview
31-
- rustup component add clippy-preview
32-
before_script:
33-
- cargo fmt --all -- --check
34-
- cargo clippy --all -- -D clippy
35-
# Since many users will use nightlies, also test that.
36-
- rust: nightly
37-
16+
- os: linux
17+
rust: stable
18+
stages:
19+
- lint
20+
- unit
21+
- integration
22+
- os: linux
23+
rust: nightly
24+
stages:
25+
- unit
26+
- integration
27+
- os: windows
28+
rust: stable
29+
stages:
30+
- unit
31+
- integration
32+
- os: windows
33+
rust: nightly
34+
stages:
35+
- unit
36+
- integration
37+
# OS X doesn't get docker. :(
38+
- os: osx
39+
rust: stable
40+
stages:
41+
- unit
42+
- os: osx
43+
rust: nightly
44+
stages:
45+
- unit
3846

39-
script:
40-
- docker run -d --net=host --name pd --rm pingcap/pd --name "pd" --data-dir "pd" --client-urls "http://127.0.0.1:2379" --advertise-client-urls "http://127.0.0.1:2379"
41-
- docker run -d --net=host --name kv --rm pingcap/tikv --pd-endpoints "127.0.0.1:2379" --addr "127.0.0.1:2378" --data-dir "kv"
42-
- cargo test --all -- --nocapture
43-
# Validate benches still work.
44-
- cargo bench --all -- --test
47+
jobs:
48+
include:
49+
- stage: lint
50+
install:
51+
- rustup component add rustfmt-preview
52+
- rustup component add clippy-preview
53+
before_script:
54+
- cargo fmt --all -- --check
55+
- cargo clippy --all -- -D clippy
56+
- stage: unit
57+
script:
58+
- cargo test --all
59+
- stage: integration
60+
before_script:
61+
- docker run -d --net=host --name pd --rm pingcap/pd --name "pd" --data-dir "pd" --client-urls "http://127.0.0.1:2379" --advertise-client-urls "http://127.0.0.1:2379"
62+
- docker run -d --net=host --name kv --rm pingcap/tikv --pd-endpoints "127.0.0.1:2379" --addr "127.0.0.1:2378" --data-dir "kv"
63+
script:
64+
- cargo test --features integration-tests

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ repository = "https://github.com/tikv/client-rust"
88
description = "The rust language implementation of TiKV client."
99
edition = "2018"
1010

11+
[features]
12+
default = []
13+
# Enable integration tests with a running TiKV and PD instance.
14+
# Use $PD_ADDRS, comma separated, to set the addresses the tests use.
15+
integration-tests = []
16+
1117
[lib]
1218
name = "tikv_client"
1319

tests/integration_tests/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2019 The TiKV Project Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
mod raw;
15+
16+
use std::env::var;
17+
const ENV_PD_ADDR: &str = "PD_ADDR";
18+
19+
pub fn pd_addrs() -> Vec<String> {
20+
var(ENV_PD_ADDR)
21+
.expect(&format!("Expected {}:", ENV_PD_ADDR))
22+
.split(",")
23+
.map(From::from)
24+
.collect()
25+
}

tests/raw.rs renamed to tests/integration_tests/raw.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 The TiKV Project Authors
1+
// Copyright 2019 The TiKV Project Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@ use futures::future::Future;
1515

1616
const NUM_TEST_KEYS: u32 = 100;
1717
use tikv_client::{raw::Client, Config, Key, KvPair, Value};
18+
use crate::integration_tests::pd_addrs;
1819

1920
fn generate_key(id: i32) -> Key {
2021
format!("testkey_{}", id).into_bytes().into()
@@ -34,7 +35,7 @@ fn wipe_all(client: &Client) {
3435
}
3536

3637
fn connect() -> Client {
37-
let client = Client::new(&Config::new(vec!["127.0.0.1:2379"]))
38+
let client = Client::new(&Config::new(pd_addrs()))
3839
.wait()
3940
.expect("Could not connect to tikv");
4041
wipe_all(&client);

tests/test.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2019 The TiKV Project Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
#[cfg(feature = "integration-tests")]
15+
mod integration_tests;

0 commit comments

Comments
 (0)