Browse Source

Switch CI to GitHub Actions

Josh Stone 4 years ago
parent
commit
84c7f2a895
8 changed files with 240 additions and 73 deletions
  1. 99 0
      .github/workflows/ci.yaml
  2. 32 0
      .github/workflows/master.yaml
  3. 47 0
      .github/workflows/pr.yaml
  4. 0 52
      .travis.yml
  5. 1 1
      Cargo.toml
  6. 11 1
      bors.toml
  7. 4 5
      ci/rustup.sh
  8. 46 14
      ci/test_full.sh

+ 99 - 0
.github/workflows/ci.yaml

@@ -0,0 +1,99 @@
+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
+          args: --verbose
+      - name: Test
+        run: ./ci/test_full.sh
+
+  # i586 presents floating point challenges for lack of SSE/SSE2
+  i586:
+    name: Test (i586)
+    runs-on: ubuntu-latest
+    steps:
+      - name: System install
+        run: |
+          sudo apt-get update
+          sudo apt-get install gcc-multilib
+      - name: Rust install
+        uses: actions-rs/toolchain@v1
+        with:
+          toolchain: stable
+          profile: minimal
+          override: true
+          target: i586-unknown-linux-gnu
+      - name: Checkout
+        uses: actions/checkout@v1
+      - name: Test
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --verbose --target i586-unknown-linux-gnu --all-features
+
+  # 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: --verbose --target thumbv6m-none-eabi --no-default-features --features i128
+      - name: Build (libm)
+        uses: actions-rs/cargo@v1
+        with:
+          command: build
+          args: --verbose --target thumbv6m-none-eabi --no-default-features --features libm
+
+  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

+ 32 - 0
.github/workflows/master.yaml

@@ -0,0 +1,32 @@
+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
+          args: --verbose
+      - name: Test
+        run: ./ci/test_full.sh

+ 47 - 0
.github/workflows/pr.yaml

@@ -0,0 +1,47 @@
+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
+          args: --verbose
+      - 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

+ 0 - 52
.travis.yml

@@ -1,52 +0,0 @@
-language: rust
-sudo: false
-rust:
-  - 1.8.0
-  - 1.15.0
-  - 1.20.0
-  - 1.26.0 # has_i128
-  - 1.31.0 # 2018!
-  - stable
-  - beta
-  - nightly
-script:
-  - cargo build --verbose
-  - ./ci/test_full.sh
-matrix:
-  include:
-    # i586 presents floating point challenges for lack of SSE/SSE2
-    - name: "i586"
-      rust: stable
-      env: TARGET=i586-unknown-linux-gnu
-      addons:
-        apt:
-          packages:
-            - gcc-multilib
-      before_script:
-        - rustup target add $TARGET
-      script:
-        - cargo test --verbose --target $TARGET --all-features
-    # try a target that doesn't have std at all
-    - name: "no_std"
-      rust: stable
-      env: TARGET=thumbv6m-none-eabi
-      before_script:
-        - rustup target add $TARGET
-      script:
-        - cargo build --verbose --target $TARGET --no-default-features --features i128
-        - cargo build --verbose --target $TARGET --no-default-features --features libm
-    - name: "rustfmt"
-      rust: 1.31.0
-      before_script:
-        - rustup component add rustfmt
-      script:
-        - cargo fmt --all -- --check
-notifications:
-  email:
-    on_success: never
-branches:
-  only:
-    - master
-    - next
-    - staging
-    - trying

+ 1 - 1
Cargo.toml

@@ -11,7 +11,7 @@ name = "num-traits"
 version = "0.2.11"
 readme = "README.md"
 build = "build.rs"
-exclude = ["/ci/*", "/.travis.yml", "/bors.toml"]
+exclude = ["/bors.toml", "/ci/*", "/.github/*"]
 
 [package.metadata.docs.rs]
 features = ["std"]

+ 11 - 1
bors.toml

@@ -1,3 +1,13 @@
 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)",
+  "Test (i586)",
+  "No Std",
+  "Format",
 ]

+ 4 - 5
ci/rustup.sh

@@ -1,11 +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.)
+# (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 $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

+ 46 - 14
ci/test_full.sh

@@ -1,10 +1,40 @@
 #!/bin/bash
 
-set -ex
+set -e
 
-echo Testing num-traits on rustc ${TRAVIS_RUST_VERSION}
+CRATE=num-traits
+MSRV=1.8
 
-# num-traits should build and test everywhere.
+get_rust_version() {
+  local array=($(rustc --version));
+  echo "${array[1]}";
+  return 0;
+}
+RUST_VERSION=$(get_rust_version)
+
+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]}" )
+  ]]
+}
+
+echo "Testing $CRATE on rustc $RUST_VERSION"
+if ! check_version $MSRV ; then
+  echo "The minimum for $CRATE is rustc $MSRV"
+  exit 1
+fi
+
+FEATURES=()
+check_version 1.26 && FEATURES+=(i128)
+check_version 1.27 && FEATURES+=(libm)
+echo "Testing supported features: ${FEATURES[*]}"
+
+set -x
+
+# test the default
 cargo build --verbose
 cargo test --verbose
 
@@ -12,16 +42,18 @@ cargo test --verbose
 cargo build --verbose --no-default-features
 cargo test --verbose --no-default-features
 
-if [[ "$TRAVIS_RUST_VERSION" =~ ^(nightly|beta|stable)$ ]]; then
-    # test `i128`
-    cargo build --verbose --features=i128
-    cargo test --verbose --features=i128
+# test each isolated feature, with and without std
+for feature in ${FEATURES[*]}; do
+  cargo build --verbose --no-default-features --features="std $feature"
+  cargo test --verbose --no-default-features --features="std $feature"
 
-    # test with std and libm (libm build fails on Rust 1.26 and earlier)
-    cargo build --verbose --features "libm"
-    cargo test --verbose --features "libm"
+  cargo build --verbose --no-default-features --features="$feature"
+  cargo test --verbose --no-default-features --features="$feature"
+done
 
-    # test `no_std` with libm (libm build fails on Rust 1.26 and earlier)
-    cargo build --verbose --no-default-features --features "libm"
-    cargo test --verbose --no-default-features --features "libm"
-fi
+# 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[*]}"