Skip to content
Snippets Groups Projects
Verified Commit a6e4a9b4 authored by Geoffrey Arthaud's avatar Geoffrey Arthaud
Browse files

Improve CI

parent 8371ec1f
No related branches found
No related tags found
No related merge requests found
/target
.idea
.cargo
*
!.gitignore
variables:
RUST_VERSION: 1.76 # slim or alpine not adapted because of openSSL dependency
TARGET_ARCH: default
CARGO_HOME: .cargo
default:
cache:
key: rust-$TARGET_ARCH
paths:
- .cargo
- target/debug/deps
- target/debug/build
- target/release/deps
- target/release/build
- target/$TARGET_ARCH/release/deps
- target/$TARGET_ARCH/release/build
policy: pull-push
stages:
- build_test
- release
......@@ -5,44 +23,56 @@ stages:
include:
- remote: 'https://api.r2devops.io/job/r/gitlab/r2devops/hub/docker_build@latest.yaml'
- remote: 'https://api.r2devops.io/job/r/gitlab/r2devops/hub/gitleaks@latest.yaml'
check-format:
stage: build_test
image: rust:latest
image: rust:$RUST_VERSION
script:
- rustup component add rustfmt
- rustup component add clippy
- cargo fmt --all -- --check
- cargo clippy -- -D warnings
allow_failure: true
test-rust-latest:
gitleaks:
stage: build_test
image: rust:latest
test-rust-current:
stage: build_test
image: rust:$RUST_VERSION
script:
- cargo test --verbose
rules:
- if: $CI_COMMIT_REF_NAME == 'main'
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
test-rust-nightly:
stage: build_test
extends: test-rust-current
image: rustlang/rust:nightly
script:
- cargo test --verbose
allow_failure: true
.rust-release:
stage: release
variables:
TARGET: target/$TARGET_ARCH/release/gitlab-project-doctor
PKG_VERSION: ${CI_COMMIT_TAG:-latest}
script:
- rustup target add $TARGET_ARCH
- cargo build $CARGO_OPTS --target $TARGET_ARCH --release
- strip $TARGET
- $LDD_CMD $TARGET
- $TARGET --help
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/$TARGET_ARCH/$PKG_VERSION/gitlab-project-doctor" -O'
artifacts:
paths:
- $TARGET
rules:
- if: $CI_COMMIT_REF_NAME == 'main'
- if: $CI_COMMIT_TAG
release-linux:
extends: .rust-release
image: rust:latest
image: rust:$RUST_VERSION
variables:
TARGET_ARCH: x86_64-unknown-linux-musl
LDD_CMD: ldd
......@@ -70,9 +100,25 @@ release-macos-x86:
docker_build:
stage: deploy
variables:
COMMIT_CREATE_LATEST: "false"
IMAGE_TAG: "v1.19.2-debug"
retry: 2
needs:
- release-linux
cache: []
rules:
- if: $CI_COMMIT_REF_NAME == 'main'
docker_build-prod:
stage: deploy
extends: docker_build
variables:
COMMIT_CREATE_LATEST: "true"
IMAGE_TAG: "v1.19.2-debug"
retry: 2
needs:
- release-linux
cache: []
rules:
- if: $CI_COMMIT_TAG
\ No newline at end of file
......@@ -18,4 +18,7 @@ pub use self::packages::Packages;
mod delete_file;
mod package;
mod package_files;
// Naming convention extends gitlab crate
#[allow(clippy::module_inception)]
mod packages;
......@@ -54,7 +54,7 @@ impl Reportable for ContainerAnalysisReport {
}
impl ContainerAnalysisJob {
fn to_report(
fn into_report(
self,
report_status: Vec<ReportStatus>,
containers: Vec<GitlabContainerRepository>,
......@@ -108,7 +108,7 @@ impl ReportJob for ContainerAnalysisJob {
pending_msg: fl!("container-analysing"),
job: std::thread::spawn(move || {
if !self.project.jobs_enabled {
return self.to_report(vec![ReportStatus::NA(fl!("no-cicd"))], vec![]);
return self.into_report(vec![ReportStatus::NA(fl!("no-cicd"))], vec![]);
}
let endpoint = api::registry::Repositories::builder()
......@@ -119,7 +119,7 @@ impl ReportJob for ContainerAnalysisJob {
let query: Result<Vec<GitlabRawContainerRepository>, _> =
gitlab::api::paged(endpoint, Pagination::All).query(&self.gitlab);
match query {
Err(e) => self.to_report(
Err(e) => self.into_report(
vec![ReportStatus::ERROR(format!(
"{} {}",
fl!("error"),
......@@ -144,7 +144,7 @@ impl ReportJob for ContainerAnalysisJob {
.iter()
.map(|cr| cr.tags.iter().filter(|t| t.created_at < ref_date).count())
.sum();
self.to_report(
self.into_report(
vec![
warning_if(
registry_size > CONTAINER_REGISTRY_LIMIT,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment