Skip to content

Commit

Permalink
[tda] add code to get latest mobile release from empower repo
Browse files Browse the repository at this point in the history
  • Loading branch information
realkosty committed Nov 3, 2023
1 parent ca9aefb commit ba7740d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
4 changes: 4 additions & 0 deletions tda/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ def android_react_native_emu_driver(request, set_tags, selenium_endpoint):

try:
release_version = ReleaseVersion.latest_react_native_github_release()
sentry_sdk.set_tag("github_release_version", release_version)

options = UiAutomator2Options().load_capabilities({
'deviceName': 'Android GoogleAPI Emulator',
Expand Down Expand Up @@ -386,6 +387,7 @@ def android_emu_driver(request, set_tags, selenium_endpoint):

try:
release_version = ReleaseVersion.latest_android_github_release()
sentry_sdk.set_tag("github_release_version", release_version)

options = UiAutomator2Options().load_capabilities({
'deviceName': 'Android GoogleAPI Emulator',
Expand Down Expand Up @@ -422,6 +424,7 @@ def ios_react_native_sim_driver(request, set_tags, selenium_endpoint):

try:
release_version = ReleaseVersion.latest_react_native_github_release()
sentry_sdk.set_tag("github_release_version", release_version)

options = XCUITestOptions().load_capabilities({
'appium:deviceName': 'iPhone 11 Simulator',
Expand Down Expand Up @@ -457,6 +460,7 @@ def ios_sim_driver(request, set_tags, selenium_endpoint):

try:
release_version = ReleaseVersion.latest_ios_github_release()
sentry_sdk.set_tag("github_release_version", release_version)

options = XCUITestOptions().load_capabilities({
'appium:deviceName': 'iPhone 13 Simulator',
Expand Down
Empty file modified tda/latest_github_release.py
100644 → 100755
Empty file.
39 changes: 32 additions & 7 deletions tda/release_version_manager.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import requests
import os
from datetime import datetime

GITHUB_API_RELEASES_MAX_RESULTS = 30

GITHUB_REPOS = {
# platform: <github repo name>
'react_native': 'sentry_react_native',
'android': 'android',
'ios': 'ios'
'react_native': {
'repo': 'sentry_react_native',
'use_prefix': False
},
'android': {
'repo': 'android',
'use_prefix': False
},
'ios': {
'repo': 'ios',
'use_prefix': True
}
}

# Setting the release version in an environment variable
Expand Down Expand Up @@ -40,6 +51,20 @@ def latest_ios_github_release():
return latest_github_release('ios')

def determine_latest_release_version(platform):
repo_name = GITHUB_REPOS[platform]
react_native_releases = requests.get(f"https://api.github.com/repos/sentry-demos/{repo_name}/releases")
return react_native_releases.json()[0]['tag_name']
repo = GITHUB_REPOS[platform]
releases = requests.get(f"https://api.github.com/repos/sentry-demos/{repo['name']}/releases").json()
if not repo['use_prefix']:
# Assuming correct ordering (might cause bugs)
return releases[0]['tag_name']
else:
# When using <platform>-1.2.3 format GH will order releases alphabetically, i.e. 0.0.21 -> 0.0.3
# We can't use "Latest" because we have multiple latest releasese - one for each platform
if len(releases) >= GITHUB_API_RELEASES_MAX_RESULTS:
raise NotImplementedError(
f"Github /releases API returned maximum number of results (${GITHUB_API_RELEASES_MAX_RESULTS}). " +
"Current implementation is not able to handle pagination. Please delete old releases or implement.")

platform_releases = list(filter(lambda r: r['tag_name'].startswith(platform + '-'), releases))
# Parse the 'published_at' times and sort the releases
platform_releases.sort(key=lambda release: datetime.strptime(release["published_at"], "%Y-%m-%dT%H:%M:%SZ"), reverse=True)
return platform_releases[0]['tag_name']
1 change: 1 addition & 0 deletions tda/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ source env/bin/activate
source .sauce_credentials
export LATEST_REACT_NATIVE_GITHUB_RELEASE=$(python3 latest_github_release.py react_native)
export LATEST_ANDROID_GITHUB_RELEASE=$(python3 latest_github_release.py android)
export LATEST_IOS_GITHUB_RELEASE=$(python3 latest_github_release.py android)

# First run ALL canaries to ensure not a single one fails
for job in jobs/*.sh; do
Expand Down

0 comments on commit ba7740d

Please sign in to comment.