Skip to content

Commit

Permalink
9273-bugs-on-the-registry-due-the-home-page-project
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jun 14, 2024
1 parent 182cb2d commit 237a2c0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Binary file modified .DS_Store
Binary file not shown.
28 changes: 19 additions & 9 deletions wordpress-prod-release-validation.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import requests
from bs4 import BeautifulSoup, Comment
import sys
import logging
import time
from urllib.parse import urljoin
from github_writer import GitHubWriter
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry

# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

def create_session_with_retries():
session = requests.Session()
retries = Retry(total=3, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
Expand All @@ -23,7 +20,6 @@ def fetch_url(session, url):
response.raise_for_status()
return response
except requests.exceptions.RequestException as e:
logging.error(f"Failed to fetch {url}: {e}")
return None

def validate_version(soup, version):
Expand All @@ -43,10 +39,24 @@ def validate_assets(url, version, github_writer, env):
return False

soup = BeautifulSoup(response.content, 'html.parser')

if not validate_version(soup, version):
github_writer.write_summary_and_fail(f"Version {version} not found in {url}.", env)
return False

# Retry mechanism for validate_version
max_retries = 5
for attempt in range(max_retries):
if validate_version(soup, version):
break
else:
if attempt < max_retries - 1:
github_writer.write_summary(f"Version {version} not found. Retrying... ({attempt + 1}/{max_retries})", env)
time.sleep(5)
response = fetch_url(session, url)
if not response:
github_writer.write_summary_and_fail(f"Failed to fetch {url}.", env)
return False
soup = BeautifulSoup(response.content, 'html.parser')
else:
github_writer.write_summary_and_fail(f"Version {version} not found in {url} after {max_retries} attempts.", env)
return False

# Collect all asset URLs
assets = []
Expand Down

0 comments on commit 237a2c0

Please sign in to comment.