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

Use SL revision in builds #19

Merged
merged 11 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
wip
  • Loading branch information
stevensoftware52 committed Feb 8, 2024
commit 19cd09be69ee624efc5e4fe6a07793dd38cb28c2
61 changes: 60 additions & 1 deletion CI/pipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ param(
)

Write-Output "Workspace is $github_workspace"
Write-Output "Revision is $revision"
Write-Output "Github revision is $revision"

$slRevision = 0

Expand All @@ -17,6 +17,7 @@ try {
$jsonContent = Get-Content -Path $filepathJsonPublish -Raw | ConvertFrom-Json

$slRevision = $jsonContent.next_rev
Write-Output "Streamlabs revision is $slRevision"
}
catch {
throw "Error: An error occurred. Details: $($_.Exception.Message)"
Expand Down Expand Up @@ -141,3 +142,61 @@ Write-Output "Archive created: $archiveFileName"

# Move the 7z archive to the $github_workspace directory
Move-Item -Path $archiveFileName -Destination "${github_workspace}\"

# Add information to the revision library
$slRevision = 0

try {
# Download data for revisions
$urlJsonObsVersions = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/meta_publish.json"
$filepathJsonPublish = ".\meta_publish.json"
Invoke-WebRequest -Uri $urlJsonObsVersions -OutFile $filepathJsonPublish
$jsonContent = Get-Content -Path $filepathJsonPublish -Raw | ConvertFrom-Json

$slRevision = $jsonContent.next_rev
Write-Output "Streamlabs revision is $slRevision"

# Attempt to download existing revision builds JSON
$urlJsonRevisionBuilds = "https://s3.us-west-2.amazonaws.com/slobs-cdn.streamlabs.com/obsplugin/revision_builds.json"
$filepathJsonRevisionBuilds = ".\revision_builds.json"

try {
Invoke-WebRequest -Uri $urlJsonRevisionBuilds -OutFile $filepathJsonRevisionBuilds
}
catch {
# If download fails, assume file does not exist and create a new JSON array
Set-Content -Path $filepathJsonRevisionBuilds -Value "[]"
}

# Load or initialize the revision builds JSON
$revisionBuilds = Get-Content -Path $filepathJsonRevisionBuilds -Raw | ConvertFrom-Json

# Prepare the new entry
$newEntry = @{
"rev" = $slRevision
"date" = (Get-Date -UFormat %s)
"gitrev" = $revision
}

# Check if the entry already exists (based on rev and gitrev)
$exists = $false
foreach ($entry in $revisionBuilds) {
if ($entry.rev -eq $newEntry.rev -and $entry.gitrev -eq $newEntry.gitrev) {
$exists = $true
break
}
}

# If the entry does not exist, add it
if (-not $exists) {
$revisionBuilds += $newEntry
}

# Save the updated JSON back to the file
$revisionBuilds | ConvertTo-Json -Depth 100 | Set-Content -Path $filepathJsonRevisionBuilds

Write-Output "Revision builds updated successfully."
}
catch {
throw "Error: An error occurred. Details: $($_.Exception.Message)"
}
10 changes: 9 additions & 1 deletion CrashHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class CrashHandler
std::string payload;
std::string version;
std::string githubRevision;
std::string revision;

#ifdef SL_OBS_VERSION
version = SL_OBS_VERSION;
Expand All @@ -150,6 +151,12 @@ class CrashHandler
githubRevision = "debug";
#endif

#ifdef SL_REVISION
revision = SL_REVISION;
#else
revision = "debug";
#endif

// Read .dmp file content
std::ifstream minidump_file(minidump_path, std::ios::binary);
std::string minidumpContent((std::istreambuf_iterator<char>(minidump_file)), std::istreambuf_iterator<char>());
Expand Down Expand Up @@ -191,9 +198,10 @@ class CrashHandler
// Construct tags payload
payload += "Content-Disposition: form-data; name=\"sentry\"\r\n";
payload += "\r\n";
payload += "{\"release\":\"" + version + "\", \"tags\":{\"gitrev\":\"" + githubRevision + "\"}}\r\n";
payload += "{\"release\":\"" + version + "\", \"tags\":{\"gitrev\":\"" + githubRevision + "\", \"revision\":\"" + revision + "\"}}\r\n";
payload += "--BOUNDARY--\r\n";


// Ship it
WindowsFunctions::HTTPRequest(uri, method, headers, &httpCode, timeoutMS, response, payload, "application/json");
}
Expand Down
4 changes: 2 additions & 2 deletions PluginJsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ void PluginJsHandler::JS_CLEAR_AUTH_TOKEN(const json11::Json &params, std::strin
void PluginJsHandler::JS_SL_VERSION_INFO(const json11::Json &params, std::string &out_jsonReturn)
{
#ifdef GITHUB_REVISION
out_jsonReturn = Json(Json::object{{"branch", SL_OBS_VERSION}, {"git_sha", GITHUB_REVISION}}).dump();
out_jsonReturn = Json(Json::object{{"branch", SL_OBS_VERSION}, {"git_sha", GITHUB_REVISION}, {"rev", SL_REVISION}}).dump();
#else
out_jsonReturn = Json(Json::object{{"branch", "debug"}, {"git_sha", "debug"}}).dump();
out_jsonReturn = Json(Json::object{{"branch", "debug"}, {"git_sha", "debug"}, {"rev", "debug"}}).dump();
#endif
}

Expand Down
35 changes: 33 additions & 2 deletions SlBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,28 @@ void SlBrowser::CreateCefBrowser(int arg)

void SlBrowser::browserInit()
{
std::string version;
std::string githubRevision;
std::string revision;

#ifdef SL_OBS_VERSION
version = SL_OBS_VERSION;
#else
version = "debug";
#endif

#ifdef GITHUB_REVISION
githubRevision = GITHUB_REVISION;
#else
githubRevision = "debug";
#endif

#ifdef SL_REVISION
revision = SL_REVISION;
#else
revision = "debug";
#endif

TCHAR moduleFileName[MAX_PATH]{};
GetModuleFileName(NULL, moduleFileName, MAX_PATH);
std::filesystem::path fsPath(moduleFileName);
Expand All @@ -133,11 +155,20 @@ void SlBrowser::browserInit()
settings.log_severity = LOGSEVERITY_VERBOSE;

CefString(&settings.user_agent_product) = "Streamlabs";

// TODO
CefString(&settings.locale) = "en-US";
CefString(&settings.accept_language_list) = "en-US,en";

// Value that will be inserted as the product portion of the default
// User-Agent string. If empty the Chromium product version will be used. If
// |userAgent| is specified this value will be ignored. Also configurable
// using the "user-agent-product" command-line switch.
std::stringstream prod_ver;
prod_ver << "Chrome/";
prod_ver << std::to_string(cef_version_info(4)) << "." << std::to_string(cef_version_info(5)) << "." << std::to_string(cef_version_info(6)) << "." << std::to_string(cef_version_info(7));
prod_ver << " SLABS/";
prod_ver << version << "." << githubRevision;
CefString(&settings.user_agent_product) = prod_ver.str();

settings.persist_user_preferences = 1;

char cache_path[MAX_PATH];
Expand Down