Skip to content

Commit 7db1b01

Browse files
committed
chore: merge branch 'main' into release/0.70
2 parents db5445b + c8d5655 commit 7db1b01

23 files changed

+134
-80
lines changed

.ci/pytest_summary.py

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
import json
22
import os
3+
from typing import Any, TypedDict
34

45
import click
56
import numpy as np
7+
from numpy.typing import NDArray
68

79
BIG_WIDTH = 80
810
SMALL_WIDTH = 8
911

1012

11-
def find_json_files(base_dir):
13+
class TEST_STATS_TYPE(TypedDict):
14+
durations: list[str | float]
15+
n_tests: int
16+
17+
18+
def find_json_files(base_dir: str) -> list[str]:
1219
"""Recursively find all JSON files in subdirectories."""
13-
json_files = []
20+
json_files: list[str] = []
1421
for root, _, files in os.walk(base_dir):
1522
for file in files:
1623
if file.endswith(".jsonl"):
1724
json_files.append(os.path.join(root, file))
1825
return json_files
1926

2027

21-
def read_json_file(file_path):
28+
def read_json_file(file_path: str) -> list[dict[str, str]]:
2229
"""Read a JSON file and return its content as a list of test configurations."""
2330
with open(file_path, "r", encoding="utf-8") as f:
2431
try:
@@ -29,24 +36,28 @@ def read_json_file(file_path):
2936
return []
3037

3138

32-
def extract_tests_with_tags(json_files):
39+
def extract_tests_with_tags(json_files: list[str]) -> list[dict[str, str | list[str]]]:
3340
"""Extract test data and assign a tag based on the directory name."""
34-
tests = []
41+
tests: list[dict[str, str | list[str]]] = []
3542

3643
for file_path in json_files:
3744
directory_name = os.path.basename(os.path.dirname(file_path))
3845
test_data = read_json_file(file_path)
3946

4047
for test in test_data:
4148
if test.get("outcome", "").lower() == "passed" and test.get("duration"):
42-
nodeid = test.get("nodeid")
49+
nodeid: str = test.get("nodeid", "")
50+
4351
if nodeid.startswith("tests/"):
4452
nodeid = nodeid[6:]
4553

46-
when = test.get("when")
47-
duration = test["duration"]
48-
tags = directory_name.split("-")
49-
tags.remove("logs")
54+
when: str = test.get("when", "")
55+
duration: str = test["duration"]
56+
tags: list[str] = directory_name.split("-")
57+
58+
if "logs" in tags:
59+
tags.remove("logs")
60+
5061
id_ = f"{nodeid}({when})"
5162

5263
tests.append(
@@ -61,12 +72,14 @@ def extract_tests_with_tags(json_files):
6172
return tests
6273

6374

64-
def compute_statistics(tests):
75+
def compute_statistics(
76+
tests: list[dict[str, str | list[str]]],
77+
) -> list[dict[str, str | float]]:
6578
"""Compute average duration and standard deviation per test ID."""
66-
test_stats = {}
79+
test_stats: dict[str, TEST_STATS_TYPE] = {}
6780

6881
for test in tests:
69-
test_id = test["id"]
82+
test_id: str = test["id"]
7083
if test_id not in test_stats:
7184
test_stats[test_id] = {
7285
"durations": [],
@@ -76,10 +89,10 @@ def compute_statistics(tests):
7689
test_stats[test_id]["durations"].append(test["duration"])
7790
test_stats[test_id]["n_tests"] += 1
7891

79-
summary = []
92+
summary: list[dict[str, Any]] = []
8093

8194
for test_id, data in test_stats.items():
82-
durations = np.array(data["durations"])
95+
durations: NDArray[Any] = np.array(data["durations"])
8396

8497
if durations.size == 0:
8598
continue
@@ -119,10 +132,15 @@ def compute_statistics(tests):
119132
return summary
120133

121134

122-
def print_table(data, keys, headers, title=""):
135+
def print_table(
136+
data: list[dict[str, str | float]],
137+
keys: list[str],
138+
headers: list[str],
139+
title: str = "",
140+
):
123141
JUNCTION = "|"
124142

125-
def make_bold(s):
143+
def make_bold(s: str) -> str:
126144
return click.style(s, bold=True)
127145

128146
h = [headers[0].ljust(BIG_WIDTH)]
@@ -135,7 +153,7 @@ def make_bold(s):
135153
+ f"-{JUNCTION}-".join(["-" * len(each) for each in h])
136154
+ f"-{JUNCTION}"
137155
)
138-
top_sep = f"{JUNCTION}" + "-" * (len_h - 2) + f"{JUNCTION}"
156+
# top_sep: str = f"{JUNCTION}" + "-" * (len_h - 2) + f"{JUNCTION}"
139157

140158
if title:
141159
# click.echo(top_sep)
@@ -148,17 +166,17 @@ def make_bold(s):
148166
click.echo(sep)
149167

150168
for test in data:
151-
s = []
169+
s: list[str] = []
152170
for i, each_key in enumerate(keys):
153171

154172
if i == 0:
155-
id_ = test[each_key]
173+
id_: str = test[each_key]
156174

157175
id_ = (
158-
id_.replace("(", "\(")
159-
.replace(")", "\)")
160-
.replace("[", "\[")
161-
.replace("]", "\]")
176+
id_.replace("(", r"(")
177+
.replace(")", r")")
178+
.replace("[", r"[")
179+
.replace("]", r"]")
162180
)
163181
if len(id_) >= BIG_WIDTH:
164182
id_ = id_[: BIG_WIDTH - 15] + "..." + id_[-12:]
@@ -177,7 +195,7 @@ def make_bold(s):
177195
# click.echo(sep)
178196

179197

180-
def print_summary(summary, num=10):
198+
def print_summary(summary: list[dict[str, str | float]], num: int = 10):
181199
"""Print the top N longest tests and the top N most variable tests."""
182200
longest_tests = sorted(summary, key=lambda x: -x["average_duration"])[:num]
183201
most_variable_tests = sorted(summary, key=lambda x: -x["std_dev"])[:num]
@@ -225,15 +243,20 @@ def print_summary(summary, num=10):
225243
default=None,
226244
)
227245
@click.option(
228-
"--num", default=10, help="Number of top tests to display.", show_default=True
246+
"--num",
247+
type=int,
248+
default=10,
249+
help="Number of top tests to display.",
250+
show_default=True,
229251
)
230252
@click.option(
231253
"--save-file",
232254
default=None,
255+
type=click.Path(exists=False, dir_okay=False),
233256
help="File to save the test durations. Default 'tests_durations.json'.",
234257
show_default=True,
235258
)
236-
def analyze_tests(directory, num, save_file):
259+
def analyze_tests(directory: str, num: int, save_file: str):
237260
directory = directory or os.getcwd() # Change this to your base directory
238261
json_files = find_json_files(directory)
239262
tests = extract_tests_with_tags(json_files)

.github/actions/pytest-summary/action.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ runs:
3030
- name: "Download artifacts"
3131
uses: actions/download-artifact@v4
3232
with:
33+
pattern: "reports-*"
3334
path: "artifacts"
3435

3536
- name: "Check if artifacts directory has files"
@@ -53,7 +54,7 @@ runs:
5354
if: ${{ env.HAS_FILES == 'true' }}
5455
shell: bash
5556
run: |
56-
find . -mindepth 1 -maxdepth 4 -type f -name 'logs-*.tgz' -exec tar -xzvf {} -C $(dirname {}) \;
57+
find . -mindepth 1 -maxdepth 4 -type f -name 'reports-*.tgz' -exec tar -xzvf {} -C $(dirname {}) \;
5758
5859
- name: "List directories"
5960
if: ${{ env.HAS_FILES == 'true' }}
@@ -66,8 +67,11 @@ runs:
6667
shell: bash
6768
run: |
6869
echo "# Test summary 🚀" >> $GITHUB_STEP_SUMMARY
69-
echo -e "The followin tables show a summary of tests duration and standard desviation for all the jobs.\n" >> $GITHUB_STEP_SUMMARY
70+
echo -e "The following tables show a summary of tests duration and standard deviation for all the jobs.\n" >> $GITHUB_STEP_SUMMARY
71+
echo -e "You have the duration of all tests in the artifact 'tests_durations.json'\n" >> $GITHUB_STEP_SUMMARY
72+
echo "Running Pytest summary..."
7073
python .ci/pytest_summary.py --num 10 --save-file tests_durations.json >> summary.md
74+
echo "Pytest summary done."
7175
echo "$(cat summary.md)" >> $GITHUB_STEP_SUMMARY
7276
cat summary.md
7377

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
contents: write
5353
pull-requests: write
5454
steps:
55-
- uses: ansys/actions/doc-deploy-changelog@v9
55+
- uses: ansys/actions/doc-deploy-changelog@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.9
5656
with:
5757
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
5858
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
@@ -65,7 +65,7 @@ jobs:
6565
runs-on: ubuntu-22.04
6666
steps:
6767
- name: Check pull-request name
68-
uses: ansys/actions/check-pr-title@v9
68+
uses: ansys/actions/check-pr-title@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.9
6969
with:
7070
token: ${{ secrets.GITHUB_TOKEN }}
7171

@@ -78,7 +78,7 @@ jobs:
7878
folder: ["doc", "examples"]
7979
steps:
8080
- name: "Ansys documentation style checks"
81-
uses: ansys/actions/doc-style@v9
81+
uses: ansys/actions/doc-style@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.9
8282
with:
8383
token: ${{ secrets.GITHUB_TOKEN }}
8484
files: ${{ matrix.folder }}
@@ -104,7 +104,7 @@ jobs:
104104
os: macos-latest
105105
steps:
106106
- name: "Build wheelhouse and perform smoke test"
107-
uses: ansys/actions/build-wheelhouse@v9
107+
uses: ansys/actions/build-wheelhouse@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.9
108108
with:
109109
library-name: ${{ env.PACKAGE_NAME }}
110110
operating-system: ${{ matrix.os }}
@@ -123,7 +123,7 @@ jobs:
123123
name: "Check library vulnerabilities"
124124
runs-on: ubuntu-22.04
125125
steps:
126-
- uses: ansys/actions/check-vulnerabilities@v9
126+
- uses: ansys/actions/check-vulnerabilities@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.9
127127
with:
128128
python-version: '3.13'
129129
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
@@ -298,7 +298,7 @@ jobs:
298298
runs-on: ubuntu-22.04
299299
steps:
300300
- name: "Build library source and wheel artifacts"
301-
uses: ansys/actions/build-library@v9
301+
uses: ansys/actions/build-library@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.9
302302
with:
303303
library-name: ${{ env.PACKAGE_NAME }}
304304
python-version: '3.13'
@@ -333,7 +333,7 @@ jobs:
333333
skip-existing: false
334334

335335
- name: "Release to GitHub"
336-
uses: ansys/actions/release-github@v9
336+
uses: ansys/actions/release-github@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.9
337337
with:
338338
library-name: ${{ env.PACKAGE_NAME }}
339339
additional-artifacts: "minimum_requirements.txt"
@@ -347,7 +347,7 @@ jobs:
347347
needs: [release]
348348
steps:
349349
- name: "Deploy the stable documentation"
350-
uses: ansys/actions/doc-deploy-stable@v9
350+
uses: ansys/actions/doc-deploy-stable@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.9
351351
with:
352352
cname: ${{ env.DOCUMENTATION_CNAME }}
353353
token: ${{ secrets.GITHUB_TOKEN }}
@@ -363,7 +363,7 @@ jobs:
363363
needs: [docs-build]
364364
steps:
365365
- name: "Deploy the latest documentation"
366-
uses: ansys/actions/doc-deploy-dev@v9
366+
uses: ansys/actions/doc-deploy-dev@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.9
367367
with:
368368
cname: ${{ env.DOCUMENTATION_CNAME }}
369369
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/docker_clean_untagged.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
steps:
2323

2424
- name: "Perform versions cleanup - except certain tags"
25-
uses: ansys/actions/hk-package-clean-untagged@v9
25+
uses: ansys/actions/hk-package-clean-untagged@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.9
2626
with:
2727
package-name: 'mapdl'
2828
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/label.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
pull-requests: write
128128
runs-on: ubuntu-latest
129129
steps:
130-
- uses: ansys/actions/doc-changelog@v9
130+
- uses: ansys/actions/doc-changelog@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.9
131131
with:
132132
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
133133
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}

.github/workflows/test-local.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,13 @@ jobs:
259259
--report-log=$file_name.jsonl \
260260
--cov-report=xml:$file_name.xml
261261
262+
- name: "Upload pytest reports to GitHub"
263+
if: always()
264+
uses: actions/[email protected]
265+
with:
266+
name: "reports-${{ inputs.file-name }}"
267+
path: ./${{ inputs.file-name }}.jsonl
268+
262269
- name: "Collect logs on failure"
263270
if: always()
264271
env:
@@ -269,7 +276,7 @@ jobs:
269276
270277
- name: "Upload logs to GitHub"
271278
if: always()
272-
uses: actions/upload-artifact@master
279+
uses: actions/upload-artifact@v4.6.2
273280
with:
274281
name: logs-${{ inputs.file-name }}.tgz
275282
path: ./logs-${{ inputs.file-name }}.tgz

.github/workflows/test-remote.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ jobs:
222222
--report-log=$file_name.jsonl \
223223
--cov-report=xml:$file_name.xml
224224
225+
- name: "Upload pytest reports to GitHub"
226+
if: always()
227+
uses: actions/[email protected]
228+
with:
229+
name: "reports-${{ inputs.file-name }}"
230+
path: ./${{ inputs.file-name }}.jsonl
231+
225232
- uses: codecov/codecov-action@v5
226233
name: "Upload coverage to Codecov"
227234
with:
@@ -230,7 +237,7 @@ jobs:
230237
flags: remote,${{ steps.ubuntu_check.outputs.TAG_UBUNTU }},${{ inputs.mapdl-version }},${{ steps.distributed_mode.outputs.distributed_mode }},${{ steps.student_check.outputs.TAG_STUDENT }}
231238

232239
- name: Upload coverage artifacts
233-
uses: actions/upload-artifact@v4
240+
uses: actions/upload-artifact@v4.6.2
234241
with:
235242
name: "${{ inputs.file-name }}.xml"
236243
path: "./${{ inputs.file-name }}.xml"
@@ -242,7 +249,7 @@ jobs:
242249
twine check dist/*
243250
244251
- name: "Upload wheel and binaries"
245-
uses: actions/upload-artifact@v4
252+
uses: actions/upload-artifact@v4.6.2
246253
with:
247254
name: PyMAPDL-packages-${{ inputs.mapdl-version }}
248255
path: dist/
@@ -260,7 +267,7 @@ jobs:
260267
261268
- name: "Upload logs to GitHub"
262269
if: always()
263-
uses: actions/upload-artifact@v4
270+
uses: actions/upload-artifact@v4.6.2
264271
with:
265272
name: logs-${{ inputs.file-name }}.tgz
266273
path: ./logs-${{ inputs.file-name }}.tgz
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feat: add artifact upload steps for JSONL logs in local and remote test workflows

doc/changelog.d/3907.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
chore: update version to 0.70.dev0 in pyproject.toml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build: bump platformdirs from 4.3.7 to 4.3.8 in the minimal group

0 commit comments

Comments
 (0)