CI cleanup

- switching more to rules syntax
  - clean up some templates
  - EITHER optional builds or build builds
  - ordering
This commit is contained in:
Marcel Märtens 2020-06-12 13:09:56 +02:00
parent c22f9530e4
commit b9344ffeb7
7 changed files with 91 additions and 112 deletions

View File

@ -1,7 +1,6 @@
stages:
- optional-builds
- check-compile
- build-post
- check
- build
- publish
variables:
@ -44,7 +43,6 @@ workflow:
include:
- local: .gitlab/CI/recompile.yml
- local: .gitlab/CI/release.yml
- local: .gitlab/CI/optional-builds.gitlab-ci.yml
- local: .gitlab/CI/check-compile.gitlab-ci.yml
- local: .gitlab/CI/build-post.gitlab-ci.yml
- local: .gitlab/CI/check.gitlab-ci.yml
- local: .gitlab/CI/build.gitlab-ci.yml
- local: .gitlab/CI/publish.gitlab-ci.yml

View File

@ -1,32 +1,15 @@
.tests: &tests
extends: .recompile-branch
stage: build-post
tags:
- veloren-docker
unittests:
<<: *tests
extends: .recompile-branch
stage: build
script:
- ln -s /dockercache/cache-all target
- cargo test
retry:
max: 2
coverage:
# Run on master and branches
extends: .recompile
allow_failure: true
stage: build-post
tags:
- veloren-docker
script:
- ln -s /dockercache/cache-tarpaulin target
- cargo tarpaulin -v
retry:
max: 2
benchmarks:
<<: *tests
extends: .recompile-branch
stage: build
script:
- unset DISABLE_GIT_LFS_CHECK
- ln -s /dockercache/cache-all target
@ -35,23 +18,27 @@ benchmarks:
max: 2
localization-status:
<<: *tests
extends: .recompile-branch
stage: build
variables:
GIT_DEPTH: 0
allow_failure: true
script:
- ln -s /dockercache/cache-all target
- cargo test -q test_all_localizations -- --nocapture --ignored
- cargo test test_all_localizations -- --nocapture --ignored
# Artifacts
.artifact: &artifact
extends: .release
stage: build-post
tags:
- veloren-docker
# Coverage is needed on master for the README.md badge to work
coverage:
extends: .recompile
stage: build
script:
- ln -s /dockercache/cache-tarpaulin target
- cargo tarpaulin -v
retry:
max: 2
linux:
<<: *artifact
#linux, windows, macos builds here as template
.tlinux:
script:
- ln -s /dockercache/cache-release-linux target
- cargo build --release
@ -67,8 +54,7 @@ linux:
- LICENSE
expire_in: 1 week
windows:
<<: *artifact
.twindows:
script:
- ln -s /dockercache/cache-release-windows target
- cargo build --target=x86_64-pc-windows-gnu --release
@ -82,8 +68,7 @@ windows:
- LICENSE
expire_in: 1 week
macos:
<<: *artifact
.tmacos:
script:
- ln -s /dockercache/cache-release-macos target
- PATH="/dockercache/osxcross/target/bin:$PATH" COREAUDIO_SDK_PATH=/dockercache/osxcross/target/SDK/MacOSX10.13.sdk CC=o64-clang CXX=o64-clang++ cargo build --target x86_64-apple-darwin --release
@ -96,4 +81,35 @@ macos:
- assets/
- LICENSE
expire_in: 1 week
allow_failure: true
# build on release or master
linux:
extends:
- .tlinux
- .release
windows:
extends:
- .twindows
- .release
macos:
extends:
- .tmacos
- .release
# if NOT release or master, allow optional builds
opt-linux:
extends:
- .tlinux
- .optional-release
opt-windows:
extends:
- .twindows
- .optional-release
opt-macos:
extends:
- .tmacos
- .optional-release

View File

@ -1,17 +1,13 @@
check:
extends: .recompile-branch
stage: check-compile
tags:
- veloren-docker
stage: check
script:
- ln -s /dockercache/cache-all target
- RUSTFLAGS="-D warnings" cargo check --locked
code-quality:
extends: .recompile-branch
stage: check-compile
tags:
- veloren-docker
stage: check
script:
- ln -s /dockercache/cache-all target
- cargo clippy -- -D warnings
@ -19,10 +15,8 @@ code-quality:
security:
extends: .recompile-branch
stage: check-compile
stage: check
allow_failure: true
tags:
- veloren-docker
script:
- ln -s /dockercache/cache-all target
- cargo audit

View File

@ -1,54 +0,0 @@
.optional-release: &optional-release
stage: optional-builds
tags:
- veloren-docker
except:
- schedules
when: manual
optional-release:linux:
<<: *optional-release
script:
- ln -s /dockercache/cache-release-linux target
- cargo build --verbose --release
- cp target/release/veloren-server-cli $CI_PROJECT_DIR
- cp target/release/veloren-voxygen $CI_PROJECT_DIR
- strip --strip-all veloren-server-cli
- strip --strip-all veloren-voxygen
artifacts:
paths:
- veloren-server-cli
- veloren-voxygen
- assets/
- LICENSE
expire_in: 1 week
optional-release:windows:
<<: *optional-release
script:
- ln -s /dockercache/cache-release-windows target
- cargo build --verbose --target=x86_64-pc-windows-gnu --release
- cp target/x86_64-pc-windows-gnu/release/veloren-server-cli.exe $CI_PROJECT_DIR
- cp target/x86_64-pc-windows-gnu/release/veloren-voxygen.exe $CI_PROJECT_DIR
artifacts:
paths:
- veloren-server-cli.exe
- veloren-voxygen.exe
- assets/
- LICENSE
expire_in: 1 week
optional-release:macos:
<<: *optional-release
script:
- ln -s /dockercache/cache-release-macos target
- PATH="/dockercache/osxcross/target/bin:$PATH" COREAUDIO_SDK_PATH=/dockercache/osxcross/target/SDK/MacOSX10.13.sdk CC=o64-clang CXX=o64-clang++ cargo build --target x86_64-apple-darwin --release
- cp -r target/x86_64-apple-darwin/release/veloren-server-cli $CI_PROJECT_DIR
- cp -r target/x86_64-apple-darwin/release/veloren-voxygen $CI_PROJECT_DIR
artifacts:
paths:
- veloren-server-cli
- veloren-voxygen
- assets/
- LICENSE
expire_in: 1 week

View File

@ -1,8 +1,16 @@
# Publishes veloren-server-cli to the gitlab container registry
# https://gitlab.com/veloren/veloren/container_registry
docker:
.publish:
stage: publish
extends: .release
tags:
- veloren-docker
rules:
- when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: always
docker:
extends: .publish
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
@ -10,15 +18,12 @@ docker:
- linux
before_script:
- ls "$CI_PROJECT_DIR/server-cli/"
tags:
- veloren-docker
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/server-cli/Dockerfile --destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}-server"
pages:
extends: .release
stage: publish
extends: .publish
artifacts:
paths:
- public
@ -26,4 +31,4 @@ pages:
- rm -rf public
- mkdir -p public
- cargo doc --no-deps --all-features --document-private-items
- mv target/doc/* public
- mv target/doc/* public

View File

@ -1,5 +1,7 @@
# Template to only run if actual changes has been made to the code and not just documentation
.recompile-branch:
tags:
- veloren-docker
rules:
- if: $CI_COMMIT_REF_NAME !~ /^master$/
# No '-' here is *very* important: https://docs.gitlab.com/ee/ci/yaml/#complex-rule-clauses
@ -11,6 +13,8 @@
# like .recompile-branch but will run on master too
.recompile:
tags:
- veloren-docker
rules:
- changes:
- "**/*.{rs,ron,toml,vox,png,wav}"

View File

@ -1,4 +1,20 @@
# allow_failure: true makes these pipelines manual and "non-blocking" which changed with except -> rule syntax
.optional-release:
stage: build
tags:
- veloren-docker
rules:
- when: manual
allow_failure: true
- if: $CI_COMMIT_REF_NAME =~ /^master$/ || $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/ || $CI_COMMIT_REF_NAME =~ /^r[0-9]+\.[0-9]+/ || $CI_PIPELINE_SOURCE == "schedule"
when: never
# Template to only run if pushes to master or a tag happened
.release:
stage: build
tags:
- veloren-docker
rules:
- if: $CI_COMMIT_REF_NAME =~ /^master$/ || $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/ || $CI_COMMIT_REF_NAME =~ /^r[0-9]+\.[0-9]+/
when: always
- when: never