feat: simplify ci/cd pipeline
This commit is contained in:
parent
6cd774b886
commit
7160b5a24b
1 changed files with 15 additions and 173 deletions
188
.gitlab-ci.yml
188
.gitlab-ci.yml
|
@ -1,178 +1,20 @@
|
|||
stages:
|
||||
- check
|
||||
- build
|
||||
- test
|
||||
- docker
|
||||
- test-2
|
||||
- release
|
||||
- deploy
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE != 'push' || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG
|
||||
when: always
|
||||
- when: never
|
||||
|
||||
.rust-default:
|
||||
image: registry.gitlab.com/tobip64/rust-gitlab-ci:latest
|
||||
cache:
|
||||
- key: $CI_COMMIT_REF
|
||||
paths: [ target/ ]
|
||||
- key: cargo
|
||||
paths: [ cargo/ ]
|
||||
interruptible: true
|
||||
timeout: 30m
|
||||
variables:
|
||||
CARGO_HOME: $CI_PROJECT_DIR/cargo
|
||||
CACHE_FALLBACK_KEY: $CI_DEFAULT_BRANCH
|
||||
parallel:
|
||||
matrix:
|
||||
- CHANNEL: [ stable ]
|
||||
rules:
|
||||
- if: $CHANNEL == "stable"
|
||||
allow_failure: false
|
||||
- allow_failure: true
|
||||
before_script:
|
||||
- rustup --version && rustc --version && cargo --version && echo $RUSTFLAGS && echo $CARGO_OPTS
|
||||
|
||||
check:clippy:
|
||||
extends: .rust-default
|
||||
stage: check
|
||||
script:
|
||||
- 'cargo +$CHANNEL clippy
|
||||
--color always
|
||||
--verbose
|
||||
--all-targets
|
||||
--all-features
|
||||
--message-format=json
|
||||
$CARGO_OPTS
|
||||
| gitlab-report -p clippy > gl-code-quality-report.json'
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
codequality: gl-code-quality-report.json
|
||||
|
||||
check:fmt:
|
||||
extends: .rust-default
|
||||
stage: check
|
||||
parallel:
|
||||
rules:
|
||||
- if: $RUN_RUST_FMT
|
||||
script:
|
||||
- cargo +stable fmt $CARGO_OPTS -- --check
|
||||
allow_failure: true
|
||||
- test
|
||||
- build
|
||||
- publish
|
||||
|
||||
tests:
|
||||
stage: test
|
||||
image: rust
|
||||
script:
|
||||
- cargo test
|
||||
|
||||
build:
|
||||
extends: .rust-default
|
||||
stage: build
|
||||
needs: [ "check:clippy" ]
|
||||
timeout: 1h
|
||||
parallel:
|
||||
matrix:
|
||||
- CHANNEL: [ stable, beta, nightly ]
|
||||
PROFILE: [ debug, release ]
|
||||
TARGET:
|
||||
- x86_64-unknown-linux-musl
|
||||
- aarch64-unknown-linux-musl
|
||||
- mips64el-unknown-linux-muslabi64
|
||||
- wasm32-wasi
|
||||
CARGO_OPTS: [ "--workspace --all-targets --all-features" ]
|
||||
script:
|
||||
- cargo +$CHANNEL build --verbose --color always --target $TARGET $([[ $PROFILE == "release" ]] && echo "--release" || echo "") $CARGO_OPTS
|
||||
artifacts:
|
||||
paths:
|
||||
- target/$TARGET/$PROFILE/*
|
||||
- Dockerfile
|
||||
|
||||
# requires nightly
|
||||
.build:multiarch:
|
||||
extends: .rust-default
|
||||
stage: build
|
||||
needs: [ "check:clippy" ]
|
||||
timeout: 1h
|
||||
parallel:
|
||||
matrix:
|
||||
- CHANNEL: [ nightly ]
|
||||
PROFILE: [ debug, release ]
|
||||
CARGO_OPTS: [ "--workspace --all-targets --all-features" ]
|
||||
script:
|
||||
- '[[ $PROFILE == "debug" ]] && export RUSTFLAGS="$RUSTFLAGS -Zinstrument-coverage" || true'
|
||||
- 'cargo +$CHANNEL build
|
||||
$([[ $PROFILE == "release" ]] && echo "--release" || echo "")
|
||||
--verbose
|
||||
--color=always
|
||||
--target x86_64-unknown-linux-musl
|
||||
--target powerpc64le-unknown-linux-musl
|
||||
--target aarch64-unknown-linux-musl
|
||||
--target riscv64gc-unknown-linux-musl
|
||||
--target wasm32-wasi
|
||||
-Z multitarget
|
||||
-Z build-std
|
||||
$CARGO_OPTS'
|
||||
artifacts:
|
||||
paths:
|
||||
- target/*/$PROFILE/*
|
||||
- Dockerfile
|
||||
|
||||
|
||||
test:test:
|
||||
extends: .rust-default
|
||||
stage: test
|
||||
needs: [ build ]
|
||||
script:
|
||||
- 'LLVM_PROFILE_FILE="$CI_PROJECT_NAME-%p-%m.profraw" cargo +$CHANNEL test
|
||||
--verbose
|
||||
--color always
|
||||
--workspace
|
||||
--all-targets
|
||||
--all-features
|
||||
--no-fail-fast
|
||||
--
|
||||
-Z unstable-options
|
||||
--format json
|
||||
$CARGO_OPTS
|
||||
| gitlab-report -p test > results.xml'
|
||||
after_script:
|
||||
- 'grcov .
|
||||
--binary-path ./target/x86_64-unknown-linux-musl/debug/
|
||||
--source-dir .
|
||||
--output-type cobertura
|
||||
--output-path coverage.xml
|
||||
--branch
|
||||
--ignore-not-existing
|
||||
--ignore "/*"'
|
||||
- mkdir results/
|
||||
- cp results.xml results/results.xml
|
||||
- allure generate -c results/
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- allure-report/
|
||||
reports:
|
||||
junit: results.xml
|
||||
# - echo '<meta http-equiv="refresh" content="0; url={{ LIBRARY NAME }}">' > public/index.html
|
||||
artifacts:
|
||||
paths:
|
||||
- public/
|
||||
# test:bench:
|
||||
# extends: .rust-default
|
||||
# stage: test
|
||||
# needs: [ build ]
|
||||
# script:
|
||||
# - 'cargo +$CHANNEL bench
|
||||
# --verbose
|
||||
# --color always
|
||||
# --workspace
|
||||
# --all-targets
|
||||
# --all-features
|
||||
# $CARGO_OPTS
|
||||
# --
|
||||
# -Z unstable-options
|
||||
# --format json
|
||||
# | gitlab-report -p bench > metrics.txt'
|
||||
# artifacts:
|
||||
# when: always
|
||||
# reports:
|
||||
# metrics: metrics.txt
|
||||
stage: build
|
||||
image: rust
|
||||
script:
|
||||
- cargo build --release
|
||||
artifacts:
|
||||
paths:
|
||||
- target/release/zenyx
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue