Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .github/actionlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ paths:
ignore:
# This runner exists, but is in beta and not known to actionlint.
- 'label "windows-11-arm" is unknown\. .+'
- 'property "check_run_id" is not defined.+'
16 changes: 11 additions & 5 deletions .github/scripts/get-envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@

import fileinput
import os
from pathlib import Path
from textwrap import dedent

GROUP_NUMBER = int(os.environ["GROUP_NUMBER"]) - 1
TOTAL_GROUPS = int(os.environ["TOTAL_GROUPS"])
GITHUB_JOB = os.environ["GITHUB_JOB"]
GITHUB_OUTPUT = os.environ.get("GITHUB_OUTPUT", None)


def main(stdin):
environments = [env.rstrip() for env in stdin]
filtered_envs = [env for env in environments if env.startswith(GITHUB_JOB + "-")]
grouped_envs = filtered_envs[GROUP_NUMBER::TOTAL_GROUPS]
joined_envs = ",".join(grouped_envs)

# If not environments are found, raise an error with helpful information.
if joined_envs:
print(joined_envs)
else:
if not grouped_envs:
error_msg = dedent(f"""
No matching environments found.
GITHUB_JOB = {GITHUB_JOB}
Expand All @@ -41,10 +40,17 @@ def main(stdin):
environments = {environments}
filtered_envs = {filtered_envs}
grouped_envs = {grouped_envs}
joined_envs = {joined_envs}
""")
raise RuntimeError(error_msg(environments))

# Output results to GITHUB_OUTPUT for use in later steps.
if GITHUB_OUTPUT:
with Path(GITHUB_OUTPUT).open("a") as output_fh:
print(f"envs={','.join(grouped_envs)}", file=output_fh)

# Output human readable results to stdout for visibility in logs.
print("\n".join(grouped_envs))


if __name__ == "__main__":
with fileinput.input() as stdin:
Expand Down
114 changes: 114 additions & 0 deletions .github/scripts/tox-summary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env python
# Copyright 2010 New Relic, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import os
import re
from pathlib import Path
from textwrap import dedent

REPO_DIR = Path(__file__).parent.parent.parent
TOX_DIR = REPO_DIR / ".tox"
GITHUB_SUMMARY = Path(os.environ.get("GITHUB_STEP_SUMMARY", TOX_DIR / "summary.md"))
RESULTS_FILE_RE = re.compile(
r"(?P<job_name>[a-zA-Z0-9_-]+)-(?P<job_num>\d+)-(?P<run_id>[a-zA-Z0-9]+)-(?P<job_id>[a-zA-Z0-9_-]+)-results.json"
)

GITHUB_SERVER_URL = os.environ.get("GITHUB_SERVER_URL", "https://github.com")
GITHUB_REPOSITORY = os.environ.get("GITHUB_REPOSITORY", "newrelic/newrelic-python-agent")

TABLE_HEADER = """
# Tox Results Summary

| Environment | Status | Duration (s) | Setup Duration (s) | Test Duration (s) | Runner |
|-------------|--------|--------------|--------------------|-------------------|--------|
"""
TABLE_HEADER = dedent(TABLE_HEADER).strip()


def main():
results = {}
# Search both repo and .tox dirs
filepaths = list(REPO_DIR.glob("*-results.json")) + list(TOX_DIR.glob("*-results.json"))
for filepath in filepaths:
with filepath.open() as f:
# Load the JSON data
data = json.load(f)
envs = data.get("testenvs", ())

# Extract GitHub info from filename
match = RESULTS_FILE_RE.match(filepath.name)
if match:
runner_link = f"{GITHUB_SERVER_URL}/{GITHUB_REPOSITORY}/actions/runs/{match.group('run_id')}/job/{match.group('job_id')}"
runner = f"[{match.group('job_name')} ({match.group('job_num')})]({runner_link})"
else:
runner = "N/A"

# Aggregate any non-empty results
sub_results = {k: v for k, v in envs.items() if v and k != ".pkg"}
for result in sub_results.values():
result["runner"] = runner
results.update(sub_results)

if not results:
raise RuntimeError("No tox results found.")

with GITHUB_SUMMARY.open("w") as output_fp:
summary = summarize_results(results)
# Print table header
print(TABLE_HEADER, file=output_fp)

for result in summary:
line = "| {env_name} | {status} | {duration} | {setup_duration} | {test_duration} | {runner} |".format(
**result
)
print(line, file=output_fp)


def summarize_results(results):
summary = []
for env, result in results.items():
duration = result["result"].get("duration", 0)
duration = f"{duration:.2f}" if duration >= 0 else "N/A"
status = "OK ✅" if result["result"]["success"] else "FAIL ❌"
runner = result.get("runner", "N/A")

# Sum up setup and test durations from individual commands
setup_duration = 0
for cmd in result.get("setup", ()):
setup_duration += cmd.get("elapsed", 0)
setup_duration = f"{setup_duration:.2f}" if setup_duration >= 0 else "N/A"

test_duration = 0
for cmd in result.get("test", ()):
test_duration += cmd.get("elapsed", 0)
test_duration = f"{test_duration:.2f}" if test_duration >= 0 else "N/A"

summary.append(
{
"env_name": env,
"status": status,
"duration": duration,
"setup_duration": setup_duration,
"test_duration": test_duration,
"runner": runner,
}
)

return sorted(summary, key=lambda result: (1 if "OK" in result["status"] else 0, result["env_name"]))


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]

env:
ASV_FACTOR: "1.1"
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
os: ubuntu-24.04
- wheel: cp313-manylinux
os: ubuntu-24.04
- wheel: cp314-manylinux
os: ubuntu-24.04
# Linux musllibc
- wheel: cp38-musllinux
os: ubuntu-24.04
Expand All @@ -54,10 +56,14 @@ jobs:
os: ubuntu-24.04
- wheel: cp313-musllinux
os: ubuntu-24.04
- wheel: cp314-musllinux
os: ubuntu-24.04
# Windows
# Windows wheels won't but published until the full release announcement.
# - wheel: cp313-win
# os: windows-2025
# - wheel: cp314-win
# os: windows-2025

name: Build wheels for ${{ matrix.wheel }}
runs-on: ${{ matrix.os }}
Expand Down
Loading
Loading