mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-21 14:37:56 +01:00
Update gitlab-ci.yml
This commit is contained in:
parent
f1c726f672
commit
481649c8d2
200
.gitlab-ci.yml
200
.gitlab-ci.yml
@ -1,86 +1,151 @@
|
|||||||
# Official language image. Look for the different tagged releases at:
|
# Define slightly different stages.
|
||||||
# https://hub.docker.com/r/library/rust/tags/
|
# Additionally, lint the code before anything else to fail more quickly
|
||||||
image: "rust:latest"
|
stages:
|
||||||
|
- lint
|
||||||
|
- build
|
||||||
|
- test
|
||||||
|
- release
|
||||||
|
- dockerify
|
||||||
|
|
||||||
# Optional: Pick zero or more services to be used on all builds.
|
default:
|
||||||
# Only needed when using a docker container to run your tests in.
|
image: "rust:latest"
|
||||||
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
|
tags:
|
||||||
# services:
|
- linux
|
||||||
# - mysql:latest
|
- docker
|
||||||
# - redis:latest
|
|
||||||
# - postgres:latest
|
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
GIT_SUBMODULE_STRATEGY: recursive
|
GIT_SUBMODULE_STRATEGY: recursive
|
||||||
# CARGO_HOME: $CI_PROJECT_DIR/cargo
|
CARGO_HOME: $CI_PROJECT_DIR/cargo
|
||||||
APT_CACHE_DIR: $CI_PROJECT_DIR/apt
|
APT_CACHE_DIR: $CI_PROJECT_DIR/apt
|
||||||
|
|
||||||
|
# cache dependencies and build environment to speed up setup
|
||||||
|
cache:
|
||||||
|
key: "$CI_COMMIT_REF_SLUG"
|
||||||
|
paths:
|
||||||
|
- apt/
|
||||||
|
- cargo/
|
||||||
|
- target/
|
||||||
|
|
||||||
# install build dependencies
|
# install build dependencies
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get update -yqq
|
- apt-get update -yqq
|
||||||
- apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -yqq --no-install-recommends capnproto build-essential cmake clang libclang-dev
|
- apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -yqq --no-install-recommends capnproto build-essential cmake clang libclang-dev jq
|
||||||
- rustup update
|
|
||||||
- rustup component add rustfmt
|
- rustup component add rustfmt
|
||||||
- rustup component add clippy
|
- rustup component add clippy
|
||||||
|
- cargo install cargo2junit
|
||||||
|
|
||||||
# Use clippy to lint the project
|
.lists:
|
||||||
|
stage: lint
|
||||||
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- merge_requests
|
||||||
|
|
||||||
|
# Use clippy lints
|
||||||
lint:clippy:
|
lint:clippy:
|
||||||
allow_failure: true
|
extends: .lints
|
||||||
script:
|
script:
|
||||||
- rustc --version && cargo --version # Print version info for debugging
|
- cargo +stable clippy -V
|
||||||
- cargo clippy -- -D warnings
|
- echo -e "\e[0Ksection_start:`date +%s`:clippy_output\r\e[0K`cargo clippy` output"
|
||||||
only:
|
- cargo +stable clippy -- --no-deps
|
||||||
- master
|
- echo -e "\e[0Ksection_end:`date +%s`:clippy_output\r\e[0K"
|
||||||
- development
|
|
||||||
- merge_requests
|
|
||||||
tags:
|
|
||||||
- linux
|
|
||||||
- docker
|
|
||||||
|
|
||||||
# Use rustfmt to check formating of the project
|
# Use rustfmt to check formating
|
||||||
lint:fmt:
|
lint:fmt:
|
||||||
allow_failure: true
|
extends: .lints
|
||||||
script:
|
script:
|
||||||
- rustc --version && cargo --version # Print version info for debugging
|
- cargo +stable fmt --version
|
||||||
- cargo fmt -- --check # TODO: Do we want to enforce formating?
|
- echo -e "\e[0Ksection_start:`date +%s`:rustfmt_output\r\e[0KChanges suggested by rustfmt"
|
||||||
|
- cargo +stable fmt --check -- -v
|
||||||
|
- echo -e "\e[0Ksection_end:`date +%s`:rustfmt_output\r\e[0K"
|
||||||
|
|
||||||
|
.builds:
|
||||||
|
stage: build
|
||||||
only:
|
only:
|
||||||
- master
|
- main
|
||||||
- development
|
- development
|
||||||
- merge_requests
|
- merge_requests
|
||||||
tags:
|
|
||||||
- linux
|
|
||||||
- docker
|
|
||||||
|
|
||||||
# Use cargo to test the project
|
# Check if the code builds on rust stable
|
||||||
test:cargo:
|
stable:build:
|
||||||
|
extends: .builds
|
||||||
script:
|
script:
|
||||||
- rustc --version && cargo --version # Print version info for debugging
|
- rustc +stable --version && cargo +stable --version
|
||||||
- cargo test --workspace --verbose
|
- echo -e "\e[0Ksection_start:`date +%s`:build_output\r\e[0KOutput of `cargo check`"
|
||||||
only:
|
- cargo +stable check --verbose
|
||||||
- master
|
- echo -e "\e[0Ksection_end:`date +%s`:build_output\r\e[0K"
|
||||||
- development
|
|
||||||
- merge_requests
|
|
||||||
tags:
|
|
||||||
- linux
|
|
||||||
- docker
|
|
||||||
|
|
||||||
build:docker-master:
|
stable:test:
|
||||||
image:
|
extends: .builds
|
||||||
name: gcr.io/kaniko-project/executor:v1.6.0-debug
|
needs: ["stable:build"]
|
||||||
entrypoint: [""]
|
|
||||||
before_script:
|
|
||||||
- ''
|
|
||||||
script:
|
script:
|
||||||
- mkdir -p /kaniko/.docker
|
- echo -e "\e[0Ksection_start:`date +%s`:build_output\r\e[0KOutput of `cargo test --no-run`"
|
||||||
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
- cargo +stable test --verbose --no-run --workspace
|
||||||
- /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:latest
|
- echo -e "\e[0Ksection_end:`date +%s`:build_output\r\e[0K"
|
||||||
only:
|
|
||||||
- master
|
.tests:
|
||||||
tags:
|
stage: test
|
||||||
- linux
|
needs:
|
||||||
- docker
|
- "stable:test"
|
||||||
|
script:
|
||||||
|
- >
|
||||||
|
cargo +stable test --workspace $TEST_TARGET --
|
||||||
|
-Z unstable-options --format json --report-time
|
||||||
|
| cargo2junit > report.xml
|
||||||
|
artifacts:
|
||||||
|
when: always
|
||||||
|
reports:
|
||||||
|
junit:
|
||||||
|
- report.xml
|
||||||
|
|
||||||
|
# Run unit tests
|
||||||
|
unit test 1/3:
|
||||||
|
variables:
|
||||||
|
TEST_TARGET: "--lib"
|
||||||
|
extends: .tests
|
||||||
|
|
||||||
|
unit test 2/3:
|
||||||
|
variables:
|
||||||
|
TEST_TARGET: "--bins"
|
||||||
|
extends: .tests
|
||||||
|
|
||||||
|
unit test 3/3:
|
||||||
|
variables:
|
||||||
|
TEST_TARGET: "--examples"
|
||||||
|
extends: .tests
|
||||||
|
|
||||||
|
|
||||||
|
release_prepare:
|
||||||
|
stage: release
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG =~ "release/.*"
|
||||||
|
when: never
|
||||||
|
- if: $CI_COMMIT_BRANCH == "main"
|
||||||
|
script:
|
||||||
|
- VERSION="cargo metadata --format-version 1 | jq -C '.packages | .[] | select(.name == "diflouroborane") | .version' -r"
|
||||||
|
- echo $VERSION > release.env
|
||||||
|
artifacts:
|
||||||
|
reports:
|
||||||
|
dotenv: release.env
|
||||||
|
|
||||||
|
release_job:
|
||||||
|
stage: release
|
||||||
|
needs:
|
||||||
|
- job: release_prepare
|
||||||
|
artifacts: true
|
||||||
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG =~ "release/.*"
|
||||||
|
when: never
|
||||||
|
- if: $CI_COMMIT_BRANCH == "main"
|
||||||
|
script:
|
||||||
|
- echo "Creating GitLab release…"
|
||||||
|
release:
|
||||||
|
name: "BFFH $VERSION"
|
||||||
|
description: "GitLab CI auto-created release"
|
||||||
|
tag_name: "release/$VERSION"
|
||||||
|
|
||||||
build:docker-releases:
|
build:docker-releases:
|
||||||
|
stage: dockerify
|
||||||
image:
|
image:
|
||||||
name: gcr.io/kaniko-project/executor:v1.6.0-debug
|
name: gcr.io/kaniko-project/executor:v1.6.0-debug
|
||||||
entrypoint: [""]
|
entrypoint: [""]
|
||||||
@ -90,13 +155,11 @@ build:docker-releases:
|
|||||||
- mkdir -p /kaniko/.docker
|
- mkdir -p /kaniko/.docker
|
||||||
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
||||||
- /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
- /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||||
only:
|
rules:
|
||||||
- tags
|
- if: $CI_COMMIT_TAG =~ "release/.*"
|
||||||
tags:
|
|
||||||
- linux
|
|
||||||
- docker
|
|
||||||
|
|
||||||
build:docker-development:
|
build:docker-development:
|
||||||
|
stage: dockerify
|
||||||
image:
|
image:
|
||||||
name: gcr.io/kaniko-project/executor:v1.6.0-debug
|
name: gcr.io/kaniko-project/executor:v1.6.0-debug
|
||||||
entrypoint: [""]
|
entrypoint: [""]
|
||||||
@ -107,15 +170,4 @@ build:docker-development:
|
|||||||
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
||||||
- /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:dev-latest
|
- /kaniko/executor --force --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:dev-latest
|
||||||
only:
|
only:
|
||||||
- development
|
- development
|
||||||
tags:
|
|
||||||
- linux
|
|
||||||
- docker
|
|
||||||
|
|
||||||
# cache dependencies and build environment to speed up setup
|
|
||||||
cache:
|
|
||||||
key: "$CI_COMMIT_REF_SLUG"
|
|
||||||
paths:
|
|
||||||
- apt/
|
|
||||||
# - cargo/
|
|
||||||
- target/
|
|
Loading…
Reference in New Issue
Block a user