diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ca5add798923035947962cfe5612881422fb34ee..6d2cd0405b03d44fac09916c11bf74cb9224e419 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,6 +45,9 @@ include: forceBuild: true Dockerfile: ${CI_PROJECT_DIR}/Dockerfile +copy-image-rust: + cache: [ ] + release-gpd-image: needs: - release-linux @@ -68,6 +71,7 @@ test-rust-current: script: - cargo test --verbose - cargo run -- $TEST_OPTIONS + - cargo run -- $TEST_OPTIONS --token $TEST_GL_TOKEN allow_failure: true test-rust-nightly: @@ -124,6 +128,8 @@ release-macos-silicon: LDD_CMD: otool -L tags: - macos_mx + rules: + - if: $CI_COMMIT_TAG release-macos-x86: extends: .rust-release @@ -133,6 +139,8 @@ release-macos-x86: LDD_CMD: otool -L tags: - macos_mx + rules: + - if: $CI_COMMIT_TAG release-windows: extends: .rust-release diff --git a/i18n/fr-FR/gitlab_project_doctor.ftl b/i18n/fr-FR/gitlab_project_doctor.ftl index 43999a624d6d02dfd432d9f40b129839e92b9626..d9520e8d4c9abffa35d1fff1c6bf09530f71e650 100644 --- a/i18n/fr-FR/gitlab_project_doctor.ftl +++ b/i18n/fr-FR/gitlab_project_doctor.ftl @@ -9,7 +9,7 @@ container-policy-disabled = L'option "Clean up image tags" est désactivée. container-policy-enabled = L'option "Clean up image tags" est activée container-report = {$image_count} images dans le container registry. {$old_image_count} datent de plus de {$nb_days} jours container-summary = Taille du container registry : {$registry_size} -duplicate-assets-option-error = Cannot get the number of duplicate assets to keep option +duplicate-assets-option-error = Impossible d'accéder à l'option "The number of duplicate assets to keep" duplicate-assets-option-onepackage = L'option "The number of duplicate assets to keep" vaut 1 duplicate-assets-option-warn = L'option "The number of duplicate assets to keep" ne vaut PAS 1 error = Erreur : diff --git a/src/diagnosis/conf_analysis.rs b/src/diagnosis/conf_analysis.rs index f5b9034006a84d2cbdc2c61f283f81b9ed2dde13..f8384edb0becb715d7359472d9f66739f52f24d9 100644 --- a/src/diagnosis/conf_analysis.rs +++ b/src/diagnosis/conf_analysis.rs @@ -1,11 +1,13 @@ -use crate::diagnosis::gitlab_connection::Project; -use crate::{fl, GitlabRepository, ReportJob, ReportPending, ReportStatus, Reportable}; use gitlab::Gitlab; use graphql_client::*; +use crate::diagnosis::gitlab_connection::{GitlabToken, Project}; +use crate::{fl, GitlabRepository, ReportJob, ReportPending, ReportStatus, Reportable}; + pub struct ConfAnalysisJob { pub gitlab: Gitlab, pub project: Project, + pub job_token: bool, } pub struct ConfAnalysisReport { @@ -66,6 +68,7 @@ impl ConfAnalysisJob { ConfAnalysisJob { gitlab: gitlab.gitlab.clone(), project: gitlab.project.clone(), + job_token: matches!(&gitlab.token, GitlabToken::JobToken(_)), } } @@ -85,6 +88,9 @@ impl ConfAnalysisJob { } fn _report_duplicate_policy(&self) -> ReportStatus { + if self.job_token { + return ReportStatus::ERROR(fl!("duplicate-assets-option-error")); + } if let Some(policy) = self._get_duplicate_policy() { return if let conf_package_duplicate_query::PackagesCleanupKeepDuplicatedPackageFilesEnum::ONE_PACKAGE_FILE = policy { ReportStatus::OK(fl!("duplicate-assets-option-onepackage")) @@ -102,15 +108,11 @@ impl ConfAnalysisJob { project_path: self.project.path_with_namespace.to_string(), }; let query = ConfPackageDuplicateQuery::build_query(variables); - let response = self - .gitlab + self.gitlab .graphql::<ConfPackageDuplicateQuery>(&query) - .unwrap(); - Some( - response - .project? - .packages_cleanup_policy? - .keep_n_duplicated_package_files, - ) + .ok() + .and_then(|r| r.project) + .and_then(|r| r.packages_cleanup_policy) + .map(|r| r.keep_n_duplicated_package_files) } }