Skip to content

Commit 3605565

Browse files
bors[bot]cuviper
andauthored
Merge #79
79: Switch CI to GitHub Actions r=cuviper a=cuviper Co-authored-by: Josh Stone <cuviper@gmail.com>
2 parents 07112ea + 3881e4e commit 3605565

File tree

10 files changed

+235
-93
lines changed

10 files changed

+235
-93
lines changed

.github/workflows/ci.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- staging
6+
- trying
7+
8+
jobs:
9+
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
rust: [
16+
1.31.0, # 2018!
17+
1.36.0, # alloc
18+
stable,
19+
beta,
20+
nightly
21+
]
22+
steps:
23+
- name: Rust install
24+
uses: actions-rs/toolchain@v1
25+
with:
26+
toolchain: ${{ matrix.rust }}
27+
profile: minimal
28+
override: true
29+
- name: Checkout
30+
uses: actions/checkout@v2
31+
- name: Build
32+
uses: actions-rs/cargo@v1
33+
with:
34+
command: build
35+
- name: Test
36+
run: ./ci/test_full.sh
37+
38+
# try a target that doesn't have std at all, but does have alloc
39+
no_std_stable:
40+
name: No Std (stable)
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Rust install
44+
uses: actions-rs/toolchain@v1
45+
with:
46+
toolchain: stable
47+
profile: minimal
48+
override: true
49+
target: thumbv6m-none-eabi
50+
- name: Checkout
51+
uses: actions/checkout@v1
52+
- name: Build
53+
uses: actions-rs/cargo@v1
54+
with:
55+
command: build
56+
args: --target thumbv6m-none-eabi --no-default-features --features "bigint serde"
57+
58+
# try a target that doesn't have std at all, nor alloc
59+
no_std_131:
60+
name: No Std (1.31.0)
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Rust install
64+
uses: actions-rs/toolchain@v1
65+
with:
66+
toolchain: 1.31.0
67+
profile: minimal
68+
override: true
69+
target: thumbv6m-none-eabi
70+
- name: Checkout
71+
uses: actions/checkout@v1
72+
- name: Build
73+
uses: actions-rs/cargo@v1
74+
with:
75+
command: build
76+
args: --target thumbv6m-none-eabi --no-default-features --features "serde"
77+
78+
fmt:
79+
name: Format
80+
runs-on: ubuntu-latest
81+
steps:
82+
- name: Rust install
83+
uses: actions-rs/toolchain@v1
84+
with:
85+
toolchain: 1.42.0
86+
profile: minimal
87+
override: true
88+
components: rustfmt
89+
- name: Checkout
90+
uses: actions/checkout@v2
91+
- name: Check formatting
92+
uses: actions-rs/cargo@v1
93+
with:
94+
command: fmt
95+
args: --all -- --check

.github/workflows/master.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: master
2+
on:
3+
push:
4+
branches:
5+
- master
6+
schedule:
7+
- cron: '0 0 * * 0' # 00:00 Sunday
8+
9+
jobs:
10+
11+
test:
12+
name: Test
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
rust: [1.31.0, stable]
17+
steps:
18+
- name: Rust install
19+
uses: actions-rs/toolchain@v1
20+
with:
21+
toolchain: ${{ matrix.rust }}
22+
profile: minimal
23+
override: true
24+
- name: Checkout
25+
uses: actions/checkout@v2
26+
- name: Build
27+
uses: actions-rs/cargo@v1
28+
with:
29+
command: build
30+
- name: Test
31+
run: ./ci/test_full.sh

.github/workflows/pr.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: PR
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
7+
test:
8+
name: Test
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
rust: [1.31.0, stable]
13+
steps:
14+
- name: Rust install
15+
uses: actions-rs/toolchain@v1
16+
with:
17+
toolchain: ${{ matrix.rust }}
18+
profile: minimal
19+
override: true
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
- name: Build
23+
uses: actions-rs/cargo@v1
24+
with:
25+
command: build
26+
- name: Test
27+
run: ./ci/test_full.sh
28+
29+
fmt:
30+
name: Format
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Rust install
34+
uses: actions-rs/toolchain@v1
35+
with:
36+
toolchain: 1.42.0
37+
profile: minimal
38+
override: true
39+
components: rustfmt
40+
- name: Checkout
41+
uses: actions/checkout@v2
42+
- name: Check formatting
43+
uses: actions-rs/cargo@v1
44+
with:
45+
command: fmt
46+
args: --all -- --check

.travis.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ name = "num-rational"
1010
repository = "https://github.com/rust-num/num-rational"
1111
version = "0.3.0-pre"
1212
readme = "README.md"
13-
exclude = ["/ci/*", "/.travis.yml", "/bors.toml"]
13+
exclude = ["/bors.toml", "/ci/*", "/.github/*"]
1414
publish = false
1515
edition = "2018"
1616

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[![crate](https://img.shields.io/crates/v/num-rational.svg)](https://crates.io/crates/num-rational)
44
[![documentation](https://docs.rs/num-rational/badge.svg)](https://docs.rs/num-rational)
5-
![minimum rustc 1.31](https://img.shields.io/badge/rustc-1.31+-red.svg)
6-
[![Travis status](https://travis-ci.org/rust-num/num-rational.svg?branch=master)](https://travis-ci.org/rust-num/num-rational)
5+
[![minimum rustc 1.31](https://img.shields.io/badge/rustc-1.31+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
6+
[![build status](https://github.com/rust-num/num-rational/workflows/master/badge.svg)](https://github.com/rust-num/num-rational/actions)
77

88
Generic `Rational` numbers (aka fractions) for Rust.
99

bors.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
status = [
2-
"continuous-integration/travis-ci/push",
2+
"Test (1.31.0)",
3+
"Test (1.36.0)",
4+
"Test (stable)",
5+
"Test (beta)",
6+
"Test (nightly)",
7+
"No Std (1.31.0)",
8+
"No Std (stable)",
9+
"Format",
310
]

ci/rustup.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#!/bin/sh
2-
# Use rustup to locally run the same suite of tests as .travis.yml.
3-
# (You should first install/update all versions listed below.)
2+
# Use rustup to locally run the same suite of tests as .github/workflows/
3+
# (You should first install/update all of the versions below.)
44

55
set -ex
66

7-
export TRAVIS_RUST_VERSION
8-
for TRAVIS_RUST_VERSION in 1.31.0 stable beta nightly; do
9-
run="rustup run $TRAVIS_RUST_VERSION"
10-
$run cargo build --verbose
11-
$run $PWD/ci/test_full.sh
7+
ci=$(dirname $0)
8+
for version in 1.31.0 1.36.0 stable beta nightly; do
9+
rustup run "$version" "$ci/test_full.sh"
1210
done

ci/test_full.sh

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,64 @@
22

33
set -e
44

5+
CRATE=num-rational
6+
MSRV=1.31
7+
58
get_rust_version() {
69
local array=($(rustc --version));
710
echo "${array[1]}";
811
return 0;
912
}
13+
RUST_VERSION=$(get_rust_version)
1014

11-
if [ -z ${TRAVIS+x} ]
12-
then RUST_VERSION=$(get_rust_version) # we're not in travis
13-
else RUST_VERSION=$TRAVIS_RUST_VERSION # we're in travis
14-
fi
15+
check_version() {
16+
IFS=. read -ra rust <<< "$RUST_VERSION"
17+
IFS=. read -ra want <<< "$1"
18+
[[ "${rust[0]}" -gt "${want[0]}" ||
19+
( "${rust[0]}" -eq "${want[0]}" &&
20+
"${rust[1]}" -ge "${want[1]}" )
21+
]]
22+
}
1523

16-
if [ -z "${RUST_VERSION}" ]
17-
then echo "WARNING: RUST_VERSION is undefined or empty string" 1>&2
18-
else echo Testing num-rational on rustc "${RUST_VERSION}"
24+
echo "Testing $CRATE on rustc $RUST_VERSION"
25+
if ! check_version $MSRV ; then
26+
echo "The minimum for $CRATE is rustc $MSRV"
27+
exit 1
1928
fi
2029

30+
STD_FEATURES=(bigint-std serde)
31+
NO_STD_FEATURES=(serde)
32+
check_version 1.36 && NO_STD_FEATURES+=(bigint)
33+
echo "Testing supported features: ${STD_FEATURES[*]}"
34+
echo " no_std supported features: ${NO_STD_FEATURES[*]}"
35+
2136
set -x
2237

23-
STD_FEATURES="bigint-std serde"
38+
# test the default with std
39+
cargo build
40+
cargo test
2441

25-
case "$RUST_VERSION" in
26-
1.3[1-5].*) NO_STD_FEATURES="serde" ;;
27-
*) NO_STD_FEATURES="bigint serde" ;;
28-
esac
42+
# test each isolated feature with std
43+
for feature in ${STD_FEATURES[*]}; do
44+
cargo build --no-default-features --features="std $feature"
45+
cargo test --no-default-features --features="std $feature"
46+
done
2947

48+
# test all supported features with std
49+
cargo build --no-default-features --features="std ${STD_FEATURES[*]}"
50+
cargo test --no-default-features --features="std ${STD_FEATURES[*]}"
3051

31-
# num-rational should build and test everywhere.
32-
cargo build --verbose
33-
cargo test --verbose
3452

35-
# It should build with minimal features too.
53+
# test minimal `no_std`
3654
cargo build --no-default-features
3755
cargo test --no-default-features
3856

39-
# Each isolated feature should also work everywhere.
40-
for feature in $STD_FEATURES; do
41-
cargo build --verbose --no-default-features --features="std $feature"
42-
cargo test --verbose --no-default-features --features="std $feature"
43-
done
44-
45-
# test all supported features together
46-
cargo build --features="std $STD_FEATURES"
47-
cargo test --features="std $STD_FEATURES"
48-
49-
# Each no-std isolated feature should also work everywhere.
50-
for feature in $NO_STD_FEATURES; do
51-
cargo build --verbose --no-default-features --features="$feature"
52-
cargo test --verbose --no-default-features --features="$feature"
57+
# test each isolated feature without std
58+
for feature in ${NO_STD_FEATURES[*]}; do
59+
cargo build --no-default-features --features="$feature"
60+
cargo test --no-default-features --features="$feature"
5361
done
5462

55-
# test all no-std supported features together
56-
cargo build --no-default-features --features="$NO_STD_FEATURES"
57-
cargo test --no-default-features --features="$NO_STD_FEATURES"
63+
# test all supported features without std
64+
cargo build --no-default-features --features="${NO_STD_FEATURES[*]}"
65+
cargo test --no-default-features --features="${NO_STD_FEATURES[*]}"

0 commit comments

Comments
 (0)