Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tda] code to get latest mobile release from monorepo #313

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
asottile-sentry marked this conversation as resolved.
Show resolved Hide resolved
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