Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
parallel = True
source = cf_remote
concurrency = multiprocessing
sigterm = True
37 changes: 37 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Fetch and upload coverage

permissions:
id-token: write
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
coverage:
if: contains(fromJSON('["cfengine","mendersoftware","NorthernTechHQ"]'), github.repository_owner)
runs-on: ubuntu-latest
name: setup-python
env:
PYTHON_VERSION: "3.10"
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install requirements
run: |
python -m pip install --upgrade pip
python -m pip install uv
uv lock --check
uv sync
- name: Run tests and collect coverage
run: make coverage
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v7
with:
use_oidc: true
env:
fail_ci_if_error: true
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@ dist
/cf_remote.egg-info/
/venv
/.venv
log
__pycache__/
**/.DS_STORE

# coverage
.coverage.*
.coverage
coverage.xml
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: default format lint install check venv
.PHONY: default format lint install check venv coverage

default: check

Expand All @@ -20,3 +20,15 @@ install:

check: venv format lint
uv run pytest

export COVERAGE_PROCESS_START = $(PWD)/.coveragerc
export COVERAGE_FILE = $(PWD)/.coverage
coverage:
uv run coverage erase
uv run coverage run --parallel-mode -m pytest
uv run bash tests/shell/all.sh
uv run bash tests/docker/0*.sh
uv run bash tests/unsafe/0*.sh
uv run coverage combine
uv run coverage report --fail-under=40
uv run coverage xml
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ dev = [
"pyflakes>=3.2.0",
"pyright>=1.1.390",
"pytest>=8.3.4",
"coverage; python_version >= '3.10'",
]
9 changes: 7 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import shutil
from multiprocessing import Pool
import multiprocessing
from cf_remote.utils import has_unescaped_character, parse_envfile, copy_file


Expand Down Expand Up @@ -73,7 +73,12 @@ def test_copy_file():

num_processes = 10

with Pool(num_processes) as copy_pool:
# Use "spawn" instead of the platform-default "fork": forking a process
# that has other threads running (e.g. coverage's own writer thread) can
# deadlock intermittently if a lock is held mid-fork. Spawn starts each
# worker from a clean interpreter and avoids that.
ctx = multiprocessing.get_context("spawn")
with ctx.Pool(num_processes) as copy_pool:
copy_pool.map(copy_file_with_args, [(src, dest) for _ in range(num_processes)])

content = None
Expand Down
153 changes: 77 additions & 76 deletions uv.lock

Large diffs are not rendered by default.

Loading