• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: BCC Build and tests
2
3on:
4  push:
5    branches:
6      - master
7  pull_request:
8
9env:
10  # Use docker.io for Docker Hub if empty
11  REGISTRY: ghcr.io
12  # github.repository as <account>/<repo>
13  IMAGE_NAME: ${{ github.repository }}
14
15permissions:
16  contents: read # to fetch code (actions/checkout)
17  pull-requests: read # to read pull requests (dorny/paths-filter)
18
19jobs:
20  test_bcc:
21    runs-on: ubuntu-20.04
22    strategy:
23      matrix:
24        os: [{distro: "ubuntu", version: "18.04", nick: bionic}, {distro: "ubuntu", version: "20.04", nick: focal}]
25        env:
26        - TYPE: Debug
27          PYTHON_TEST_LOGFILE: critical.log
28          RW_ENGINE_ENABLED: ON
29        - TYPE: Debug
30          PYTHON_TEST_LOGFILE: critical.log
31          RW_ENGINE_ENABLED: OFF
32        - TYPE: Release
33          PYTHON_TEST_LOGFILE: critical.log
34          RW_ENGINE_ENABLED: ON
35    steps:
36    - uses: actions/checkout@v2
37    - uses: dorny/paths-filter@v2
38      id: changes
39      with:
40        filters: |
41          docker:
42            - 'docker/build/**'
43    - name: System info
44      run: |
45        uname -a
46        ip addr
47    - name: Pull docker container
48      if: steps.changes.outputs.docker == 'false'
49      run: |
50        docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os.distro }}-${{ matrix.os.version }}
51    - name: Build docker container
52      if: steps.changes.outputs.docker == 'true'
53      uses: ./.github/actions/build-container
54      with:
55        os_distro: ${{ matrix.os.distro }}
56        os_version: ${{ matrix.os.version }}
57        os_nick: ${{ matrix.os.nick }}
58    - name: Tag docker container
59      run: |
60        docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os.distro }}-${{ matrix.os.version }} bcc-docker
61    - name: Run bcc build
62      env: ${{ matrix.env }}
63      run: |
64        /bin/bash -c \
65                   "docker run --privileged \
66                   --pid=host \
67                   -v $(pwd):/bcc \
68                   -v /sys/kernel/debug:/sys/kernel/debug:rw \
69                   -v /lib/modules:/lib/modules:ro \
70                   -v /usr/src:/usr/src:ro \
71                   -v /usr/include/linux:/usr/include/linux:ro \
72                   bcc-docker \
73                   /bin/bash -c \
74                   'mkdir -p /bcc/build && cd /bcc/build && \
75                    cmake -DCMAKE_BUILD_TYPE=${TYPE} -DENABLE_LLVM_NATIVECODEGEN=${RW_ENGINE_ENABLED} .. && make -j9'"
76    - name: Run bcc's cc tests
77      env: ${{ matrix.env }}
78      # tests are wrapped with `script` as a hack to get a TTY as github actions doesn't provide this
79      # see https://github.com/actions/runner/issues/241
80      run: |
81        script -e -c /bin/bash -c \
82        "docker run -ti \
83                    --privileged \
84                    --network=host \
85                    --pid=host \
86                    -v $(pwd):/bcc \
87                    -v /sys/kernel/debug:/sys/kernel/debug:rw \
88                    -v /lib/modules:/lib/modules:ro \
89                    -v /usr/src:/usr/src:ro \
90                    -e CTEST_OUTPUT_ON_FAILURE=1 \
91                    bcc-docker \
92                    /bin/bash -c \
93                    '/bcc/build/tests/wrapper.sh \
94                        c_test_all sudo /bcc/build/tests/cc/test_libbcc'"
95
96    - name: Run all tests
97      env: ${{ matrix.env }}
98      run: |
99        script -e -c /bin/bash -c \
100        "docker run -ti \
101                    --privileged \
102                    --network=host \
103                    --pid=host \
104                    -v $(pwd):/bcc \
105                    -v /sys/kernel/debug:/sys/kernel/debug:rw \
106                    -v /lib/modules:/lib/modules:ro \
107                    -v /usr/src:/usr/src:ro \
108                    -e CTEST_OUTPUT_ON_FAILURE=1 \
109                    bcc-docker \
110                    /bin/bash -c \
111                    'cd /bcc/build && \
112                     make test PYTHON_TEST_LOGFILE=$PYTHON_TEST_LOGFILE ARGS=-V'"
113
114    - name: Check critical tests
115      env: ${{ matrix.env }}
116      run: |
117        critical_count=$(grep @mayFail tests/python/critical.log | wc -l)
118        echo "There were $critical_count critical tests skipped with @mayFail:"
119        grep -A2 @mayFail tests/python/critical.log
120
121    - uses: actions/upload-artifact@v1
122      with:
123        name: critical-tests-${{ matrix.env['TYPE'] }}-${{ matrix.os.version }}
124        path: tests/python/critical.log
125
126  test_bcc_fedora:
127    runs-on: ubuntu-20.04
128    strategy:
129      matrix:
130        os: [{distro: "fedora", version: "34", nick: "f34"}, {distro: "fedora", version: "36", nick: "f36"}]
131        env:
132        - TYPE: Debug
133          PYTHON_TEST_LOGFILE: critical.log
134        - TYPE: Release
135          PYTHON_TEST_LOGFILE: critical.log
136    steps:
137    - uses: actions/checkout@v2
138    - uses: dorny/paths-filter@v2
139      id: changes
140      with:
141        filters: |
142          docker:
143            - 'docker/build/**'
144    - name: System info
145      run: |
146        uname -a
147        ip addr
148    - name: Pull docker container
149      if: steps.changes.outputs.docker == 'false'
150      run: |
151        docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os.distro }}-${{ matrix.os.version }}
152    - name: Build docker container
153      if: steps.changes.outputs.docker == 'true'
154      uses: ./.github/actions/build-container
155      with:
156        os_distro: ${{ matrix.os.distro }}
157        os_version: ${{ matrix.os.version }}
158        os_nick: ${{ matrix.os.nick }}
159    - name: Tag docker container
160      run: |
161        docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os.distro }}-${{ matrix.os.version }} bcc-docker
162    - name: Run bcc build
163      env: ${{ matrix.env }}
164      run: |
165        /bin/bash -c \
166                   "docker run --privileged \
167                   --pid=host \
168                   -v $(pwd):/bcc \
169                   -v /sys/kernel/debug:/sys/kernel/debug:rw \
170                   -v /lib/modules:/lib/modules:ro \
171                   -v /usr/src:/usr/src:ro \
172                   -v /usr/include/linux:/usr/include/linux:ro \
173                   bcc-docker \
174                   /bin/bash -c \
175                   'mkdir -p /bcc/build && cd /bcc/build && \
176                    cmake -DCMAKE_BUILD_TYPE=${TYPE} -DENABLE_LLVM_SHARED=ON -DRUN_LUA_TESTS=OFF .. && make -j9'"
177    - name: Run libbpf-tools build
178      env: ${{ matrix.env }}
179      run: |
180        /bin/bash -c \
181                   "docker run --privileged \
182                   --pid=host \
183                   -v $(pwd):/bcc \
184                   -v /sys/kernel/debug:/sys/kernel/debug:rw \
185                   -v /lib/modules:/lib/modules:ro \
186                   -v /usr/src:/usr/src:ro \
187                   -v /usr/include/linux:/usr/include/linux:ro \
188                   bcc-docker \
189                   /bin/bash -c \
190                   'cd /bcc/libbpf-tools && make -j9'"
191
192    - name: Run bcc's cc tests
193      env: ${{ matrix.env }}
194      # tests are wrapped with `script` as a hack to get a TTY as github actions doesn't provide this
195      # see https://github.com/actions/runner/issues/241
196      run: |
197        script -e -c /bin/bash -c \
198        "docker run -ti \
199                    --privileged \
200                    --network=host \
201                    --pid=host \
202                    -v $(pwd):/bcc \
203                    -v /sys/kernel/debug:/sys/kernel/debug:rw \
204                    -v /lib/modules:/lib/modules:ro \
205                    -v /usr/src:/usr/src:ro \
206                    -e CTEST_OUTPUT_ON_FAILURE=1 \
207                    bcc-docker \
208                    /bin/bash -c \
209                    '/bcc/build/tests/wrapper.sh \
210                        c_test_all sudo /bcc/build/tests/cc/test_libbcc'"
211
212    - name: Run all tests
213      env: ${{ matrix.env }}
214      run: |
215        script -e -c /bin/bash -c \
216        "docker run -ti \
217                    --privileged \
218                    --network=host \
219                    --pid=host \
220                    -v $(pwd):/bcc \
221                    -v /sys/kernel/debug:/sys/kernel/debug:rw \
222                    -v /lib/modules:/lib/modules:ro \
223                    -v /usr/src:/usr/src:ro \
224                    -e CTEST_OUTPUT_ON_FAILURE=1 \
225                    bcc-docker \
226                    /bin/bash -c \
227                    'cd /bcc/build && \
228                     make test PYTHON_TEST_LOGFILE=$PYTHON_TEST_LOGFILE ARGS=-V'"
229
230    - name: Check critical tests
231      env: ${{ matrix.env }}
232      run: |
233        critical_count=$(grep @mayFail tests/python/critical.log | wc -l)
234        echo "There were $critical_count critical tests skipped with @mayFail:"
235        grep -A2 @mayFail tests/python/critical.log
236
237
238# To debug weird issues, you can add this step to be able to SSH to the test environment
239#     https://github.com/marketplace/actions/debugging-with-tmate
240#    - name: Setup tmate session
241#      uses: mxschmitt/action-tmate@v1
242