name: reusable unit tests on: workflow_call: inputs: python-version: type: string required: true branch: type: string required: false secrets: CODECOV_TOKEN: required: false jobs: build: runs-on: ubuntu-24.04 continue-on-error: false steps: - uses: actions/checkout@v4 with: ref: ${{ inputs.branch }} - name: Set up Python ${{ inputs.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} - uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }} restore-keys: | ${{ runner.os }}-pip- - name: Install system dependencies run: | sudo apt-get install -yq libow-dev openssh-server openssh-client graphviz openocd sudo mkdir -p /var/cache/labgrid/runner && sudo chown runner /var/cache/labgrid/runner - name: Prepare local SSH run: | # the default of 777 is too open for SSH chmod 755 ~ ssh-keygen -f ~/.ssh/id_ed25519.local -t ed25519 -N "" cat ~/.ssh/id_ed25519.local.pub >> ~/.ssh/authorized_keys 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 ssh -o StrictHostKeyChecking=no localhost echo OK - name: Enable unprivileged user namespaces run: | sudo sysctl kernel.unprivileged_userns_clone=1 unshare -Un true - name: Install python dependencies run: | python -m pip install --upgrade pip virtualenv - name: Install labgrid run: | pip install -e ".[dev]" - name: Lint with pylint run: | pylint --list-msgs-enabled pylint labgrid - name: Format with ruff run: | ruff format --check --diff - name: Test with pytest run: | 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" - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} flags: ${{ inputs.python-version }} - name: Upload test results to Codecov if: ${{ !cancelled() }} uses: codecov/test-results-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} flags: ${{ inputs.python-version }} - name: Build documentation run: | make -C doc clean make -C doc doctest SPHINXOPTS=-W make -C doc html SPHINXOPTS=-W make -C man clean make -C man all git --no-pager diff --exit-code # check README.rst separately pip install rstcheck rstcheck --ignore-languages=bash --report-level=WARNING README.rst