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

feat(proguard): Release association #1688

Merged
merged 7 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,28 @@ impl Api {
)
}

pub fn associate_proguard_mappings(
&self,
org: &str,
project: &str,
data: &AssociateProguard,
) -> ApiResult<()> {
let path = format!(
"/projects/{}/{}/files/proguard-artifact-releases",
PathArg(org),
PathArg(project)
);
let resp: ApiResponse = self
.request(Method::Post, &path)?
.with_json_body(data)?
.send()?;
if resp.status() == 404 || resp.status() == 201 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we doing Ok(()) on 404? 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be there for sure!

Ok(())
} else {
resp.convert()
}
}

/// Associate arbitrary debug symbols with a build
pub fn associate_dsyms(
&self,
Expand Down Expand Up @@ -2354,6 +2376,16 @@ pub struct AssociateDsyms {
pub build: Option<String>,
}

#[derive(Debug, Serialize)]
pub struct AssociateProguard {
pub release_name: String,
pub proguard_uuid: String,
#[serde(rename = "appId")]
pub app_id: String,
pub version: String,
pub build: Option<String>,
}

#[derive(Deserialize)]
struct MissingChecksumsResponse {
missing: HashSet<Digest>,
Expand Down
35 changes: 18 additions & 17 deletions src/commands/upload_proguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
use symbolic::common::ByteView;
use uuid::Uuid;

use crate::api::AssociateProguard;
use crate::api::{Api, AssociateDsyms};

Check failure on line 15 in src/commands/upload_proguard.rs

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

unused import: `AssociateDsyms`

Check failure on line 15 in src/commands/upload_proguard.rs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

unused import: `AssociateDsyms`

Check failure on line 15 in src/commands/upload_proguard.rs

View workflow job for this annotation

GitHub Actions / Test (macos-latest)

unused import: `AssociateDsyms`

Check failure on line 15 in src/commands/upload_proguard.rs

View workflow job for this annotation

GitHub Actions / Lint

unused import: `AssociateDsyms`
use crate::config::Config;
use crate::utils::android::{dump_proguard_uuids_as_properties, AndroidManifest};
use crate::utils::args::ArgExt;
Expand Down Expand Up @@ -216,7 +217,6 @@
let tf = TempFile::create()?;
{
let mut zip = zip::ZipWriter::new(tf.open()?);

for mapping in &mappings {
let pb = make_byte_progress_bar(mapping.size);
zip.start_file(
Expand Down Expand Up @@ -267,22 +267,23 @@

// if values are given associate
} else if let Some(app_id) = matches.get_one::<String>("app_id") {
api.associate_dsyms(
&org,
&project,
&AssociateDsyms {
platform: matches
.get_one::<String>("platform")
.map(String::as_str)
.unwrap_or("android")
.to_string(),
checksums: all_checksums,
name: app_id.to_string(),
app_id: app_id.to_string(),
version: matches.get_one::<String>("version").unwrap().to_owned(),
build: matches.get_one::<String>("version_code").cloned(),
},
)?;
let version = matches.get_one::<String>("version").unwrap().to_owned();
let build: Option<String> = matches.get_one::<String>("version_code").cloned();

for mapping in &mappings {
let uuid = forced_uuid.unwrap_or_else(|| &mapping.uuid);

Check failure on line 274 in src/commands/upload_proguard.rs

View workflow job for this annotation

GitHub Actions / Lint

unnecessary closure used to substitute value for `Option::None`
api.associate_proguard_mappings(
&org,
&project,
&AssociateProguard {
release_name: app_id.to_owned(),
proguard_uuid: uuid.to_string(),
app_id: app_id.to_owned(),
version: version.clone(),
build: build.clone(),
},
)?;
}
}

// If wanted trigger reprocessing
Expand Down