forked from nonsensical-dev/zenyx-engine
feat: add a WIP ci/cd pipeline
This commit is contained in:
parent
17140cdcd2
commit
27a9911c3c
2 changed files with 173 additions and 44 deletions
205
.gitlab-ci.yml
205
.gitlab-ci.yml
|
@ -1,49 +1,178 @@
|
||||||
# This file is a template, and might need editing before it works on your project.
|
stages:
|
||||||
# This is a sample GitLab CI/CD configuration file that should run without any modifications.
|
- check
|
||||||
# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts,
|
|
||||||
# it uses echo commands to simulate the pipeline execution.
|
|
||||||
#
|
|
||||||
# A pipeline is composed of independent jobs that run scripts, grouped into stages.
|
|
||||||
# Stages run in sequential order, but jobs within stages run in parallel.
|
|
||||||
#
|
|
||||||
# For more information, see: https://docs.gitlab.com/ee/ci/yaml/#stages
|
|
||||||
#
|
|
||||||
# You can copy and paste this template into a new `.gitlab-ci.yml` file.
|
|
||||||
# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword.
|
|
||||||
#
|
|
||||||
# To contribute improvements to CI/CD templates, please follow the Development guide at:
|
|
||||||
# https://docs.gitlab.com/development/cicd/templates/
|
|
||||||
# This specific template is located at:
|
|
||||||
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml
|
|
||||||
|
|
||||||
stages: # List of stages for jobs, and their order of execution
|
|
||||||
- build
|
- build
|
||||||
- test
|
- test
|
||||||
|
- docker
|
||||||
|
- test-2
|
||||||
|
- release
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
build-job: # This job runs in the build stage, which runs first.
|
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
|
||||||
|
|
||||||
|
|
||||||
|
build:
|
||||||
|
extends: .rust-default
|
||||||
stage: build
|
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:
|
script:
|
||||||
- echo "Compiling the code..."
|
- cargo +$CHANNEL build --verbose --color always --target $TARGET $([[ $PROFILE == "release" ]] && echo "--release" || echo "") $CARGO_OPTS
|
||||||
- echo "Compile complete."
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- target/$TARGET/$PROFILE/*
|
||||||
|
- Dockerfile
|
||||||
|
|
||||||
unit-test-job: # This job runs in the test stage.
|
# requires nightly
|
||||||
stage: test # It only starts when the job in the build stage completes successfully.
|
.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:
|
script:
|
||||||
- echo "Running unit tests... This will take about 60 seconds."
|
- '[[ $PROFILE == "debug" ]] && export RUSTFLAGS="$RUSTFLAGS -Zinstrument-coverage" || true'
|
||||||
- sleep 60
|
- 'cargo +$CHANNEL build
|
||||||
- echo "Code coverage is 90%"
|
$([[ $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
|
||||||
|
|
||||||
lint-test-job: # This job also runs in the test stage.
|
|
||||||
stage: test # It can run at the same time as unit-test-job (in parallel).
|
|
||||||
script:
|
|
||||||
- echo "Linting code... This will take about 10 seconds."
|
|
||||||
- sleep 10
|
|
||||||
- echo "No lint issues found."
|
|
||||||
|
|
||||||
deploy-job: # This job runs in the deploy stage.
|
test:test:
|
||||||
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
|
extends: .rust-default
|
||||||
environment: production
|
stage: test
|
||||||
|
needs: [ build ]
|
||||||
script:
|
script:
|
||||||
- echo "Deploying application..."
|
- 'LLVM_PROFILE_FILE="$CI_PROJECT_NAME-%p-%m.profraw" cargo +$CHANNEL test
|
||||||
- echo "Application successfully deployed."
|
--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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue