Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷 Prettify build.yml and adjust coverage compute if a job isn't run #2361

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
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
23 changes: 15 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,25 @@ jobs:
- 'tests/curators/test_curator.py'

- id: set-matrix
shell: bash
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
# On push, run all
echo "matrix={\"group\":[\"unit-core\",\"unit-storage\",\"tutorial\",\"guide\",\"biology\",\"faq\",\"storage\",\"cli\",\"curator\"]}" >> $GITHUB_OUTPUT
elif [[ "${{ steps.changes.outputs.curator }}" == "true" ]]; then
# If curator paths changed, include curator
echo "matrix={\"group\":[\"unit-core\",\"unit-storage\",\"tutorial\",\"guide\",\"biology\",\"faq\",\"storage\",\"cli\",\"curator\"]}" >> $GITHUB_OUTPUT
BASE_GROUPS=$(jq -n -c '["unit-core", "unit-storage", "tutorial", "guide", "biology", "faq", "storage", "cli"]')

if [[ "${{ github.event_name }}" == "push" || "${{ steps.changes.outputs.curator }}" == "true" ]]; then
# Run everything on push or when curator paths change
MATRIX=$(jq -n -c --argjson groups "$BASE_GROUPS" '{group: ($groups + ["curator"])}')
else
# Otherwise, run all except curator
echo "matrix={\"group\":[\"unit-core\",\"unit-storage\",\"tutorial\",\"guide\",\"biology\",\"faq\",\"storage\",\"cli\"]}" >> $GITHUB_OUTPUT
# Otherwise only run base groups
MATRIX=$(jq -n -c --argjson groups "$BASE_GROUPS" '{group: $groups}')
fi

# Output as single line for GitHub Actions
echo "matrix=$(echo "$MATRIX" | jq -c .)" >> $GITHUB_OUTPUT

# Pretty print for debugging
echo "Generated matrix:"
echo "$MATRIX" | jq .

test:
needs: pre-filter
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__MACOSX/

# LaminDB
.coveragerc
*.db
*.lndb
*.jpg
Expand Down
39 changes: 38 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,43 @@ def install_ci(session, group):
)


def write_coverage_config(group: str) -> None:
"""Write a coverage config file, adding extra patterns to omit.

Args:
base_config_path: Path to the base config file (e.g. pyproject.toml)
output_path: Where to write the new config file (.coveragerc)
extra_omit_patterns: Additional patterns to add to the omit list
"""
import configparser

import tomli

if group == "curator":
extra_omit_patterns = ["**/curators/*"]
else:
extra_omit_patterns = []

# Read patterns from pyproject.toml
base_config_path = "pyproject.toml"
output_path = ".coveragerc"
with open(base_config_path, "rb") as f:
config = tomli.load(f)

base_patterns = config["tool"]["coverage"]["run"]["omit"]
all_patterns = base_patterns + extra_omit_patterns

# Write .coveragerc
coverage_config = configparser.ConfigParser()
coverage_config["run"] = {"omit": "\n" + "\n".join(all_patterns)}

with open(output_path, "w") as f:
coverage_config.write(f)

coverage_args = f"--cov=lamindb --cov-config={output_path} --cov-append --cov-report=term-missing"
return coverage_args


@nox.session
@nox.parametrize(
"group",
Expand All @@ -178,7 +215,7 @@ def build(session, group):
login_testuser2(session)
login_testuser1(session)
run(session, "lamin settings set private-django-api true")
coverage_args = "--cov=lamindb --cov-config=pyproject.toml --cov-append --cov-report=term-missing"
coverage_args = write_coverage_config(group)
if group == "unit-core":
run(
session,
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ omop = [
]
dev = [
# basic test
"tomli",
"line_profiler",
"pre-commit",
"nox",
Expand Down Expand Up @@ -215,5 +216,6 @@ exclude_lines = [

[tool.coverage.run]
omit = [
"**/core/datasets/*", # Datasets don't perform any logic
"**/core/datasets/*",
"**/migrations/*",
]
Loading