Debian Codegraph @

.github/workflows/reusable-unit-tests.yml

raw symbols SCIP
1 name: reusable unit tests
2
3 on:
4 workflow_call:
5 inputs:
6 python-version:
7 type: string
8 required: true
9 branch:
10 type: string
11 required: false
12 secrets:
13 CODECOV_TOKEN:
14 required: false
15
16 jobs:
17 build:
18 runs-on: ubuntu-24.04
19 continue-on-error: false
20 steps:
21 - uses: actions/checkout@v4
22 with:
23 ref: ${{ inputs.branch }}
24 - name: Set up Python ${{ inputs.python-version }}
25 uses: actions/setup-python@v5
26 with:
27 python-version: ${{ inputs.python-version }}
28 - uses: actions/cache@v4
29 with:
30 path: ~/.cache/pip
31 key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
32 restore-keys: |
33 ${{ runner.os }}-pip-
34 - name: Install system dependencies
35 run: |
36 sudo apt-get install -yq libow-dev openssh-server openssh-client graphviz openocd
37 sudo mkdir -p /var/cache/labgrid/runner && sudo chown runner /var/cache/labgrid/runner
38 - name: Prepare local SSH
39 run: |
40 # the default of 777 is too open for SSH
41 chmod 755 ~
42 ssh-keygen -f ~/.ssh/id_ed25519.local -t ed25519 -N ""
43 cat ~/.ssh/id_ed25519.local.pub >> ~/.ssh/authorized_keys
44 echo -e "Host localhost ip6-localhost\n Hostname 127.0.0.1\n IdentityFile ~/.ssh/id_ed25519.local\n UserKnownHostsFile ~/.ssh/known_hosts.local" >> ~/.ssh/config
45 ssh -o StrictHostKeyChecking=no localhost echo OK
46 - name: Enable unprivileged user namespaces
47 run: |
48 sudo sysctl kernel.unprivileged_userns_clone=1
49 unshare -Un true
50 - name: Install python dependencies
51 run: |
52 python -m pip install --upgrade pip virtualenv
53 - name: Install labgrid
54 run: |
55 pip install -e ".[dev]"
56 - name: Lint with pylint
57 run: |
58 pylint --list-msgs-enabled
59 pylint labgrid
60 - name: Format with ruff
61 run: |
62 ruff format --check --diff
63 - name: Test with pytest
64 run: |
65 pytest -r a --cov-config .coveragerc --cov=labgrid --junitxml=junit.xml -o junit_family=legacy --local-sshmanager --ssh-username runner -k "not test_docker_with_daemon"
66 - name: Upload coverage to Codecov
67 uses: codecov/codecov-action@v4
68 with:
69 token: ${{ secrets.CODECOV_TOKEN }}
70 flags: ${{ inputs.python-version }}
71 - name: Upload test results to Codecov
72 if: ${{ !cancelled() }}
73 uses: codecov/test-results-action@v1
74 with:
75 token: ${{ secrets.CODECOV_TOKEN }}
76 flags: ${{ inputs.python-version }}
77 - name: Build documentation
78 run: |
79 make -C doc clean
80 make -C doc doctest SPHINXOPTS=-W
81 make -C doc html SPHINXOPTS=-W
82 make -C man clean
83 make -C man all
84 git --no-pager diff --exit-code
85 # check README.rst separately
86 pip install rstcheck
87 rstcheck --ignore-languages=bash --report-level=WARNING README.rst