update fls to 0.3.0 #2323
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Python Tests | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| merge_group: | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| jobs: | |
| changes: | |
| if: github.repository_owner == 'jumpstarter-dev' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_run: ${{ steps.filter.outputs.python }} | |
| renode_driver: ${{ steps.filter.outputs.renode_driver }} | |
| python-versions: ${{ steps.matrix.outputs.python-versions }} | |
| runners: ${{ steps.matrix.outputs.runners }} | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 | |
| with: | |
| fetch-depth: 0 | |
| - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4 | |
| id: filter | |
| with: | |
| base: ${{ github.base_ref || github.event.merge_group.base_ref || 'main' }} | |
| filters: | | |
| python: | |
| - 'python/**' | |
| - '!python/docs/**' | |
| - '!python/**/*.md' | |
| - '.github/workflows/python-tests.yaml' | |
| renode_driver: | |
| - 'python/packages/jumpstarter-driver-renode/**' | |
| - name: Compute test matrix | |
| id: matrix | |
| run: | | |
| # PRs: test only Python 3.12 on Linux to save CI time. | |
| # Merge queue and workflow_dispatch run the full matrix | |
| # (all Python versions on both Linux and macOS). | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| echo 'python-versions=["3.12"]' >> "$GITHUB_OUTPUT" | |
| echo 'runners=["ubuntu-24.04"]' >> "$GITHUB_OUTPUT" | |
| else | |
| echo 'python-versions=["3.11", "3.12", "3.13"]' >> "$GITHUB_OUTPUT" | |
| echo 'runners=["ubuntu-24.04", "macos-15"]' >> "$GITHUB_OUTPUT" | |
| fi | |
| pytest-matrix: | |
| needs: changes | |
| if: needs.changes.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch' | |
| runs-on: ${{ matrix.runs-on }} | |
| strategy: | |
| matrix: | |
| runs-on: ${{ fromJson(needs.changes.outputs.runners) }} | |
| # Floor: oldest Python in supported platforms (RHEL 9 appstream) | |
| # Ceiling: newest Python in latest Fedora | |
| # Review on each RHEL/Fedora release | |
| # PRs run only 3.12 on Linux; merge queue runs all versions | |
| # on both Linux and macOS. | |
| python-version: ${{ fromJson(needs.changes.outputs.python-versions) }} | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Free up runner disk space | |
| uses: mathio/gha-cleanup@aca3d43a05bf564f5fc69acb929a65b01797f22b # v1.1.2 | |
| with: | |
| remove-browsers: true | |
| verbose: true | |
| - id: uv | |
| run: echo "version=$(cat .uv-version)" >> "$GITHUB_OUTPUT" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 | |
| with: | |
| version: ${{ steps.uv.outputs.version }} | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install Qemu (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| echo <<EOF | sudo tee /etc/udev/rules.d/99-kvm.rules | |
| KERNEL=="kvm", GROUP="kvm", MODE="0666" | |
| KERNEL=="vhost-vsock", GROUP="kvm", MODE="0666" | |
| KERNEL=="vhost-net", GROUP="kvm", MODE="0666" | |
| EOF | |
| sudo udevadm control --reload-rules | |
| sudo modprobe vhost_vsock | |
| sudo modprobe vhost_net | |
| sudo chmod 0666 /dev/kvm /dev/vhost-vsock /dev/vhost-net | |
| sudo apt-get update | |
| sudo apt-get install -y qemu-system-arm qemu-system-x86 rpm2cpio cpio | |
| - name: Install libgpiod-dev (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libgpiod-dev liblgpio-dev | |
| - name: Install nftables and dnsmasq (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y nftables dnsmasq-base isc-dhcp-client dnsutils | |
| - name: Load kernel modules for DUT network tests (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| for mod in veth bridge nf_nat nf_conntrack nft_masq nft_nat nft_chain_nat; do | |
| sudo modprobe "$mod" 2>/dev/null || true | |
| done | |
| - name: Install Renode (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| wget https://github.com/renode/renode/releases/download/v1.16.1/renode_1.16.1_amd64.deb -O /tmp/renode.deb | |
| sudo apt-get install -y /tmp/renode.deb | |
| - name: Install Qemu (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install qemu | |
| # Homebrew Renode is slow (~5+ minutes per job). Install on macOS only when this run | |
| # touches the Renode driver, or on workflow_dispatch (full manual run). Linux still | |
| # installs Renode from the .deb in all jobs (fast). | |
| - name: Install Renode (macOS) | |
| if: >- | |
| runner.os == 'macOS' | |
| && (needs.changes.outputs.renode_driver == 'true' | |
| || github.event_name == 'workflow_dispatch') | |
| run: | | |
| brew install renode/tap/renode | |
| - name: Cache Fedora Cloud images | |
| id: cache-fedora-cloud-images | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 | |
| with: | |
| path: python/packages/jumpstarter-driver-qemu/images | |
| key: fedora-cloud-43-1.6 | |
| - name: Download Fedora Cloud images | |
| if: steps.cache-fedora-cloud-images.outputs.cache-hit != 'true' | |
| run: | | |
| for arch in aarch64 x86_64; do | |
| curl -L --fail --output "python/packages/jumpstarter-driver-qemu/images/Fedora-Cloud-Base-Generic-43-1.6.${arch}.qcow2" \ | |
| "https://iad.mirror.rackspace.com/fedora/releases/43/Cloud/${arch}/images/Fedora-Cloud-Base-Generic-43-1.6.${arch}.qcow2" | |
| done | |
| - name: Run pytest | |
| working-directory: python | |
| env: | |
| PYTEST_ADDOPTS: "--cov-report=xml --log-level=CRITICAL --log-cli-level=CRITICAL" | |
| run: | | |
| make test -j4 LOGS_DIR=${{ runner.temp }}/test-logs | |
| - name: Upload test logs | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 | |
| with: | |
| name: test-logs-${{ matrix.runs-on }}-py${{ matrix.python-version }} | |
| path: ${{ runner.temp }}/test-logs/ | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| # Diff-coverage is only checked on Linux. Several packages (e.g. | |
| # jumpstarter-driver-dut-network) are Linux-only, so their tests are | |
| # entirely skipped on macOS, making all changed lines appear uncovered | |
| # and dragging diff-coverage below the threshold. Linux runners already | |
| # enforce the 80% gate, so nothing is lost. | |
| - name: Check coverage on changed lines | |
| if: github.event_name == 'pull_request' && runner.os == 'Linux' | |
| working-directory: python | |
| run: | | |
| coverage_files=$(find packages docs/source/reference -name coverage.xml 2>/dev/null | sort) | |
| if [ -z "$coverage_files" ]; then | |
| echo "::error::No coverage.xml files found" | |
| exit 1 | |
| fi | |
| uv run diff-cover $coverage_files --compare-branch=origin/${{ github.base_ref }} --fail-under=80 --exclude '*_pb2.py' '*_pb2_grpc.py' '**/conftest.py' '**/test_*.py' '**/*_test.py' | |
| # https://github.com/orgs/community/discussions/26822 | |
| pytest: | |
| runs-on: ubuntu-latest | |
| needs: [changes, pytest-matrix] | |
| if: ${{ always() }} | |
| steps: | |
| - run: exit 1 | |
| # Fail on failures or cancellations, but allow skips when no relevant changes | |
| if: >- | |
| ${{ | |
| contains(needs.*.result, 'failure') | |
| || contains(needs.*.result, 'cancelled') | |
| || (contains(needs.*.result, 'skipped') && needs.changes.outputs.should_run == 'true') | |
| }} |