aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: 36dc5b9c1523a891efbdd6d3f6426b68059a74e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: CI
on:
  pull_request:
  push:
    branches:
      - master

env:
  RUST_BACKTRACE: 1
  CARGO_TERM_COLOR: always

jobs:
  ci-pass:
    name: CI is green
    runs-on: ubuntu-latest
    needs:
      - msrv
      - test-linux
      - test-macos
      - test-windows
      - build-cross
      - test-cgroups
    steps:
      - run: exit 0

  msrv:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        rust:
          - 1.13
        target:
          - x86_64-unknown-linux-gnu

    steps:
    - uses: actions/checkout@v3
    - name: Run tests
      run: |
        rustup default ${{ matrix.rust }}
        rustup target add ${{ matrix.target }}
        cargo test --verbose --target ${{ matrix.target }}

  test-linux:
    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@v3
    - name: Run tests
      run: |
        rustup default ${{ matrix.rust }}
        rustup target add ${{ matrix.target }}
        cargo test --verbose --target ${{ matrix.target }}

  test-macos:
    runs-on: macos-latest

    strategy:
      matrix:
        rust:
          - stable
          - beta
          - nightly
        target:
          - x86_64-apple-darwin

    steps:
    - uses: actions/checkout@v3
    - name: Run tests
      run: |
        rustup default ${{ matrix.rust }}
        rustup target add ${{ matrix.target }}
        cargo test --verbose --target ${{ matrix.target }}

  test-windows:
    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@v3
    - name: Run tests
      run: |
        rustup default ${{ matrix.rust }}
        rustup target add ${{ matrix.target }}
        cargo test --verbose --target ${{ matrix.target }}

  build-cross:
    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
          - aarch64-apple-darwin
    steps:
    - uses: actions/checkout@v3
    - name: Run build
      run: |
        rustup default ${{ matrix.rust }}
        rustup target add ${{ matrix.target }}
        cargo build --verbose --target ${{ matrix.target }}

  test-cgroups:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - 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