Skip to content

Commit

Permalink
add docker cgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWhiteWu committed Oct 27, 2021
1 parent a8b3ccc commit c4c81c9
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 9 deletions.
20 changes: 20 additions & 0 deletions .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
12 changes: 9 additions & 3 deletions .github/workflows/cargo-test-linux.yml
Expand Up @@ -14,9 +14,15 @@ jobs:

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: Make clippy happy
run: cargo clippy
- name: Run tests
run: cargo test --verbose
run: |
rustup default ${{ matrix.rust }}
rustup target add ${{ matrix.target }}
cargo test --verbose --target ${{ matrix.target }}
12 changes: 9 additions & 3 deletions .github/workflows/cargo-test-macos.yml
Expand Up @@ -14,9 +14,15 @@ jobs:

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: Make clippy happy
run: cargo clippy
- name: Run tests
run: cargo test --verbose
run: |
rustup default ${{ martix.rust }}
rustup target add ${{ matrix.target }}
cargo test --verbose --target ${{ matrix.target }}
28 changes: 28 additions & 0 deletions .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 }}
12 changes: 9 additions & 3 deletions .github/workflows/cargo-test-windows.yml
Expand Up @@ -14,9 +14,15 @@ jobs:

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: Make clippy happy
run: cargo clippy
- name: Run tests
run: cargo test --verbose
run: |
rustup default ${{ matrix.rust }}
rustup target add ${{ matrix.target }}
cargo test --verbose --target ${{ matrix.target }}
27 changes: 27 additions & 0 deletions .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
9 changes: 9 additions & 0 deletions ci/cgroups/Dockerfile
@@ -0,0 +1,9 @@
FROM rust:latest

WORKDIR /usr/num_cpus

COPY . .

RUN cargo build

CMD [ "cargo", "test", "--lib" ]

0 comments on commit c4c81c9

Please sign in to comment.