1- use crate :: VERSION ;
1+ use super :: ExecAndRunSharedArgs ;
22use crate :: api_client:: CodSpeedAPIClient ;
33use crate :: config:: CodSpeedConfig ;
44use crate :: executor;
@@ -7,129 +7,14 @@ use crate::prelude::*;
77use crate :: project_config:: ProjectConfig ;
88use crate :: project_config:: merger:: ConfigMerger ;
99use crate :: run_environment:: interfaces:: RepositoryProvider ;
10- use crate :: runner_mode:: RunnerMode ;
1110use crate :: upload:: UploadResult ;
1211use clap:: { Args , ValueEnum } ;
1312use std:: path:: Path ;
14- use std:: path:: PathBuf ;
1513
1614pub mod helpers;
1715pub mod logger;
1816mod poll_results;
1917
20- pub ( crate ) fn show_banner ( ) {
21- let banner = format ! (
22- r#"
23- ______ __ _____ __
24- / ____/____ ____/ // ___/ ____ ___ ___ ____/ /
25- / / / __ \ / __ / \__ \ / __ \ / _ \ / _ \ / __ /
26- / /___ / /_/ // /_/ / ___/ // /_/ // __// __// /_/ /
27- \____/ \____/ \__,_/ /____// .___/ \___/ \___/ \__,_/
28- https://codspeed.io /_/ runner v{VERSION}
29- "#
30- ) ;
31- println ! ( "{banner}" ) ;
32- debug ! ( "codspeed v{VERSION}" ) ;
33- }
34-
35- #[ derive( Debug , Copy , Clone , PartialEq , ValueEnum , Default ) ]
36- pub enum UnwindingMode {
37- /// Use the frame pointer for unwinding. Requires the binary to be compiled with frame pointers enabled.
38- #[ clap( name = "fp" ) ]
39- FramePointer ,
40-
41- /// Use DWARF unwinding. This does not require any special compilation flags and is enabled by default.
42- #[ default]
43- Dwarf ,
44- }
45-
46- #[ derive( Args , Debug , Clone ) ]
47- pub struct PerfRunArgs {
48- /// Enable the linux perf profiler to collect granular performance data.
49- /// This is only supported on Linux.
50- #[ arg( long, env = "CODSPEED_PERF_ENABLED" , default_value_t = true ) ]
51- pub enable_perf : bool ,
52-
53- /// The unwinding mode that should be used with perf to collect the call stack.
54- #[ arg( long, env = "CODSPEED_PERF_UNWINDING_MODE" ) ]
55- pub perf_unwinding_mode : Option < UnwindingMode > ,
56- }
57-
58- /// Arguments shared between run and exec commands
59- #[ derive( Args , Debug , Clone ) ]
60- pub struct ExecAndRunSharedArgs {
61- /// The upload URL to use for uploading the results, useful for on-premises installations
62- #[ arg( long, env = "CODSPEED_UPLOAD_URL" ) ]
63- pub upload_url : Option < String > ,
64-
65- /// The token to use for uploading the results,
66- ///
67- /// It can be either a CodSpeed token retrieved from the repository setting
68- /// or an OIDC token issued by the identity provider.
69- #[ arg( long, env = "CODSPEED_TOKEN" ) ]
70- pub token : Option < String > ,
71-
72- /// The repository the benchmark is associated with, under the format `owner/repo`.
73- #[ arg( short, long, env = "CODSPEED_REPOSITORY" ) ]
74- pub repository : Option < String > ,
75-
76- /// The repository provider to use in case --repository is used. Defaults to github
77- #[ arg(
78- long,
79- env = "CODSPEED_PROVIDER" ,
80- requires = "repository" ,
81- ignore_case = true
82- ) ]
83- pub provider : Option < RepositoryProvider > ,
84-
85- /// The directory where the command will be executed.
86- #[ arg( long) ]
87- pub working_directory : Option < String > ,
88-
89- /// The mode to run the benchmarks in.
90- #[ arg( short, long, value_enum, env = "CODSPEED_RUNNER_MODE" ) ]
91- pub mode : RunnerMode ,
92-
93- /// Profile folder to use for the run.
94- #[ arg( long) ]
95- pub profile_folder : Option < PathBuf > ,
96-
97- /// Only for debugging purposes, skips the upload of the results
98- #[ arg(
99- long,
100- default_value = "false" ,
101- hide = true ,
102- env = "CODSPEED_SKIP_UPLOAD"
103- ) ]
104- pub skip_upload : bool ,
105-
106- /// Used internally to upload the results after running the benchmarks in a sandbox environment
107- /// with no internet access
108- #[ arg( long, default_value = "false" , hide = true ) ]
109- pub skip_run : bool ,
110-
111- /// Only for debugging purposes, skips the setup of the runner
112- #[ arg( long, default_value = "false" , hide = true ) ]
113- pub skip_setup : bool ,
114-
115- /// Allow runs without any benchmarks to succeed instead of failing
116- #[ arg( long, default_value = "false" , hide = true ) ]
117- pub allow_empty : bool ,
118-
119- /// The version of the go-runner to use (e.g., 1.2.3, 1.0.0-beta.1)
120- /// If not specified, the latest version will be installed
121- #[ arg( long, env = "CODSPEED_GO_RUNNER_VERSION" , value_parser = parse_version) ]
122- pub go_runner_version : Option < semver:: Version > ,
123-
124- #[ command( flatten) ]
125- pub perf_run_args : PerfRunArgs ,
126- }
127-
128- /// Parser for go-runner version that validates semver format
129- fn parse_version ( s : & str ) -> Result < semver:: Version , String > {
130- semver:: Version :: parse ( s) . map_err ( |e| format ! ( "Invalid semantic version: {e}" ) )
131- }
132-
13318#[ derive( Args , Debug ) ]
13419pub struct RunArgs {
13520 #[ command( flatten) ]
@@ -175,6 +60,9 @@ pub enum MessageFormat {
17560impl RunArgs {
17661 /// Constructs a new `RunArgs` with default values for testing purposes
17762 pub fn test ( ) -> Self {
63+ use super :: PerfRunArgs ;
64+ use crate :: RunnerMode ;
65+
17866 Self {
17967 shared : ExecAndRunSharedArgs {
18068 upload_url : None ,
@@ -259,7 +147,7 @@ pub async fn run(
259147 executor:: ExecutionContext :: try_from ( ( config, codspeed_config) ) ?;
260148
261149 if !execution_context. is_local ( ) {
262- show_banner ( ) ;
150+ super :: show_banner ( ) ;
263151 }
264152 debug ! ( "config: {:#?}" , execution_context. config) ;
265153
0 commit comments