mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
switch to a python implementation of the same procedure
This commit is contained in:
@@ -0,0 +1,58 @@
|
|||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
def get_ci_jobs(repo_name):
|
||||||
|
url = f"https://api.github.com/repos/{repo_name}/actions/runs"
|
||||||
|
response = requests.get(url)
|
||||||
|
return response.json()
|
||||||
|
|
||||||
|
|
||||||
|
def get_ci_specific_run_specific_failure_details(repo_name, run_id):
|
||||||
|
url = f"https://api.github.com/repos/{repo_name}/actions/runs/{run_id}/attempts/1/logs"
|
||||||
|
response = requests.get(url)
|
||||||
|
return response.json()
|
||||||
|
|
||||||
|
|
||||||
|
def restart_job(repo_name, job_id):
|
||||||
|
url = f"https://api.github.com/repos/{repo_name}/actions/runs/{job_id}/rerun"
|
||||||
|
response = requests.post(url)
|
||||||
|
return response.json()
|
||||||
|
|
||||||
|
|
||||||
|
def logs_contain_signs_of_stoppage_due_to_lack_of_vm_resources(logs):
|
||||||
|
"""Do something like this?"""
|
||||||
|
for log in logs["lines"]:
|
||||||
|
if log["name"] == "stderr":
|
||||||
|
if "Error: The operation was canceled." in log["text"]:
|
||||||
|
return True
|
||||||
|
if "fatal error C1060: compiler is out of heap space" in log["text"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def eval_jobs():
|
||||||
|
jobs = get_ci_jobs("IfcOpenShell/IfcOpenShell")
|
||||||
|
for job in jobs["workflow_runs"]:
|
||||||
|
if job["name"] != "ci-ifcopenshell-conda-daily":
|
||||||
|
continue
|
||||||
|
|
||||||
|
if job["status"] != "completed":
|
||||||
|
continue
|
||||||
|
if job["conclusion"] != "failure":
|
||||||
|
continue
|
||||||
|
|
||||||
|
if job["run_attempt"] > 1:
|
||||||
|
continue
|
||||||
|
|
||||||
|
logs = get_ci_specific_run_specific_failure_details("IfcOpenShell/IfcOpenShell", job["id"])
|
||||||
|
|
||||||
|
print(logs)
|
||||||
|
print("restarting job", job["id"])
|
||||||
|
|
||||||
|
if logs_contain_signs_of_stoppage_due_to_lack_of_vm_resources(logs):
|
||||||
|
r = restart_job("IfcOpenShell/IfcOpenShell", job["id"])
|
||||||
|
print(r)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
eval_jobs()
|
||||||
@@ -2,9 +2,12 @@ name: Restart failed daily conda builds
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_run:
|
workflow_run:
|
||||||
workflows: [ci-ifcopenshell-conda-daily]
|
workflows: [ ci-ifcopenshell-conda-daily ]
|
||||||
types:
|
types:
|
||||||
- completed
|
- completed
|
||||||
|
push: # Remove this before merging
|
||||||
|
branches:
|
||||||
|
- add-conda-daily-restart-workflow
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REPO_OWNER: IfcOpenShell
|
REPO_OWNER: IfcOpenShell
|
||||||
@@ -15,19 +18,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
|
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check for failed runs
|
- uses: actions/setup-python@v2
|
||||||
id: check-failed-runs
|
with:
|
||||||
run: |
|
python-version: '3.10'
|
||||||
echo "Checking for failed runs..."
|
- name: Check for failed runs
|
||||||
# Replace "my-workflow" with the name of your workflow
|
id: check-failed-runs
|
||||||
failed_runs=$(curl -s https://api.github.com/repos/${{ env.REPO_OWNER }}/REPO/actions/runs?status=completed&conclusion=failure&workflow_id=${{ env.MY_WORKFLOW }} | jq '. | map(select(.status.code == 143))')
|
run: |
|
||||||
echo "Found $(echo $failed_runs | jq length) failed runs"
|
python check_repo_ci_jobs.py
|
||||||
- name: Restart failed runs
|
|
||||||
if: steps.check-failed-runs.outputs.failed_runs != null
|
|
||||||
run: |
|
|
||||||
echo "Restarting failed runs..."
|
|
||||||
for run_id in $(echo $failed_runs | jq -r '.[].id'); do
|
|
||||||
echo "Restarting run $run_id..."
|
|
||||||
curl -s -X POST https://api.github.com/repos/${{ env.REPO_OWNER }}/REPO/actions/runs/$run_id/rerun \
|
|
||||||
-H "Accept: application/vnd.github+json"
|
|
||||||
done
|
|
||||||
|
|||||||
Reference in New Issue
Block a user