Update github actions
[kconfig-hardened-check.git] / .github / workflows / functional_test.yml
1 name: functional test
2
3 on:
4   push:
5     branches: [ master ]
6   pull_request:
7     branches: [ master ]
8
9 jobs:
10   functional_test:
11
12     runs-on: ubuntu-latest
13
14     strategy:
15       max-parallel: 1
16       fail-fast: false
17       matrix:
18         # Current ubuntu-latest (Ubuntu 22.04) provides the following versions of Python:
19         python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
20
21     steps:
22
23     - name: Set up Python ${{ matrix.python-version }}
24       uses: actions/setup-python@v5
25       with:
26         python-version: ${{ matrix.python-version }}
27
28     - name: Install package
29       run: |
30         python -m pip install --upgrade pip
31         echo "Install the package via pip..."
32         pip --verbose install git+https://github.com/a13xp0p0v/kernel-hardening-checker
33         echo "Run the installed tool..."
34         kernel-hardening-checker
35
36     - name: Check all configs with the installed tool
37       run: |
38         echo "Check all configs with the installed tool..."
39         sysctl -a > /tmp/sysctls
40         CONFIG_DIR=`find /opt/hostedtoolcache/Python/ -name config_files`
41         KCONFIGS=`find $CONFIG_DIR -type f | grep -e "\.config" -e "\.gz"`
42         COUNT=0
43         for C in $KCONFIGS
44         do
45                 COUNT=$(expr $COUNT + 1)
46                 echo -e "\n>>>>> checking kconfig number $COUNT <<<<<"
47                 kernel-hardening-checker -c $C -l /proc/cmdline -s /tmp/sysctls
48         done
49         echo -e "\nHave checked $COUNT kconfigs"
50
51     - name: Get source code for collecting coverage
52       uses: actions/checkout@v4
53
54     - name: Run the functional tests and collect the coverage
55       run: |
56         pip install coverage
57         sh .github/workflows/functional_test.sh
58
59     - name: Prepare final coverage report
60       run: |
61         coverage xml -i -o coverage.xml
62
63     - name: Handle coverage
64       uses: codecov/codecov-action@v3
65       with:
66         files: ./coverage.xml
67         flags: functional_test
68         name: functional_test_upload
69         fail_ci_if_error: true
70         verbose: true