Skip to content

Commit bfe7667

Browse files
authored
Merge pull request #16 from vkt1414/main
A github actions workflow to notify if building the extension fails
2 parents 2f7d585 + 8b48f89 commit bfe7667

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

.github/get_build_status.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import requests
2+
import pandas as pd
3+
import sys
4+
pd.set_option("display.max_columns", None)
5+
pd.set_option("display.max_rows", None)
6+
slicerExtensionName ='IDCBrowser'
7+
# API URL
8+
api_url = f"https://slicer.cdash.org/api/v1/index.php?project=SlicerPreview&filtercount=1&showfilters=1&field1=buildname&compare1=63&value1={slicerExtensionName}"
9+
10+
# Make the API request and store the JSON response
11+
response = requests.get(api_url)
12+
13+
if response.status_code == 200:
14+
# Parse the JSON response
15+
api_result = response.json()
16+
17+
# Extract the necessary information from the API result
18+
api_call_time = api_result["datetime"]
19+
builds = api_result["buildgroups"][0]["builds"]
20+
21+
# Create a list of dictionaries with the desired data
22+
data = []
23+
for build in builds:
24+
build_data = {
25+
"APICallTime": api_call_time,
26+
"BuildTriggerTime": build["builddate"],
27+
"BuildName": build["buildname"],
28+
"BuildPlatform": build.get("buildplatform", None),
29+
"ConfigureErrors": build.get("configure", {}).get("error", 0),
30+
"ConfigureWarnings": build.get("configure", {}).get("warning", 0),
31+
"HasCompilationData": build.get("hascompilation", False),
32+
"CompilationErrors": build.get("compilation", {}).get("error", 0),
33+
"CompilationWarnings": build.get("compilation", {}).get("warning", 0),
34+
"HasTestData": build.get("hastest", False),
35+
"TestNotRun": build.get("test", {}).get("notrun", 0),
36+
"TestFail": build.get("test", {}).get("fail", 0),
37+
"TestPass": build.get("test", {}).get("pass", 0),
38+
}
39+
data.append(build_data)
40+
41+
# Create a DataFrame
42+
df = pd.DataFrame(data)
43+
print(df)
44+
error_sum = df['ConfigureErrors'].sum()+ df['CompilationErrors'].sum()+df['TestFail'].sum()
45+
has_errors = error_sum > 0
46+
if has_errors:
47+
sys.exit(1)
48+
else:
49+
sys.exit(0)
50+
else:
51+
print(f"Failed to retrieve data. Status code: {response.status_code}")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Check Extension Build Status
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: 0 12 */1 * *
7+
8+
jobs:
9+
calculate_errors:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: 3.11
20+
21+
- name: Install dependencies
22+
run: pip install requests==2.31.0 pandas==2.1.1
23+
24+
- name: Run Python script to calculate errors
25+
run: |
26+
python .github/get_build_status.py
27+

0 commit comments

Comments
 (0)