Skip to content

Commit 15763f2

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 7fb4f1c + f5fd778 commit 15763f2

File tree

9 files changed

+217
-71
lines changed

9 files changed

+217
-71
lines changed

.github/workflows/ci.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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.32.0, # rand
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:
40+
name: No Std
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 "libm rand serde"
57+
58+
fmt:
59+
name: Format
60+
runs-on: ubuntu-latest
61+
steps:
62+
- name: Rust install
63+
uses: actions-rs/toolchain@v1
64+
with:
65+
toolchain: 1.42.0
66+
profile: minimal
67+
override: true
68+
components: rustfmt
69+
- name: Checkout
70+
uses: actions/checkout@v2
71+
- name: Check formatting
72+
uses: actions-rs/cargo@v1
73+
with:
74+
command: fmt
75+
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 & 36 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-complex"
1010
repository = "https://github.com/rust-num/num-complex"
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-complex.svg)](https://crates.io/crates/num-complex)
44
[![documentation](https://docs.rs/num-complex/badge.svg)](https://docs.rs/num-complex)
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-complex.svg?branch=master)](https://travis-ci.org/rust-num/num-complex)
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-complex/workflows/master/badge.svg)](https://github.com/rust-num/num-complex/actions)
77

88
`Complex` numbers for Rust.
99

bors.toml

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

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 1.32.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.32.0 stable beta nightly; do
9+
rustup run "$version" "$ci/test_full.sh"
1210
done

ci/test_full.sh

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,58 @@
11
#!/bin/bash
22

3-
set -ex
4-
5-
echo Testing num-complex on rustc ${TRAVIS_RUST_VERSION}
6-
7-
case "$TRAVIS_RUST_VERSION" in
8-
1.31.*) FEATURES="libm serde" ;;
9-
*) FEATURES="libm serde rand" ;;
10-
esac
11-
12-
# num-complex should build and test everywhere.
13-
cargo build --verbose
14-
cargo test --verbose
15-
16-
# It should build with minimal features too.
3+
set -e
4+
5+
CRATE=num-complex
6+
MSRV=1.31
7+
8+
get_rust_version() {
9+
local array=($(rustc --version));
10+
echo "${array[1]}";
11+
return 0;
12+
}
13+
RUST_VERSION=$(get_rust_version)
14+
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+
}
23+
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
28+
fi
29+
30+
FEATURES=(libm serde)
31+
check_version 1.32 && FEATURES+=(rand)
32+
echo "Testing supported features: ${FEATURES[*]}"
33+
34+
set -x
35+
36+
# test the default
37+
cargo build
38+
cargo test
39+
40+
# test `no_std`
1741
cargo build --no-default-features
1842
cargo test --no-default-features
1943

20-
# Each isolated feature should also work everywhere.
21-
for feature in $FEATURES; do
22-
cargo build --verbose --no-default-features --features="$feature"
23-
cargo test --verbose --no-default-features --features="$feature"
44+
# test each isolated feature, with and without std
45+
for feature in ${FEATURES[*]}; do
46+
cargo build --no-default-features --features="std $feature"
47+
cargo test --no-default-features --features="std $feature"
48+
49+
cargo build --no-default-features --features="$feature"
50+
cargo test --no-default-features --features="$feature"
2451
done
2552

26-
# test all supported features together
27-
cargo build --features="$FEATURES"
28-
cargo test --features="$FEATURES"
53+
# test all supported features, with and without std
54+
cargo build --features="std ${FEATURES[*]}"
55+
cargo test --features="std ${FEATURES[*]}"
2956

30-
# test all supported features together with std
31-
cargo build --features="std $FEATURES"
32-
cargo test --features="std $FEATURES"
57+
cargo build --features="${FEATURES[*]}"
58+
cargo test --features="${FEATURES[*]}"

0 commit comments

Comments
 (0)