Skip to content

Commit 65a2980

Browse files
committed
refactor(run): store upload metadata latest version in a const
1 parent 08a8a5d commit 65a2980

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

src/run/run_environment/local/provider.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use crate::run::config::RepositoryOverride;
88
use crate::run::helpers::{GitRemote, parse_git_remote};
99
use crate::run::run_environment::{RunEnvironment, RunPart};
1010
use crate::run::runner::ExecutorName;
11-
use crate::run::uploader::{ProfileArchive, Runner, UploadMetadata};
11+
use crate::run::uploader::{
12+
LATEST_UPLOAD_METADATA_VERSION, ProfileArchive, Runner, UploadMetadata,
13+
};
1214
use crate::run::{
1315
config::Config,
1416
helpers::find_repository_root,
@@ -153,7 +155,7 @@ impl RunEnvironmentProvider for LocalProvider {
153155
let run_environment_metadata = self.get_run_environment_metadata()?;
154156

155157
Ok(UploadMetadata {
156-
version: Some(7),
158+
version: Some(LATEST_UPLOAD_METADATA_VERSION),
157159
tokenless: config.token.is_none(),
158160
repository_provider: self.get_repository_provider(),
159161
commit_hash: run_environment_metadata.ref_.clone(),

src/run/run_environment/provider.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use crate::prelude::*;
55
use crate::run::check_system::SystemInfo;
66
use crate::run::config::Config;
77
use crate::run::runner::ExecutorName;
8-
use crate::run::uploader::{ProfileArchive, Runner, UploadMetadata};
8+
use crate::run::uploader::{
9+
LATEST_UPLOAD_METADATA_VERSION, ProfileArchive, Runner, UploadMetadata,
10+
};
911

1012
use super::interfaces::{RepositoryProvider, RunEnvironment, RunEnvironmentMetadata, RunPart};
1113

@@ -74,7 +76,7 @@ pub trait RunEnvironmentProvider {
7476
let commit_hash = get_commit_hash(&run_environment_metadata.repository_root_path)?;
7577

7678
Ok(UploadMetadata {
77-
version: Some(7),
79+
version: Some(LATEST_UPLOAD_METADATA_VERSION),
7880
tokenless: config.token.is_none(),
7981
repository_provider: self.get_repository_provider(),
8082
run_environment_metadata,

src/run/uploader/interfaces.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use crate::run::{
77
runner::ExecutorName,
88
};
99

10+
pub const LATEST_UPLOAD_METADATA_VERSION: u32 = 7;
11+
1012
#[derive(Deserialize, Serialize, Debug)]
1113
#[serde(rename_all = "camelCase")]
1214
pub struct UploadMetadata {

src/run/uploader/snapshots/codspeed__run__uploader__upload_metadata__tests__get_metadata_hash-2.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ expression: upload_metadata
44
---
55
{
66
"repositoryProvider": "GITHUB",
7-
"version": 6,
7+
"version": 7,
88
"tokenless": true,
99
"profileMd5": "jp/k05RKuqP3ERQuIIvx4Q==",
10+
"profileEncoding": "gzip",
1011
"runner": {
1112
"name": "codspeed-runner",
1213
"version": "2.1.0",

src/run/uploader/upload_metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ mod tests {
2323
Sender,
2424
},
2525
runner::ExecutorName,
26-
uploader::{Runner, UploadMetadata},
26+
uploader::{LATEST_UPLOAD_METADATA_VERSION, Runner, UploadMetadata},
2727
};
2828

2929
#[test]
3030
fn test_get_metadata_hash() {
3131
let upload_metadata = UploadMetadata {
3232
repository_provider: RepositoryProvider::GitHub,
33-
version: Some(7),
33+
version: Some(LATEST_UPLOAD_METADATA_VERSION),
3434
tokenless: true,
3535
profile_md5: "jp/k05RKuqP3ERQuIIvx4Q==".into(),
3636
profile_encoding: Some("gzip".into()),

0 commit comments

Comments
 (0)