From 46d520dc90140de9d436aa84a6f5264927cd8adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Meyer?= Date: Sat, 4 May 2024 13:07:24 +0200 Subject: [PATCH] Add infos --- Cargo.toml | 6 +- src/cli_args.rs | 153 +++++++++++++++++++++++------------ src/config/appveyor.rs | 52 ++++++++++-- src/config/buildkite.rs | 44 ++++++++-- src/config/circleci.rs | 24 ++++-- src/config/coveralls_env.rs | 2 +- src/config/generic.rs | 54 ++++++++++++- src/config/github_actions.rs | 2 +- src/config/jenkins.rs | 2 +- src/config/mod.rs | 91 ++++++++++++++------- src/config/semaphore.rs | 4 +- src/config/travis.rs | 2 +- src/coverralls.rs | 2 +- 13 files changed, 330 insertions(+), 108 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f8974c2..d7ef2da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "coveralls" description = "Send job to Coveralls (coveralls.io)" -version = "0.1.3" +version = "0.1.4" authors = ["Frédéric Meyer "] edition = "2021" license = "LGPL-3.0" @@ -18,11 +18,11 @@ categories = [ [dependencies] regex = "1.10.4" itertools = "0.12.1" -simple-error = "0.3" +simple-error = "0.3.0" serde_json = "1.0.116" const_format = "0.2.32" git2 = { version = "0.18.3", optional = true } -serde = { version = "1.0.199", features = ["derive"] } +serde = { version = "1.0.200", features = ["derive"] } clap = { version = "4.5.4", features = ["wrap_help", "color", "derive"] } reqwest = { version = "0.12.4", features = ["blocking", "multipart"] } diff --git a/src/cli_args.rs b/src/cli_args.rs index 83790d4..ae4ea93 100644 --- a/src/cli_args.rs +++ b/src/cli_args.rs @@ -37,6 +37,10 @@ pub struct CliArgs { #[clap(value_name = "file_name", global = true)] pub input: Option, + /// Use `file` as output file for writing what should be sent to Coveralls + #[clap(short='O', long, value_name = "file", global = true)] + pub output: Option, + /// Add a prefix to all files #[clap(short='P', long, value_name = "prefix", global = true)] pub source_prefix: Option, @@ -62,16 +66,17 @@ pub enum CliService { /// Service Circle-CI #[clap(name = "circleci", after_help = "\ Used environment variables for Circle-CI:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - - CIRCLE_BRANCH: Git branch\n\ - - CIRCLE_WORKFLOW_ID, CIRCLE_BUILD_NUM: Service number\n\ - - CIRCLE_PULL_REQUEST: Service pull request\n\ - - CIRCLE_BUILD_URL: Service build url\n\ - - CIRCLE_WORKFLOW_JOB_ID: Service job id\n\ + - CIRCLE_PULL_REQUEST: Service pull request\n\ + - CIRCLE_BUILD_URL: Service build url\n\ + - CIRCLE_PROJECT_ID: Service project ID\n\ + - CIRCLE_WORKFLOW_JOB_ID: Service job ID\n\ + - CIRCLE_JOB: Service job name\n\ + - CIRCLE_BUILD_NUM: Service build number\n\ + - CIRCLE_BRANCH: Service branch\n\ + - CIRCLE_TAG: Service tag\n\ + - CIRCLE_SHA1: Service commit ID\n\ \n\ Common environment variables:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - - COVERALLS_FLAG_NAME: Coveralls flag name\n\ - GIT_ID: Git ID\n\ - GIT_MESSAGE: Git message\n\ - GIT_AUTHOR_NAME: Git author name\n\ @@ -81,6 +86,7 @@ pub enum CliService { - GIT_REMOTE: Git remote name\n\ - GIT_URL: Git remote URL\n\ - GIT_BRANCH, BRANCH_NAME: Git branch\n\ + - GIT_TAG: Git tag\n\ \n\ ")] CircleCI(CliServiceArgs), @@ -88,7 +94,6 @@ pub enum CliService { /// Service Github-Actions #[clap(name = "actions", after_help = "\ Used environment variables for GitHub Actions:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - GITHUB_REF, GITHUB_HEAD_REF: Git branch\n\ - GITHUB_RUN_ID: Service number\n\ - GITHUB_REF: Service pull request\n\ @@ -96,8 +101,6 @@ pub enum CliService { - GITHUB_RUN_NUMBER: Service job number\n\ \n\ Common environment variables:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - - COVERALLS_FLAG_NAME: Coveralls flag name\n\ - GIT_ID: Git ID\n\ - GIT_MESSAGE: Git message\n\ - GIT_AUTHOR_NAME: Git author name\n\ @@ -107,6 +110,7 @@ pub enum CliService { - GIT_REMOTE: Git remote name\n\ - GIT_URL: Git remote URL\n\ - GIT_BRANCH, BRANCH_NAME: Git branch\n\ + - GIT_TAG: Git tag\n\ \n\ ")] Actions(CliServiceArgs), @@ -114,16 +118,23 @@ pub enum CliService { /// Service AppVeyor #[clap(name = "appveyor", after_help = "\ Used environment variables for AppVeyor:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - - APPVEYOR_REPO_BRANCH: Git branch\n\ - - APPVEYOR_BUILD_NUMBER: Service number\n\ - - APPVEYOR_PULL_REQUEST_NUMBER: Service pull request\n\ - - APPVEYOR_BUILD_ID: Service job id\n\ - - APPVEYOR_JOB_NUMBER: Service job number\n\ + - APPVEYOR_PROJECT_ID: Service project ID\n\ + - APPVEYOR_BUILD_ID: Service build id\n\ + - APPVEYOR_BUILD_NUMBER: Service number\n\ + - APPVEYOR_BUILD_VERSION: Service build version\n\ + - APPVEYOR_PULL_REQUEST_NUMBER: Service pull request\n\ + - APPVEYOR_JOB_ID: Service job id\n\ + - APPVEYOR_JOB_NUMBER: Service job number\n\ + - APPVEYOR_JOB_NAME: Service job name\n\ + - APPVEYOR_REPO_BRANCH: Service repo branch\n\ + - APPVEYOR_REPO_NAME: Service repo name\n\ + - APPVEYOR_REPO_TAG_NAME: Service repo tag name\n\ + - APPVEYOR_REPO_COMMIT: Service repo commit ID\n\ + - APPVEYOR_REPO_COMMIT_MESSAGE: Service repo commit message\n\ + - APPVEYOR_REPO_COMMIT_AUTHOR: Service repo commit author\n\ + - APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL: Service repo commit email\n\ \n\ Common environment variables:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - - COVERALLS_FLAG_NAME: Coveralls flag name\n\ - GIT_ID: Git ID\n\ - GIT_MESSAGE: Git message\n\ - GIT_AUTHOR_NAME: Git author name\n\ @@ -133,6 +144,7 @@ pub enum CliService { - GIT_REMOTE: Git remote name\n\ - GIT_URL: Git remote URL\n\ - GIT_BRANCH, BRANCH_NAME: Git branch\n\ + - GIT_TAG: Git tag\n\ \n\ ")] AppVeyor(CliServiceArgs), @@ -140,16 +152,21 @@ pub enum CliService { /// Service BuildKite #[clap(name = "buildkite", after_help = "\ Used environment variables for BuildKite:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - - BUILDKITE_BRANCH: Git branch\n\ - - BUILDKITE_BUILD_NUMBER: Service number\n\ - - BUILDKITE_PULL_REQUEST: Service pull request\n\ - - BUILDKITE_BUILD_URL: Service build url\n\ - - BUILDKITE_JOB_ID: Service job id\n\ + - BUILDKITE_COMMIT: Service commit ID\n\ + - BUILDKITE_MESSAGE: Service message\n\ + - BUILDKITE_BRANCH: Service branch\n\ + - BUILDKITE_TAG: Service tag\n\ + - BUILDKITE_PULL_REQUEST: Service pull request\n\ + - BUILDKITE_JOB_ID: Service job id\n\ + - BUILDKITE_BUILD_ID : Service build ID\n\ + - BUILDKITE_BUILD_URL: Service build url\n\ + - BUILDKITE_BUILD_NUMBER: Service number\n\ + - BUILDKITE_BUILD_AUTHOR: Service build author\n\ + - BUILDKITE_BUILD_AUTHOR_EMAIL: Service build author email\n\ + - BUILDKITE_BUILD_CREATOR: Service build creator\n\ + - BUILDKITE_BUILD_CREATOR_EMAIL: Service build creator email\n\ \n\ Common environment variables:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - - COVERALLS_FLAG_NAME: Coveralls flag name\n\ - GIT_ID: Git ID\n\ - GIT_MESSAGE: Git message\n\ - GIT_AUTHOR_NAME: Git author name\n\ @@ -159,6 +176,7 @@ pub enum CliService { - GIT_REMOTE: Git remote name\n\ - GIT_URL: Git remote URL\n\ - GIT_BRANCH, BRANCH_NAME: Git branch\n\ + - GIT_TAG: Git tag\n\ \n\ ")] BuildKite(CliServiceArgs), @@ -166,7 +184,6 @@ pub enum CliService { /// Service Travis #[clap(name = "travis", after_help = "\ Used environment variables for Travis-CI:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - TRAVIS_BRANCH: Git branch\n\ - TRAVIS_BUILD_NUMBER: Service number\n\ - TRAVIS_PULL_REQUEST: Service pull request\n\ @@ -175,8 +192,6 @@ pub enum CliService { - TRAVIS_JOB_NUMBER: Service job number\n\ \n\ Common environment variables:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - - COVERALLS_FLAG_NAME: Coveralls flag name\n\ - GIT_ID: Git ID\n\ - GIT_MESSAGE: Git message\n\ - GIT_AUTHOR_NAME: Git author name\n\ @@ -186,6 +201,7 @@ pub enum CliService { - GIT_REMOTE: Git remote name\n\ - GIT_URL: Git remote URL\n\ - GIT_BRANCH, BRANCH_NAME: Git branch\n\ + - GIT_TAG: Git tag\n\ \n\ ")] Travis(CliServiceArgs), @@ -193,7 +209,6 @@ pub enum CliService { /// Service Semaphore-CI #[clap(name = "semaphore", after_help = "\ Used environment variables for Semaphore-CI:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - SEMAPHORE_GIT_BRANCH: Git branch\n\ - SEMAPHORE_EXECUTABLE_UUID, SEMAPHORE_WORKFLOW_ID: Service number\n\ - SEMAPHORE_BRANCH_ID, SEMAPHORE_GIT_PR_NUMBER: Service pull request\n\ @@ -201,8 +216,6 @@ pub enum CliService { - SEMAPHORE_WORKFLOW_NUMBER: Service job number\n\ \n\ Common environment variables:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - - COVERALLS_FLAG_NAME: Coveralls flag name\n\ - GIT_ID: Git ID\n\ - GIT_MESSAGE: Git message\n\ - GIT_AUTHOR_NAME: Git author name\n\ @@ -212,6 +225,7 @@ pub enum CliService { - GIT_REMOTE: Git remote name\n\ - GIT_URL: Git remote URL\n\ - GIT_BRANCH, BRANCH_NAME: Git branch\n\ + - GIT_TAG: Git tag\n\ \n\ ")] Semaphore(CliServiceArgs), @@ -219,15 +233,12 @@ pub enum CliService { /// Service Jenkins #[clap(name = "jenkins", after_help = "\ Used environment variables for Jenkins:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - BUILD_NUMBER: Service number\n\ - CI_PULL_REQUEST: Service pull request\n\ - BUILD_URL: Service build url\n\ - BUILD_ID: Service job id\n\ \n\ Common environment variables:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - - COVERALLS_FLAG_NAME: Coveralls flag name\n\ - GIT_ID: Git ID\n\ - GIT_MESSAGE: Git message\n\ - GIT_AUTHOR_NAME: Git author name\n\ @@ -237,6 +248,7 @@ pub enum CliService { - GIT_REMOTE: Git remote name\n\ - GIT_URL: Git remote URL\n\ - GIT_BRANCH, BRANCH_NAME: Git branch\n\ + - GIT_TAG: Git tag\n\ \n\ ")] Jenkins(CliServiceArgs), @@ -244,15 +256,27 @@ pub enum CliService { /// Guess service from environment #[clap(name = "env", after_help = "\ Used environment variables in a generic context:\n\ - - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ - - CI_NAME: Service name: \ + - CI_NAME: Service name: \ circleci, travis-ci, appveyor, jenkins, semaphore-ci, github-actions, buildkite\n\ - - CI_BUILD_NUMBER: Service number\n\ - - CI_BUILD_URL: Service build URL\n\ - - CI_JOB_ID: Service job ID\n\ - - CI_JOB_NUMBER: Service job number\n\ - - CI_PULL_REQUEST: Service pull request\n\ - - CI_BRANCH: Git branch\n\ + - CI_JOB_ID: Service job ID\n\ + - CI_JOB_NUMBER: Service job number\n\ + - CI_PULL_REQUEST: Service pull request\n\ + - CI_PROJECT_ID: Service project ID\n\ + - CI_BUILD_ID: Service build ID\n\ + - CI_BUILD_VERSION: Service build version\n\ + - CI_BUILD_NUMBER: Service number\n\ + - CI_BUILD_URL: Service build URL\n\ + - CI_JOB_NAME: Service job name\n\ + - CI_REPO_NAME: Service repo name\n\ + - CI_COMMIT: Service commit ID\n\ + - CI_REMOTE: Service remote name\n\ + - CI_REMOTE_URL: Service remote URL\n\ + - CI_AUTHOR_NAME: Service author name\n\ + - CI_AUTHOR_EMAIL: Service author email\n\ + - CI_COMMITER_NAME: Service committer name\n\ + - CI_COMMITTER_EMAIL: Service committer email\n\ + - CI_BRANCH: Service branch\n\ + - CI_TAG: Service tag\n\ \n\ Used environment variables with Coveralls variables: - COVERALLS_REPO_TOKEN: Coveralls repo token\n\ @@ -277,6 +301,7 @@ pub enum CliService { - GIT_REMOTE: Git remote name\n\ - GIT_URL: Git remote URL\n\ - GIT_BRANCH, BRANCH_NAME: Git branch\n\ + - GIT_TAG: Git tag\n\ \n\ ")] Env, @@ -292,9 +317,21 @@ pub struct CliServiceArgs { #[clap(short='f', long, value_name = "flag_name")] pub flag_name: Option, - /// Service number - #[clap(short='s', long, value_name = "service_number")] - pub service_number: Option, + /// Project ID + #[clap(short='P', long, value_name = "id")] + pub project_id: Option, + + /// Service build ID + #[clap(short='b', long, value_name = "build_id")] + pub service_build_id: Option, + + /// Service build number + #[clap(short='s', long, value_name = "build_number")] + pub service_build_number: Option, + + /// Service build version + #[clap(short='v', long, value_name = "build_version")] + pub service_build_version: Option, /// Service build URL #[clap(short='u', long, value_name = "url")] @@ -308,20 +345,32 @@ pub struct CliServiceArgs { #[clap(short='j', long, value_name = "job_id")] pub service_job_id: Option, + /// Service job name + #[clap(short='n', long, value_name = "job_name")] + pub service_job_name: Option, + /// Service job number - #[clap(short='n', long, value_name = "job_number")] + #[clap(short='i', long, value_name = "job_number")] pub service_job_number: Option, + /// Service repo name + #[clap(short='r', long, value_name = "name")] + pub service_repo_name: Option, + /// Git ID - #[clap(short='k', long, value_name = "id")] + #[clap(short='K', long, value_name = "id")] pub git_id: Option, /// Git branch - #[clap(short='b', long, value_name = "branch")] + #[clap(short='B', long, value_name = "branch")] pub git_branch: Option, + /// Git tag + #[clap(short='T', long, value_name = "tag")] + pub git_tag: Option, + /// Git message - #[clap(short='m', long, value_name = "message")] + #[clap(short='M', long, value_name = "message")] pub git_message: Option, /// Git author name @@ -341,7 +390,7 @@ pub struct CliServiceArgs { pub git_committer_email: Option, /// Git remote name - #[clap(short='r', long, value_name = "name")] + #[clap(short='N', long, value_name = "name")] pub git_remote_name: Option, /// Git remote URL diff --git a/src/config/appveyor.rs b/src/config/appveyor.rs index 42e1906..9803b39 100644 --- a/src/config/appveyor.rs +++ b/src/config/appveyor.rs @@ -1,16 +1,12 @@ use super::{Config, Env, Result}; pub(super) fn load_config(config: &mut Config, env: &Env) -> Result<()> { - if let Some(v) = env.get_var("APPVEYOR_REPO_BRANCH")? { - config.git_branch.replace(v); - } - - if let Some(v) = env.get_var("APPVEYOR_BUILD_ID")? { + if let Some(v) = env.get_var("APPVEYOR_JOB_ID")? { config.service_job_id.replace(v); } if let Some(v) = env.get_var("APPVEYOR_BUILD_NUMBER")? { - config.service_number.replace(v); + config.service_build_number.replace(v); } if let Some(v) = env.get_var("APPVEYOR_PULL_REQUEST_NUMBER")? { @@ -21,5 +17,49 @@ pub(super) fn load_config(config: &mut Config, env: &Env) -> Result<()> { config.service_job_number.replace(v); } + if let Some(v) = env.get_var("APPVEYOR_PROJECT_ID")? { + config.service_project_id.replace(v); + } + + if let Some(v) = env.get_var("APPVEYOR_BUILD_ID")? { + config.service_build_id.replace(v); + } + + if let Some(v) = env.get_var("APPVEYOR_BUILD_VERSION")? { + config.service_build_version.replace(v); + } + + if let Some(v) = env.get_var("APPVEYOR_JOB_NAME")? { + config.service_job_name.replace(v); + } + + if let Some(v) = env.get_var("APPVEYOR_REPO_NAME")? { + config.service_repo_name.replace(v); + } + + if let Some(v) = env.get_var("APPVEYOR_REPO_BRANCH")? { + config.git_branch.replace(v); + } + + if let Some(v) = env.get_var("APPVEYOR_REPO_TAG_NAME")? { + config.git_tag.replace(v); + } + + if let Some(v) = env.get_var("APPVEYOR_REPO_COMMIT")? { + config.git_id.replace(v); + } + + if let Some(v) = env.get_var("APPVEYOR_REPO_COMMIT_MESSAGE")? { + config.git_message.replace(v); + } + + if let Some(v) = env.get_var("APPVEYOR_REPO_COMMIT_AUTHOR")? { + config.git_author_name.replace(v); + } + + if let Some(v) = env.get_var("APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL")? { + config.git_author_email.replace(v); + } + Ok(()) } diff --git a/src/config/buildkite.rs b/src/config/buildkite.rs index 202d66f..2555267 100644 --- a/src/config/buildkite.rs +++ b/src/config/buildkite.rs @@ -1,25 +1,57 @@ use super::{Config, Env, Result}; pub(super) fn load_config(config: &mut Config, env: &Env) -> Result<()> { - if let Some(v) = env.get_var("BUILDKITE_BRANCH")? { - config.git_branch.replace(v); - } - if let Some(v) = env.get_var("BUILDKITE_JOB_ID")? { config.service_job_id.replace(v); } - if let Some(v) = env.get_var("BUILDKITE_BUILD_NUMBER")? { - config.service_number.replace(v); + if let Some(v) = env.get_var("BUILDKITE_BUILD_ID ")? { + config.service_build_id.replace(v); } if let Some(v) = env.get_var("BUILDKITE_PULL_REQUEST")? { config.service_pull_request.replace(v); } + if let Some(v) = env.get_var("BUILDKITE_BUILD_NUMBER")? { + config.service_build_number.replace(v); + } + if let Some(v) = env.get_var("BUILDKITE_BUILD_URL")? { config.service_build_url.replace(v); } + if let Some(v) = env.get_var("BUILDKITE_COMMIT")? { + config.git_id.replace(v); + } + + if let Some(v) = env.get_var("BUILDKITE_MESSAGE")? { + config.git_message.replace(v); + } + + if let Some(v) = env.get_var("BUILDKITE_BRANCH")? { + config.git_branch.replace(v); + } + + if let Some(v) = env.get_var("BUILDKITE_TAG")? { + config.git_tag.replace(v); + } + + if let Some(v) = env.get_var("BUILDKITE_BUILD_AUTHOR")? { + config.git_author_name.replace(v); + } + + if let Some(v) = env.get_var("BUILDKITE_BUILD_AUTHOR_EMAIL")? { + config.git_author_email.replace(v); + } + + if let Some(v) = env.get_var("BUILDKITE_BUILD_CREATOR")? { + config.git_committer_name.replace(v); + } + + if let Some(v) = env.get_var("BUILDKITE_BUILD_CREATOR_EMAIL")? { + config.git_committer_email.replace(v); + } + Ok(()) } diff --git a/src/config/circleci.rs b/src/config/circleci.rs index f0eab63..35ad4aa 100644 --- a/src/config/circleci.rs +++ b/src/config/circleci.rs @@ -1,20 +1,20 @@ use super::{Config, Env, Result}; pub(super) fn load_config(config: &mut Config, env: &Env) -> Result<()> { - if let Some(v) = env.get_var("CIRCLE_BRANCH")? { - config.git_branch.replace(v); + if let Some(v) = env.get_var("CIRCLE_PROJECT_ID")? { + config.service_project_id.replace(v); } if let Some(v) = env.get_var("CIRCLE_WORKFLOW_JOB_ID")? { config.service_job_id.replace(v); } - if let Some(v) = env.get_var("CIRCLE_WORKFLOW_ID")? { - config.service_number.replace(v); + if let Some(v) = env.get_var("CIRCLE_BUILD_NUM")? { + config.service_build_number.replace(v); } - if let Some(v) = env.get_var("CIRCLE_BUILD_NUM")? { - config.service_number.replace(v); + if let Some(v) = env.get_var("CIRCLE_JOB")? { + config.service_job_name.replace(v); } if let Some(v) = env.get_var("CIRCLE_PULL_REQUEST")? { @@ -25,5 +25,17 @@ pub(super) fn load_config(config: &mut Config, env: &Env) -> Result<()> { config.service_build_url.replace(v); } + if let Some(v) = env.get_var("CIRCLE_BRANCH")? { + config.git_branch.replace(v); + } + + if let Some(v) = env.get_var("CIRCLE_TAG")? { + config.git_tag.replace(v); + } + + if let Some(v) = env.get_var("CIRCLE_SHA1")? { + config.git_id.replace(v); + } + Ok(()) } diff --git a/src/config/coveralls_env.rs b/src/config/coveralls_env.rs index b7e3a5c..4e416a8 100644 --- a/src/config/coveralls_env.rs +++ b/src/config/coveralls_env.rs @@ -2,7 +2,7 @@ use super::{Config, Env, Result}; pub(super) fn load_config(config: &mut Config, env: &Env) -> Result<()> { if let Some(v) = env.get_var("COVERALLS_SERVICE_NUMBER")? { - config.service_number.replace(v); + config.service_build_number.replace(v); } if let Some(v) = env.get_var("COVERALLS_BUILD_URL")? { diff --git a/src/config/generic.rs b/src/config/generic.rs index 5777319..d7137de 100644 --- a/src/config/generic.rs +++ b/src/config/generic.rs @@ -1,18 +1,34 @@ use super::{Config, Env, Result}; pub(super) fn load_config(config: &mut Config, env: &Env) -> Result<()> { + if let Some(v) = env.get_var("CI_PROJECT_ID")? { + config.service_project_id.replace(v); + } + if let Some(v) = env.get_var("CI_BUILD_NUMBER")? { - config.service_number.replace(v); + config.service_build_number.replace(v); + } + + if let Some(v) = env.get_var("CI_BUILD_ID")? { + config.service_build_id.replace(v); } if let Some(v) = env.get_var("CI_BUILD_URL")? { config.service_build_url.replace(v); } + if let Some(v) = env.get_var("CI_BUILD_VERSION")? { + config.service_build_version.replace(v); + } + if let Some(v) = env.get_var("CI_JOB_ID")? { config.service_job_id.replace(v); } + if let Some(v) = env.get_var("CI_JOB_NAME")? { + config.service_job_name.replace(v); + } + if let Some(v) = env.get_var("CI_JOB_NUMBER")? { config.service_job_number.replace(v); } @@ -21,9 +37,45 @@ pub(super) fn load_config(config: &mut Config, env: &Env) -> Result<()> { config.service_pull_request.replace(v); } + if let Some(v) = env.get_var("CI_REPO_NAME")? { + config.service_repo_name.replace(v); + } + + if let Some(v) = env.get_var("CI_COMMIT")? { + config.git_id.replace(v); + } + + if let Some(v) = env.get_var("CI_REMOTE")? { + config.git_remote_name.replace(v); + } + + if let Some(v) = env.get_var("CI_REMOTE_URL")? { + config.git_remote_url.replace(v); + } + + if let Some(v) = env.get_var("CI_AUTHOR_NAME")? { + config.git_author_name.replace(v); + } + + if let Some(v) = env.get_var("CI_AUTHOR_EMAIL")? { + config.git_author_email.replace(v); + } + + if let Some(v) = env.get_var("CI_COMMITER_NAME")? { + config.git_committer_name.replace(v); + } + + if let Some(v) = env.get_var("CI_COMMITTER_EMAIL")? { + config.git_committer_email.replace(v); + } + if let Some(v) = env.get_var("CI_BRANCH")? { config.git_branch.replace(v); } + if let Some(v) = env.get_var("CI_TAG")? { + config.git_tag.replace(v); + } + Ok(()) } diff --git a/src/config/github_actions.rs b/src/config/github_actions.rs index f5093d5..c965906 100644 --- a/src/config/github_actions.rs +++ b/src/config/github_actions.rs @@ -10,7 +10,7 @@ pub(super) fn load_config(config: &mut Config, env: &Env) -> Result<()> { } if let Some(v) = env.get_var("GITHUB_RUN_ID")? { - config.service_number.replace(v); + config.service_build_number.replace(v); } if let Some(v) = env.get_github_actions_pull_request()? { diff --git a/src/config/jenkins.rs b/src/config/jenkins.rs index a5a8fd4..ed812f5 100644 --- a/src/config/jenkins.rs +++ b/src/config/jenkins.rs @@ -6,7 +6,7 @@ pub(super) fn load_config(config: &mut Config, env: &Env) -> Result<()> { } if let Some(v) = env.get_var("BUILD_NUMBER")? { - config.service_number.replace(v); + config.service_build_number.replace(v); } if let Some(v) = env.get_var("CI_PULL_REQUEST")? { diff --git a/src/config/mod.rs b/src/config/mod.rs index 7442c8c..9880c34 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -18,12 +18,18 @@ pub struct Config { pub(crate) service: Service, pub(crate) flag_name: Option, pub(crate) repo_token: Option, - pub(crate) service_number: Option, + pub(crate) service_project_id: Option, + pub(crate) service_build_id: Option, + pub(crate) service_build_version: Option, + pub(crate) service_build_number: Option, pub(crate) service_build_url: Option, pub(crate) service_pull_request: Option, pub(crate) service_job_id: Option, + pub(crate) service_job_name: Option, pub(crate) service_job_number: Option, + pub(crate) service_repo_name: Option, pub(crate) git_id: Option, + pub(crate) git_tag: Option, pub(crate) git_branch: Option, pub(crate) git_message: Option, pub(crate) git_author_name: Option, @@ -43,11 +49,16 @@ impl Config { service, flag_name: env.get_var("COVERALLS_FLAG_NAME")?, repo_token: env.get_var("COVERALLS_REPO_TOKEN")?, - service_number: None, + service_project_id: None, + service_build_id: None, + service_build_version: None, + service_build_number: None, service_build_url: None, service_pull_request: None, service_job_id: None, + service_job_name: None, service_job_number: None, + service_repo_name: None, param_prune_absolutes: false, param_prune_dirs: vec![], param_src_prefix: None, @@ -59,10 +70,11 @@ impl Config { git_committer_email: env.get_var("GIT_COMMITTER_EMAIL")?, git_remote_name: env.get_var("GIT_REMOTE")?, git_remote_url: env.get_var("GIT_URL")?, + git_tag: env.get_var("GIT_TAG")?, git_branch: match env.get_var("GIT_BRANCH")? { Some(v) => Some(v), None => env.get_var("BRANCH_NAME")?, - } + }, }) } @@ -127,16 +139,28 @@ impl Config { } fn configure(&mut self, args: &CliServiceArgs) { + if let Some(v) = &args.flag_name { + self.flag_name.replace(v.clone()); + } + if let Some(v) = &args.repo_token { self.repo_token.replace(v.clone()); } - if let Some(v) = &args.flag_name { - self.flag_name.replace(v.clone()); + if let Some(v) = &args.service_repo_name { + self.service_repo_name.replace(v.clone()); + } + + if let Some(v) = &args.service_build_id { + self.service_build_id.replace(v.clone()); + } + + if let Some(v) = &args.service_build_number { + self.service_build_number.replace(v.clone()); } - if let Some(v) = &args.service_number { - self.service_number.replace(v.clone()); + if let Some(v) = &args.service_build_version { + self.service_build_version.replace(v.clone()); } if let Some(v) = &args.service_build_url { @@ -151,6 +175,10 @@ impl Config { self.service_job_id.replace(v.clone()); } + if let Some(v) = &args.service_job_name { + self.service_job_name.replace(v.clone()); + } + if let Some(v) = &args.service_job_number { self.service_job_number.replace(v.clone()); } @@ -163,6 +191,10 @@ impl Config { self.git_branch.replace(v.clone()); } + if let Some(v) = &args.git_tag { + self.git_tag.replace(v.clone()); + } + if let Some(v) = &args.git_message { self.git_message.replace(v.clone()); } @@ -212,28 +244,33 @@ impl Config { let source_prefix = self.param_src_prefix.as_ref().map(helpers::path_to_string).unwrap_or_else(String::new); println!("Parameters:"); - println!("Prune absolute paths: {}", self.param_prune_absolutes); - println!("Prune directories: .. [{}]", prune_dirs); - println!("Source prefix: ...... [{}]", source_prefix); + println!("Prune absolute paths: {}", self.param_prune_absolutes); + println!("Prune directories: ... [{}]", prune_dirs); + println!("Source prefix: ....... [{}]", source_prefix); println!(); println!("Configuration:"); - println!("Service name: ....... {}", self.service.get_name()); - println!("Repo token: ......... [{}]", self.repo_token.as_ref().unwrap_or(&empty)); - println!("Flag name: .......... [{}]", self.flag_name.as_ref().unwrap_or(&empty)); - println!("Service number: ..... [{}]", self.service_number.as_ref().unwrap_or(&empty)); - println!("Service build URL: .. [{}]", self.service_build_url.as_ref().unwrap_or(&empty)); - println!("Service pull request: [{}]", self.service_pull_request.as_ref().unwrap_or(&empty)); - println!("Service job id: ..... [{}]", self.service_job_id.as_ref().unwrap_or(&empty)); - println!("Service job number: . [{}]", self.service_job_number.as_ref().unwrap_or(&empty)); - println!("Git ID: ............. [{}]", self.git_id.as_ref().unwrap_or(&empty)); - println!("Git branch: ......... [{}]", self.git_branch.as_ref().unwrap_or(&empty)); - println!("Git author name: .... [{}]", self.git_author_name.as_ref().unwrap_or(&empty)); - println!("Git author email: ... [{}]", self.git_author_email.as_ref().unwrap_or(&empty)); - println!("Git committer name: . [{}]", self.git_committer_name.as_ref().unwrap_or(&empty)); - println!("Git committer email: [{}]", self.git_committer_email.as_ref().unwrap_or(&empty)); - println!("Git remote name: .... [{}]", self.git_remote_name.as_ref().unwrap_or(&empty)); - println!("Git remote URL: ..... [{}]", self.git_remote_url.as_ref().unwrap_or(&empty)); - println!("Git message: ........ [{}]", self.git_message.as_ref().unwrap_or(&empty)); + println!("Service name: ........ {}", self.service.get_name()); + println!("Repo token: .......... [{}]", self.repo_token.as_ref().unwrap_or(&empty)); + println!("Repo name: ........... [{}]", self.service_repo_name.as_ref().unwrap_or(&empty)); + println!("Flag name: ........... [{}]", self.flag_name.as_ref().unwrap_or(&empty)); + println!("Service build ID: .... [{}]", self.service_build_id.as_ref().unwrap_or(&empty)); + println!("Service build number: [{}]", self.service_build_number.as_ref().unwrap_or(&empty)); + println!("Service build version: [{}]", self.service_build_version.as_ref().unwrap_or(&empty)); + println!("Service build URL: ... [{}]", self.service_build_url.as_ref().unwrap_or(&empty)); + println!("Service pull request: [{}]", self.service_pull_request.as_ref().unwrap_or(&empty)); + println!("Service job ID: ...... [{}]", self.service_job_id.as_ref().unwrap_or(&empty)); + println!("Service job name: .... [{}]", self.service_job_name.as_ref().unwrap_or(&empty)); + println!("Service job number: .. [{}]", self.service_job_number.as_ref().unwrap_or(&empty)); + println!("Git ID: .............. [{}]", self.git_id.as_ref().unwrap_or(&empty)); + println!("Git branch: .......... [{}]", self.git_branch.as_ref().unwrap_or(&empty)); + println!("Git tag: ............. [{}]", self.git_tag.as_ref().unwrap_or(&empty)); + println!("Git author name: ..... [{}]", self.git_author_name.as_ref().unwrap_or(&empty)); + println!("Git author email: .... [{}]", self.git_author_email.as_ref().unwrap_or(&empty)); + println!("Git committer name: .. [{}]", self.git_committer_name.as_ref().unwrap_or(&empty)); + println!("Git committer email: . [{}]", self.git_committer_email.as_ref().unwrap_or(&empty)); + println!("Git remote name: ..... [{}]", self.git_remote_name.as_ref().unwrap_or(&empty)); + println!("Git remote URL: ...... [{}]", self.git_remote_url.as_ref().unwrap_or(&empty)); + println!("Git message: ......... [{}]", self.git_message.as_ref().unwrap_or(&empty)); println!(); } } diff --git a/src/config/semaphore.rs b/src/config/semaphore.rs index 1aa6cc3..bb28a21 100644 --- a/src/config/semaphore.rs +++ b/src/config/semaphore.rs @@ -17,12 +17,12 @@ pub(super) fn load_config(config: &mut Config, env: &Env) -> Result<()> { // Classic if let Some(v) = env.get_var("SEMAPHORE_EXECUTABLE_UUID")? { - config.service_number.replace(v); + config.service_build_number.replace(v); } // 2.0 if let Some(v) = env.get_var("SEMAPHORE_WORKFLOW_ID")? { - config.service_number.replace(v); + config.service_build_number.replace(v); } // Classic diff --git a/src/config/travis.rs b/src/config/travis.rs index 9d21c1c..e532b57 100644 --- a/src/config/travis.rs +++ b/src/config/travis.rs @@ -10,7 +10,7 @@ pub(super) fn load_config(config: &mut Config, env: &Env) -> Result<()> { } if let Some(v) = env.get_var("TRAVIS_BUILD_NUMBER")? { - config.service_number.replace(v); + config.service_build_number.replace(v); } if let Some(v) = env.get_var("TRAVIS_PULL_REQUEST")? { diff --git a/src/coverralls.rs b/src/coverralls.rs index e893810..0702ee7 100644 --- a/src/coverralls.rs +++ b/src/coverralls.rs @@ -35,7 +35,7 @@ impl CoverallsManager { coverage.flag_name.replace(v.clone()); } - if let Some(v) = config.service_number.as_ref() { + if let Some(v) = config.service_build_number.as_ref() { coverage.service_number = v.clone(); }