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

Refactored CI

parent 29b46f21
No related branches found
No related tags found
1 merge request!2Refactored CI
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
variables: variables:
RUST_VERSION: "1.76" # slim or alpine not adapted because of openSSL dependency RUST_VERSION: "1.79" # slim or alpine not adapted because of openSSL dependency
TARGET_ARCH: default TARGET_ARCH: default
CARGO_HOME: .cargo CARGO_HOME: .cargo
TEST_OPTIONS: --url $CI_PROJECT_URL -a TEST_OPTIONS: --url $CI_PROJECT_URL -a
...@@ -14,30 +20,47 @@ default: ...@@ -14,30 +20,47 @@ default:
policy: pull-push policy: pull-push
stages: stages:
- prepare
- build_test - build_test
- release - release
- deploy - deploy
- deploy_test - deploy_test
include: include:
- remote: 'https://gitlab.com/r2devops/hub/-/raw/docker_build@2.0.2/jobs/docker_build/docker_build.yml' - component: ${CI_SERVER_FQDN}/share/components/oci-copier/crane@~latest
- remote: 'https://gitlab.com/r2devops/hub/-/raw/gitleaks@1.2.2/jobs/gitleaks/gitleaks.yml' inputs:
as: copy-image-rust
gitleaks: stage: prepare
stage: build_test imageNameToCopy: rust
imageTagToCopy: $RUST_VERSION
copiedImageDigest: "RUST"
- component: $CI_SERVER_FQDN/share/components/oci-builder/podman@~latest
inputs:
as: release-gpd-image
stage: deploy
targetImageAppName: ${CI_PROJECT_NAME}
targetImageAppTag: $VERSION
targetImageRegistry: ${CI_REGISTRY}/${CI_PROJECT_NAMESPACE}
targetImageRegistryDigestName: "GPD"
forceBuild: true
Dockerfile: ${CI_PROJECT_DIR}/Dockerfile
release-gpd-image:
needs:
- release-linux
cache: [ ] cache: [ ]
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
check-format: check-format:
stage: build_test stage: build_test
image: rust:$RUST_VERSION image: ${REGISTRY_IMAGE_RUST}
script: script:
- rustup component add rustfmt - rustup component add rustfmt
- rustup component add clippy - rustup component add clippy
- cargo fmt --all -- --check - cargo fmt --all -- --check
- cargo clippy -- -D warnings - cargo clippy -- -D warnings
rules:
- if: $CI_COMMIT_REF_NAME == 'main'
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
test-rust-current: test-rust-current:
stage: build_test stage: build_test
...@@ -46,16 +69,15 @@ test-rust-current: ...@@ -46,16 +69,15 @@ test-rust-current:
- cargo test --verbose - cargo test --verbose
- cargo run -- $TEST_OPTIONS - cargo run -- $TEST_OPTIONS
allow_failure: true allow_failure: true
rules:
- if: $CI_COMMIT_REF_NAME == 'main'
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
test-rust-nightly: test-rust-nightly:
extends: test-rust-current extends: test-rust-current
image: rustlang/rust:nightly image: rustlang/rust:nightly
allow_failure: true
test-clean-rust-current: test-clean-rust-current:
extends: test-rust-current extends: test-rust-current
allow_failure: true
variables: variables:
TEST_OPTIONS: $CLEAN_OPTIONS TEST_OPTIONS: $CLEAN_OPTIONS
...@@ -68,18 +90,25 @@ test-clean-rust-current: ...@@ -68,18 +90,25 @@ test-clean-rust-current:
- rustup target add $TARGET_ARCH - rustup target add $TARGET_ARCH
- cargo build $CARGO_OPTS --target $TARGET_ARCH --release - cargo build $CARGO_OPTS --target $TARGET_ARCH --release
- if [ -z "$NO_POSTPROCESS" ]; then strip $TARGET; $LDD_CMD $TARGET; $TARGET $TEST_OPTIONS; fi - if [ -z "$NO_POSTPROCESS" ]; then strip $TARGET; $LDD_CMD $TARGET; $TARGET $TEST_OPTIONS; fi
- 'if [ -z "$DEBUG" ]; then curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file $TARGET "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/$TARGET_ARCH/${CI_COMMIT_TAG:-latest}/$APP_NAME"; fi' - export VERSION=${CI_COMMIT_TAG:-latest}
- echo "VERSION=${VERSION}" > release.env
- 'if [ -z "$DEBUG" ]; then curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file $TARGET "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/$TARGET_ARCH/${VERSION}/$APP_NAME"; fi'
artifacts: artifacts:
paths: paths:
- $TARGET - $TARGET
reports:
dotenv: release.env
allow_failure: true allow_failure: true
rules: rules:
- if: $CI_COMMIT_REF_NAME == 'main' - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
needs:
- copy-image-rust
- test-rust-current
release-linux: release-linux:
extends: .rust-release extends: .rust-release
image: rust:$RUST_VERSION image: ${REGISTRY_IMAGE_RUST}
variables: variables:
TARGET_ARCH: x86_64-unknown-linux-musl TARGET_ARCH: x86_64-unknown-linux-musl
LDD_CMD: ldd LDD_CMD: ldd
...@@ -107,7 +136,7 @@ release-macos-x86: ...@@ -107,7 +136,7 @@ release-macos-x86:
release-windows: release-windows:
extends: .rust-release extends: .rust-release
image: rust:$RUST_VERSION image: ${REGISTRY_IMAGE_RUST}
variables: variables:
TARGET_ARCH: x86_64-pc-windows-gnu TARGET_ARCH: x86_64-pc-windows-gnu
APP_NAME: gitlab-project-doctor.exe APP_NAME: gitlab-project-doctor.exe
...@@ -116,18 +145,6 @@ release-windows: ...@@ -116,18 +145,6 @@ release-windows:
- apt-get update - apt-get update
- apt-get install -y lld gcc-mingw-w64-x86-64 - apt-get install -y lld gcc-mingw-w64-x86-64
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'
test-release-docker: test-release-docker:
stage: deploy_test stage: deploy_test
image: $CI_REGISTRY/pub/numeco/gitlab-project-doctor:$CI_COMMIT_SHA image: $CI_REGISTRY/pub/numeco/gitlab-project-doctor:$CI_COMMIT_SHA
...@@ -135,9 +152,10 @@ test-release-docker: ...@@ -135,9 +152,10 @@ test-release-docker:
- gitlab-project-doctor --url $CI_PROJECT_URL -a - gitlab-project-doctor --url $CI_PROJECT_URL -a
cache: [ ] cache: [ ]
needs: needs:
- docker_build - release-gpd-image
rules: rules:
- if: $CI_COMMIT_REF_NAME == 'main' - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
test-release-linux: test-release-linux:
stage: deploy_test stage: deploy_test
...@@ -149,17 +167,5 @@ test-release-linux: ...@@ -149,17 +167,5 @@ test-release-linux:
- chmod +x gitlab-project-doctor - chmod +x gitlab-project-doctor
- ./gitlab-project-doctor --url $CI_PROJECT_URL -a - ./gitlab-project-doctor --url $CI_PROJECT_URL -a
rules: rules:
- if: $CI_COMMIT_REF_NAME == 'main' - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment