Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch CI to GitHub Actions #33

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: CI
on:
push:
branches:
- staging
- trying

jobs:

test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.8.0, 1.15.0, 1.20.0, 1.26.0, 1.31.0, stable, beta, nightly]
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Checkout
uses: actions/checkout@v2
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
- name: Test
run: ./ci/test_full.sh

# try a target that doesn't have std at all
no_std:
name: No Std
runs-on: ubuntu-latest
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: thumbv6m-none-eabi
- name: Checkout
uses: actions/checkout@v1
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --target thumbv6m-none-eabi --no-default-features --features i128

fmt:
name: Format
runs-on: ubuntu-latest
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: 1.42.0
profile: minimal
override: true
components: rustfmt
- name: Checkout
uses: actions/checkout@v2
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
31 changes: 31 additions & 0 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: master
on:
push:
branches:
- master
schedule:
- cron: '0 0 * * 0' # 00:00 Sunday

jobs:

test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.8.0, stable]
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Checkout
uses: actions/checkout@v2
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
- name: Test
run: ./ci/test_full.sh
46 changes: 46 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: PR
on:
pull_request:

jobs:

test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.8.0, stable]
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Checkout
uses: actions/checkout@v2
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
- name: Test
run: ./ci/test_full.sh

fmt:
name: Format
runs-on: ubuntu-latest
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: 1.42.0
profile: minimal
override: true
components: rustfmt
- name: Checkout
uses: actions/checkout@v2
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name = "num-integer"
version = "0.1.42"
readme = "README.md"
build = "build.rs"
exclude = ["/ci/*", "/.travis.yml", "/bors.toml"]
exclude = ["/bors.toml", "/ci/*", "/.github/*"]

[package.metadata.docs.rs]
features = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![crate](https://img.shields.io/crates/v/num-integer.svg)](https://crates.io/crates/num-integer)
[![documentation](https://docs.rs/num-integer/badge.svg)](https://docs.rs/num-integer)
![minimum rustc 1.8](https://img.shields.io/badge/rustc-1.8+-red.svg)
[![Travis status](https://travis-ci.org/rust-num/num-integer.svg?branch=master)](https://travis-ci.org/rust-num/num-integer)
![build status](https://github.com/rust-num/num-integer/workflows/master/badge.svg)

`Integer` trait and functions for Rust.

Expand Down
11 changes: 10 additions & 1 deletion bors.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
status = [
"continuous-integration/travis-ci/push",
"Test (1.8.0)",
"Test (1.15.0)",
"Test (1.20.0)",
"Test (1.26.0)",
"Test (1.31.0)",
"Test (stable)",
"Test (beta)",
"Test (nightly)",
"No Std",
"Format",
]
12 changes: 5 additions & 7 deletions ci/rustup.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/bin/sh
# Use rustup to locally run the same suite of tests as .travis.yml.
# (You should first install/update 1.8.0, stable, beta, and nightly.)
# Use rustup to locally run the same suite of tests as .github/workflows/
# (You should first install/update all of the versions below.)

set -ex

export TRAVIS_RUST_VERSION
for TRAVIS_RUST_VERSION in 1.8.0 1.15.0 1.20.0 stable beta nightly; do
run="rustup run $TRAVIS_RUST_VERSION"
$run cargo build --verbose
$run $PWD/ci/test_full.sh
ci=$(dirname $0)
for version in 1.8.0 1.15.0 1.20.0 1.26.0 1.31.0 stable beta nightly; do
rustup run "$version" "$ci/test_full.sh"
done
67 changes: 53 additions & 14 deletions ci/test_full.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,62 @@
#!/bin/bash

set -ex
set -e

echo Testing num-integer on rustc ${TRAVIS_RUST_VERSION}
CRATE=num-integer
MSRV=1.8

# num-integer should build and test everywhere.
cargo build --verbose
cargo test --verbose
get_rust_version() {
local array=($(rustc --version));
echo "${array[1]}";
return 0;
}
RUST_VERSION=$(get_rust_version)

# test `no_std`
cargo build --verbose --no-default-features
cargo test --verbose --no-default-features
check_version() {
IFS=. read -ra rust <<< "$RUST_VERSION"
IFS=. read -ra want <<< "$1"
[[ "${rust[0]}" -gt "${want[0]}" ||
( "${rust[0]}" -eq "${want[0]}" &&
"${rust[1]}" -ge "${want[1]}" )
]]
}

# test `i128`
if [[ "$TRAVIS_RUST_VERSION" =~ ^(nightly|beta|stable)$ ]]; then
cargo build --verbose --features=i128
cargo test --verbose --features=i128
echo "Testing $CRATE on rustc $RUST_VERSION"
if ! check_version $MSRV ; then
echo "The minimum for $CRATE is rustc $MSRV"
exit 1
fi

if [[ "$TRAVIS_RUST_VERSION" == "nightly" ]]; then
cargo test --verbose --all-features --benches
FEATURES=()
check_version 1.26 && FEATURES+=(i128)
echo "Testing supported features: ${FEATURES[*]}"

set -x

# test the default
cargo build
cargo test

# test `no_std`
cargo build --no-default-features
cargo test --no-default-features

# test each isolated feature, with and without std
for feature in ${FEATURES[*]}; do
cargo build --no-default-features --features="std $feature"
cargo test --no-default-features --features="std $feature"

cargo build --no-default-features --features="$feature"
cargo test --no-default-features --features="$feature"
done

# test all supported features, with and without std
cargo build --features="std ${FEATURES[*]}"
cargo test --features="std ${FEATURES[*]}"

cargo build --features="${FEATURES[*]}"
cargo test --features="${FEATURES[*]}"

if rustc --version | grep -q nightly; then
cargo test --all-features --benches
fi