Skip to content

Commit 418847f

Browse files
committed
Exclude metadata.json from pytest report selection
1 parent 3e3cadb commit 418847f

File tree

3 files changed

+97
-73
lines changed

3 files changed

+97
-73
lines changed

.github/workflows/nightly.yml

Lines changed: 82 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,88 @@
11
name: Nightly
22

33
on:
4-
schedule:
5-
- cron: "0 1 * * *"
64
workflow_dispatch:
7-
pull_request:
8-
paths:
9-
- '.github/workflows/nightly.yml'
10-
11-
concurrency:
12-
group: ${{ github.workflow }}-${{ github.ref }}
13-
cancel-in-progress: true
14-
15-
permissions:
16-
contents: read
17-
packages: write
5+
inputs:
6+
source-repo:
7+
description: "ORG/REPO"
8+
required: false
9+
default: "rocm/jax"
10+
type: string
11+
source-github-run-id:
12+
description: "Repo GitHub Run ID"
13+
required: false
14+
default: ""
15+
type: string
16+
secrets:
17+
ROCM_JAX_DB_HOSTNAME:
18+
required: true
19+
ROCM_JAX_DB_USERNAME:
20+
required: true
21+
ROCM_JAX_DB_PASSWORD:
22+
required: true
23+
ROCM_JAX_DB_NAME:
24+
required: true
1825

1926
jobs:
20-
call-build-wheels:
21-
strategy:
22-
fail-fast: false
23-
matrix:
24-
rocm-version: ["7.1.1", "7.2.0"]
25-
include:
26-
- rocm-version: "7.1.1"
27-
runner-label: '["linux-x86-64-1gpu-amd"]'
28-
- rocm-version: "7.2.0"
29-
runner-label: '["linux-x86-64-1gpu-amd"]'
30-
uses: ./.github/workflows/build-wheels.yml
31-
with:
32-
python-versions: "3.11,3.12"
33-
rocm-version: ${{ matrix.rocm-version }}
34-
rocm-build-job: ${{ matrix.rocm-build-job }}
35-
rocm-build-num: ${{ matrix.rocm-build-num }}
36-
runner-label: ${{ matrix.runner-label }}
37-
secrets:
38-
rbe_ci_cert: ${{ secrets.RBE_CI_CERT }}
39-
rbe_ci_key: ${{ secrets.RBE_CI_KEY }}
40-
call-build-docker:
41-
needs: call-build-wheels
42-
strategy:
43-
fail-fast: false
44-
matrix:
45-
rocm-version: ["7.1.1", "7.2.0"]
46-
include:
47-
- rocm-version: "7.1.1"
48-
runner-label: '["linux-x86-64-1gpu-amd"]'
49-
- rocm-version: "7.2.0"
50-
runner-label: '["linux-x86-64-1gpu-amd"]'
51-
uses: ./.github/workflows/build-docker.yml
52-
with:
53-
rocm-version: ${{ matrix.rocm-version }}
54-
rocm-build-job: ${{ matrix.rocm-build-job }}
55-
rocm-build-num: ${{ matrix.rocm-build-num }}
56-
runner-label: ${{ matrix.runner-label }}
57-
extra-cr-tag: "nightly"
27+
download-logs:
28+
runs-on: linux-mi355-1
29+
steps:
30+
- name: Download logs artifact from source run
31+
env:
32+
GH_TOKEN: ${{ secrets.SECRET_TOKEN }}
33+
run: |
34+
gh run download "${{ inputs.source-github-run-id }}" \
35+
-R "${{ inputs.source-repo }}" \
36+
-D "logs-${{ inputs.source-github-run-id }}"
37+
- name: Upload logs for DB job
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: logs-${{ inputs.source-github-run-id }}
41+
path: logs-${{ inputs.source-github-run-id }}/
42+
upload-to-db:
43+
needs: download-logs
44+
runs-on: mysqldb
45+
steps:
46+
- name: Checkout source
47+
uses: actions/checkout@v4
48+
- name: Download logs from workflow artifact
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: logs-${{ inputs.source-github-run-id }}
52+
path: logs-${{ inputs.source-github-run-id }}
53+
- name: Upload logs to MySQL database
54+
env:
55+
ROCM_JAX_DB_HOSTNAME: ${{ secrets.ROCM_JAX_DB_HOSTNAME }}
56+
ROCM_JAX_DB_USERNAME: ${{ secrets.ROCM_JAX_DB_USERNAME }}
57+
ROCM_JAX_DB_PASSWORD: ${{ secrets.ROCM_JAX_DB_PASSWORD }}
58+
ROCM_JAX_DB_NAME: ${{ secrets.ROCM_JAX_DB_NAME }}
59+
ROCM_VERSION: ${{ inputs.rocm-version }}
60+
UBUNTU_VERSION: ${{ inputs.ubuntu-version }}
61+
LOGS_DIR: logs-${{ inputs.source-github-run-id }}
62+
GITHUB_SHA: ${{ inputs.github-sha }}
63+
GITHUB_RUN_ID: ${{ inputs.github-run-id }}
64+
ROCM_BUILD_NUM: ${{ inputs.rocm-build-num }}
65+
run: |
66+
python3 -m venv venv
67+
source venv/bin/activate
68+
pip install --upgrade pip
69+
pip install mysql-connector-python
70+
71+
for artifact_dir in "$LOGS_DIR"/*; do
72+
[ -d "$artifact_dir" ] || continue
73+
meta="$artifact_dir/metadata.json"
74+
[ -f "$meta" ] || continue
75+
RUNNER_LABEL=$(python -c "import json;print(json.load(open('$meta'))['runner_label'])")
76+
UBUNTU_VERSION=$(python -c "import json;print(json.load(open('$meta'))['ubuntu_version'])")
77+
ROCM_VERSION=$(python -c "import json;print(json.load(open('$meta'))['rocm_version'])")
78+
GITHUB_SHA=$(python -c "import json;print(json.load(open('$meta'))['github_sha'])")
79+
GITHUB_RUN_ID=$(python -c "import json;print(json.load(open('$meta'))['github_run_id'])")
80+
python ci/upload_test_to_db.py \
81+
--logs_dir "$artifact_dir" \
82+
--run-tag "ci-run" \
83+
--runner-label "$RUNNER_LABEL" \
84+
--ubuntu-version "$UBUNTU_VERSION" \
85+
--rocm-version "${ROCM_VERSION//.}" \
86+
--commit-sha "$GITHUB_SHA" \
87+
--github-run-id "$GITHUB_RUN_ID"
88+
done

.github/workflows/pytest-results-to-db.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,8 @@ on:
2525

2626
jobs:
2727
download-logs:
28-
runs-on: linux-x86-64-1gpu-amd
28+
runs-on: linux-mi355-1
2929
steps:
30-
- name: Install GitHub CLI
31-
run: |
32-
type -p curl >/dev/null || (apt update && apt install curl -y)
33-
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
34-
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
35-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
36-
apt update
37-
apt install gh -y
3830
- name: Download logs artifact from source run
3931
env:
4032
GH_TOKEN: ${{ secrets.SECRET_TOKEN }}

ci/upload_test_to_db.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"""
33
Upload pytest results to MySQL.
44
Tables:
5-
- ci_runs_dup: one row per run
6-
- ci_tests_dup: one row per unique test
7-
- ci_results_dup: one row per test per run
5+
- ci_runs: one row per run
6+
- ci_tests: one row per unique test
7+
- ci_results: one row per test per run
88
"""
99

1010
from __future__ import annotations
@@ -78,6 +78,7 @@ def find_single_report_json(logs_dir: Path) -> Path:
7878
for p in logs_dir.iterdir()
7979
if p.is_file()
8080
and p.suffix.lower() == ".json"
81+
and p.name not in {"metadata.json"}
8182
and not p.name.endswith("last_running.json")
8283
]
8384
if not jsons:
@@ -267,10 +268,10 @@ def connect():
267268

268269

269270
def insert_run(cur, created_at: datetime, meta: dict) -> int:
270-
"""Insert one row into ci_runs_dup and return run_id. Idempotence is not enforced here."""
271+
"""Insert one row into ci_runs and return run_id. Idempotence is not enforced here."""
271272
cur.execute(
272273
"""
273-
INSERT INTO ci_runs_dup (
274+
INSERT INTO ci_runs (
274275
created_at, commit_sha, runner_label, ubuntu_version,
275276
rocm_version, build_num, github_run_id, run_tag, logs_path
276277
) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)
@@ -291,11 +292,11 @@ def insert_run(cur, created_at: datetime, meta: dict) -> int:
291292

292293

293294
def sync_tests_and_get_ids(cur, tests: List[dict]) -> Dict[Tuple[str, str, str], int]:
294-
"""Ensure all tests exist in ci_tests_dup and return an ID mapping.
295+
"""Ensure all tests exist in ci_tests and return an ID mapping.
295296
296297
Uses a TEMPORARY TABLE for efficiency with large runs:
297298
1) Bulk insert unique (filename, classname, test_name) into a temp table.
298-
2) INSERT any missing rows into ci_tests_dup in one set operation.
299+
2) INSERT any missing rows into ci_tests in one set operation.
299300
3) SELECT back (file, class, test) -> id mapping in one query.
300301
"""
301302
uniq = {nodeid_parts(t["nodeid"]) for t in tests}
@@ -319,10 +320,10 @@ def sync_tests_and_get_ids(cur, tests: List[dict]) -> Dict[Tuple[str, str, str],
319320

320321
cur.execute(
321322
"""
322-
INSERT INTO ci_tests_dup (filename, classname, test_name)
323+
INSERT INTO ci_tests (filename, classname, test_name)
323324
SELECT s.filename, s.classname, s.test_name
324325
FROM tmp_tests s
325-
LEFT JOIN ci_tests_dup t
326+
LEFT JOIN ci_tests t
326327
ON t.filename = s.filename
327328
AND t.classname = s.classname
328329
AND t.test_name = s.test_name
@@ -334,7 +335,7 @@ def sync_tests_and_get_ids(cur, tests: List[dict]) -> Dict[Tuple[str, str, str],
334335
"""
335336
SELECT t.id, s.filename, s.classname, s.test_name
336337
FROM tmp_tests s
337-
JOIN ci_tests_dup t
338+
JOIN ci_tests t
338339
ON t.filename = s.filename
339340
AND t.classname = s.classname
340341
AND t.test_name = s.test_name
@@ -360,7 +361,7 @@ def batch_insert_results(
360361
return
361362

362363
sql = """
363-
INSERT INTO ci_results_dup
364+
INSERT INTO ci_results
364365
(run_id, test_id, outcome, duration, longrepr, message, skip_label)
365366
VALUES (%s,%s,%s,%s,%s,%s,%s)
366367
ON DUPLICATE KEY UPDATE
@@ -392,9 +393,9 @@ def upload_pytest_results( # pylint: disable=too-many-arguments, too-many-local
392393
393394
Flow:
394395
1) Parse JSONs and gather tests.
395-
2) Insert a ci_runs_dup row and get run_id.
396+
2) Insert a ci_runs row and get run_id.
396397
3) Ensure all tests exist; get (file,class,test) -> test_id map.
397-
4) Bulk insert/update ci_results_dup for this run.
398+
4) Bulk insert/update ci_results for this run.
398399
"""
399400
report = find_single_report_json(logs_dir)
400401
created_at, tests = load_from_single_json(report)

0 commit comments

Comments
 (0)