diff --git a/.github/workflows/cargo-clippy.yml b/.github/workflows/cargo-clippy.yml new file mode 100644 index 0000000..acef88d --- /dev/null +++ b/.github/workflows/cargo-clippy.yml @@ -0,0 +1,20 @@ +name: Cargo Clippy + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Make clippy happy + run: cargo clippy diff --git a/.github/workflows/cargo-cross-build.yml b/.github/workflows/cargo-cross-build.yml new file mode 100644 index 0000000..13bf85b --- /dev/null +++ b/.github/workflows/cargo-cross-build.yml @@ -0,0 +1,58 @@ +name: Cargo Cross Build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + rust: [stable] + target: + - aarch64-unknown-linux-gnu + - i686-pc-windows-gnu + - i686-pc-windows-msvc + - i686-unknown-linux-gnu + - aarch64-apple-darwin + - aarch64-pc-windows-msvc + - aarch64-unknown-linux-musl + - arm-unknown-linux-gnueabi + - arm-unknown-linux-gnueabihf + - armv7-unknown-linux-gnueabihf + - mips-unknown-linux-gnu + - mips64-unknown-linux-gnuabi64 + - mips64el-unknown-linux-gnuabi64 + - mipsel-unknown-linux-gnu + - powerpc-unknown-linux-gnu + - powerpc64-unknown-linux-gnu + - powerpc64le-unknown-linux-gnu + - riscv64gc-unknown-linux-gnu + - s390x-unknown-linux-gnu + - x86_64-unknown-freebsd + - x86_64-unknown-illumos + - x86_64-unknown-netbsd + - i686-linux-android + - x86_64-linux-android + - arm-linux-androideabi + - aarch64-linux-android + - x86_64-apple-ios + - asmjs-unknown-emscripten + - aarch64-apple-ios + - aarch64-apple-ios-sim + + steps: + - uses: actions/checkout@v2 + - name: Run build + run: | + rustup default ${{ matrix.rust }} + rustup target add ${{ matrix.target }} + cargo build --verbose --target ${{ matrix.target }} diff --git a/.github/workflows/cargo-test-linux.yml b/.github/workflows/cargo-test-linux.yml new file mode 100644 index 0000000..6db3aa3 --- /dev/null +++ b/.github/workflows/cargo-test-linux.yml @@ -0,0 +1,28 @@ +name: Cargo Test Linux + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + rust: [stable, beta, nightly] + target: [x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl] + + steps: + - uses: actions/checkout@v2 + - name: Run tests + run: | + rustup default ${{ matrix.rust }} + rustup target add ${{ matrix.target }} + cargo test --verbose --target ${{ matrix.target }} diff --git a/.github/workflows/cargo-test-macos.yml b/.github/workflows/cargo-test-macos.yml new file mode 100644 index 0000000..c3cf500 --- /dev/null +++ b/.github/workflows/cargo-test-macos.yml @@ -0,0 +1,28 @@ +name: Cargo Test macOS + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: macos-latest + + strategy: + matrix: + rust: [stable, beta, nightly] + target: [x86_64-apple-darwin, x86_64-apple-ios, aarch64-apple-darwin] + + steps: + - uses: actions/checkout@v2 + - name: Run tests + run: | + rustup default ${{ martix.rust }} + rustup target add ${{ matrix.target }} + cargo test --verbose --target ${{ matrix.target }} diff --git a/.github/workflows/cargo-test-minimum-rust.yml b/.github/workflows/cargo-test-minimum-rust.yml new file mode 100644 index 0000000..785672c --- /dev/null +++ b/.github/workflows/cargo-test-minimum-rust.yml @@ -0,0 +1,28 @@ +name: Cargo Test Minimum Rust Version + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + rust: [1.13] + target: [x86_64-unknown-linux-gnu] + + steps: + - uses: actions/checkout@v2 + - name: Run tests + run: | + rustup default ${{ matrix.rust }} + rustup target add ${{ matrix.target }} + cargo test --verbose --target ${{ matrix.target }} diff --git a/.github/workflows/cargo-test-windows.yml b/.github/workflows/cargo-test-windows.yml new file mode 100644 index 0000000..3c563ca --- /dev/null +++ b/.github/workflows/cargo-test-windows.yml @@ -0,0 +1,28 @@ +name: Cargo Test Windows + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: windows-latest + + strategy: + matrix: + rust: [stable, beta, nightly] + target: [x86_64-pc-windows-gnu, x86_64-pc-windows-msvc] + + steps: + - uses: actions/checkout@v2 + - name: Run tests + run: | + rustup default ${{ matrix.rust }} + rustup target add ${{ matrix.target }} + cargo test --verbose --target ${{ matrix.target }} diff --git a/.github/workflows/test-docker-cgroup.yml b/.github/workflows/test-docker-cgroup.yml new file mode 100644 index 0000000..bc27b80 --- /dev/null +++ b/.github/workflows/test-docker-cgroup.yml @@ -0,0 +1,27 @@ +name: Test Docker Cgroup + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Test Cgroup + run: | + docker build -f ci/cgroups/Dockerfile -t num-cpus-cgroups . + # Test without cgroups + docker run -e NUM_CPUS_TEST_GET=2 num-cpus-cgroups + # Only 1 CPU + docker run --cpus="1" -e NUM_CPUS_TEST_GET=1 num-cpus-cgroups + # 1.5 CPUs + docker run --cpus="1.5" -e NUM_CPUS_TEST_GET=2 num-cpus-cgroups diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cec6ddb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,81 +0,0 @@ -language: rust -rust: stable -dist: xenial -sudo: false -notifications: - email: disabled - -cache: cargo - -install: - - if [ -z "$NO_ADD" ]; then rustup target add "$TARGET"; fi - -script: - - cargo build --verbose --target "$TARGET" - # Only run the targets if we are on the same OS. - - if [ "$RUN" == "1" ]; then cargo test --verbose --target "$TARGET"; fi - -env: - global: - # Travis CI servers make 2 cores available to processes via virtualization. - # See https://docs.travis-ci.com/user/reference/overview/ - - NUM_CPUS_TEST_GET=2 - -matrix: - include: - # Linux - # Minimum Supported Rust Version - - name: Minimum Supported Rust Version - env: TARGET=x86_64-unknown-linux-gnu RUN=1 NO_ADD=1 - rust: 1.13.0 - # 32-bit requires multilib. - - env: TARGET=i686-unknown-linux-gnu RUN=1 - addons: - apt: - packages: - - gcc-multilib - # 64-bit stable. - - env: TARGET=x86_64-unknown-linux-gnu RUN=1 NO_ADD=1 - rust: stable - # 64-bit beta. - - env: TARGET=x86_64-unknown-linux-gnu RUN=1 NO_ADD=1 - rust: beta - # 64-bit nightly. - - env: TARGET=x86_64-unknown-linux-gnu RUN=1 NO_ADD=1 - rust: nightly - - # Mac OS X - - os: osx - env: TARGET=x86_64-apple-darwin RUN=1 NO_ADD=1 - # Android - # - for x86 - - env: TARGET=i686-linux-android - - env: TARGET=x86_64-linux-android - # - for ARM - - env: TARGET=arm-linux-androideabi - - env: TARGET=aarch64-linux-android - # IOS - - os: osx - osx_image: xcode9 - env: TARGET=x86_64-apple-ios - # FreeBSD - - env: TARGET=x86_64-unknown-freebsd - # Fuchsia - # FIXME: figure out why target is missing and re-enable - #- env: TARGET=x86_64-unknown-fuchsia - # NetBSD - - env: TARGET=x86_64-unknown-netbsd - # Emscripten - - env: TARGET=asmjs-unknown-emscripten - - # CGroups in Docker - - name: Docker CGroups - install: - script: - - docker build -f ci/cgroups/Dockerfile -t num-cpus-cgroups . - # Test without cgroups - - docker run -it -e NUM_CPUS_TEST_GET=2 num-cpus-cgroups - # Only 1 CPU - - docker run -it --cpus="1" -e NUM_CPUS_TEST_GET=1 num-cpus-cgroups - # 1.5 CPUs - - docker run -it --cpus="1.5" -e NUM_CPUS_TEST_GET=2 num-cpus-cgroups diff --git a/ci/cgroups/Dockerfile b/ci/cgroups/Dockerfile index d5f288a..7636a47 100644 --- a/ci/cgroups/Dockerfile +++ b/ci/cgroups/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.40 +FROM rust:latest WORKDIR /usr/num_cpus