CI improvements

This commit is contained in:
Acrimon 2019-10-08 08:13:40 +00:00 committed by Marcel
parent f95561f9df
commit 4f52a88c27

View File

@ -1,57 +1,31 @@
image: registry.gitlab.com/veloren/veloren-docker-ci:rework
variables:
GIT_STRATEGY: none
stages: stages:
- optional-builds - optional-builds
- check-compile - check-compile
- post-build - post
# Our own git fetch command like https://gitlab.com/gitlab-org/gitlab-runner/blob/master/shells/abstract.go
# speeds up building because we skip the git clean and don't need any gitlab caches.
variables:
GIT_STRATEGY: none
before_script: before_script:
# Make the directories - mkdir -p veloren
- mkdir -p /cache/veloren - cd veloren
- rm -rf /cache/veloren/bin - git lfs install
- cd /cache/veloren - if [ ! -d ".git" ]; then git clone https://gitlab.com/veloren/veloren.git .; fi
- if [ -d .git ]; then - git clean -f
echo "is git dir"; - git lfs fetch
else - git lfs checkout $CI_COMMIT_SHA
git clone $CI_REPOSITORY_URL . ; - source $HOME/.cargo/env
fi; - df -h
- mkdir -p /cache/veloren/bin - free -h
# Remove previous Git files - gcc -v
- rm -f .git/index.lock - cargo --version
- rm -f .git/shallow.lock
- rm -f .git/HEAD.lock
- rm -f .git/hocks/post-checkout
# Do an efficient Git checkout
- git remote set-url origin $CI_REPOSITORY_URL
- git fetch origin --prune +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/*
- git checkout -f -q $CI_COMMIT_SHA
- if [ ! -z "${SOURCE_PROJECT}" -a "${SOURCE_PROJECT}" != " " ]; then
echo "THIS SEEMS TO BE A MERGE PIPELINE FROM ${SOURCE_PROJECT}/${SOURCE_BRANCH}";
git pull "https://gitlab.com/${SOURCE_PROJECT}/veloren.git" "${SOURCE_BRANCH}";
fi;
# Prepare Git LFS
- git lfs install;
- git lfs fetch;
- git lfs checkout;
# Debug info
- git status
- rustup -v show
# See what's in the target folder?
- if [ -d target ]; then
ls -la target;
fi;
# Overwrite toolchain
- cp /rust-toolchain /cache/veloren/rust-toolchain
############# # -- optional build
# Optional build
#############
.optional: &optional .optional-debug: &optional-debug
stage: optional-builds stage: optional-builds
image: registry.gitlab.com/veloren/veloren-docker-ci
tags: tags:
- veloren-docker - veloren-docker
except: except:
@ -59,34 +33,39 @@ before_script:
when: manual when: manual
artifacts: artifacts:
paths: paths:
- ./ - veloren/artifact
expire_in: 1 week expire_in: 1 week
optional:linux-debug: optional-debug:linux:
<<: *optional <<: *optional-debug
cache:
key: "cache-linux-debug"
paths:
- veloren/
script: script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build) - mkdir artifact
- (cd server-cli && VELOREN_ASSETS=assets cargo build) - cd voxygen && VELOREN_ASSETS=assets cargo build --verbose && cd ..
- cp target/debug/veloren-server-cli $CI_PROJECT_DIR - cd server-cli && VELOREN_ASSETS=assets cargo build --verbose && cd ..
- cp target/debug/veloren-voxygen $CI_PROJECT_DIR - cp target/debug/veloren-server-cli ./artifact
- cp -r assets $CI_PROJECT_DIR - cp target/debug/veloren-voxygen ./artifact
- cp -r assets ./artifact
optional:windows-debug: optional-debug:windows:
<<: *optional <<: *optional-debug
cache:
key: "cache-windows-debug"
paths:
- veloren/
script: script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu) - mkdir artifact
- (cd server-cli && VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu) - cd voxygen && VELOREN_ASSETS=assets cargo build --verbose --target=x86_64-pc-windows-gnu && cd ..
- cp target/x86_64-pc-windows-gnu/debug/veloren-server-cli.exe $CI_PROJECT_DIR - cd server-cli && VELOREN_ASSETS=assets cargo build --verbose --target=x86_64-pc-windows-gnu && cd ..
- cp target/x86_64-pc-windows-gnu/debug/veloren-voxygen.exe $CI_PROJECT_DIR - cp target/x86_64-pc-windows-gnu/debug/veloren-server-cli.exe ./artifact
- cp -r assets $CI_PROJECT_DIR - cp target/x86_64-pc-windows-gnu/debug/veloren-voxygen.exe ./artifact
- cp -r assets ./artifact
#############
# Optional release build
#############
.optional-release: &optional-release .optional-release: &optional-release
stage: optional-builds stage: optional-builds
image: registry.gitlab.com/veloren/veloren-docker-ci
tags: tags:
- veloren-docker - veloren-docker
except: except:
@ -94,127 +73,145 @@ optional:windows-debug:
when: manual when: manual
artifacts: artifacts:
paths: paths:
- ./ - veloren/artifact
expire_in: 1 month expire_in: 1 week
optional-release:linux-debug: optional-release:linux:
<<: *optional-release <<: *optional-release
cache:
key: "cache-linux-release"
paths:
- veloren/
script: script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build --release) - mkdir artifact
- (cd server-cli && VELOREN_ASSETS=assets cargo build --release) - cd voxygen && VELOREN_ASSETS=assets cargo build --verbose --release && cd ..
- cp target/debug/veloren-server-cli $CI_PROJECT_DIR - cd server-cli && VELOREN_ASSETS=assets cargo build --verbose --release && cd ..
- cp target/debug/veloren-voxygen $CI_PROJECT_DIR - cp target/release/veloren-server-cli ./artifact
- cp -r assets $CI_PROJECT_DIR - cp target/release/veloren-voxygen ./artifact
- cp -r assets ./artifact
optional-release:windows-debug: optional-release:windows:
<<: *optional-release <<: *optional-release
cache:
key: "cache-windows-release"
paths:
- veloren/
script: script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build --release --target=x86_64-pc-windows-gnu) - mkdir artifact
- (cd server-cli && VELOREN_ASSETS=assets cargo build --release --target=x86_64-pc-windows-gnu) - cd voxygen && VELOREN_ASSETS=assets cargo build --verbose --target=x86_64-pc-windows-gnu --release && cd ..
- cp target/x86_64-pc-windows-gnu/debug/veloren-server-cli.exe $CI_PROJECT_DIR - cd server-cli && VELOREN_ASSETS=assets cargo build --verbose --target=x86_64-pc-windows-gnu --release && cd ..
- cp target/x86_64-pc-windows-gnu/debug/veloren-voxygen.exe $CI_PROJECT_DIR - cp target/x86_64-pc-windows-gnu/release/veloren-server-cli.exe ./artifact
- cp -r assets $CI_PROJECT_DIR - cp target/x86_64-pc-windows-gnu/release/veloren-voxygen.exe ./artifact
- cp -r assets ./artifact
############# # --
# CHECK
#############
check-voxygen: # -- check
check:
stage: check-compile stage: check-compile
image: registry.gitlab.com/veloren/veloren-docker-ci cache:
key: "cache-linux-debug"
paths:
- veloren/
tags: tags:
- veloren-docker - veloren-docker
script: script:
- (cd voxygen && RUSTFLAGS="-D warnings" cargo check) - RUSTFLAGS="-D warnings" cargo check --verbose
check-server-cli: code-quality:
stage: check-compile stage: check-compile
image: registry.gitlab.com/veloren/veloren-docker-ci cache:
key: "cache-linux-debug"
paths:
- veloren/
tags: tags:
- veloren-docker - veloren-docker
script: script:
- (cd server-cli && RUSTFLAGS="-D warnings" cargo check) - cargo clippy -- --warn clippy::all
- cargo fmt --all -- --check
############# # --
# POST-BUILD
############# # -- post build
unittests: unittests:
stage: post-build stage: post
image: registry.gitlab.com/veloren/veloren-docker-ci cache:
key: "cache-linux-debug"
paths:
- veloren/
when: delayed
start_in: 5 seconds
tags: tags:
- veloren-docker - veloren-docker
script: script:
- cargo test - cargo test
benchmarktests: benchmarks:
stage: post-build stage: post
image: registry.gitlab.com/veloren/veloren-docker-ci cache:
key: "cache-linux-release"
paths:
- veloren/
when: delayed
start_in: 5 seconds
tags: tags:
- veloren-docker - veloren-docker
script: script:
- cargo bench - cargo bench
allow_failure: true allow_failure: true
clean-code: linux:
stage: post-build stage: post
image: registry.gitlab.com/veloren/veloren-docker-ci cache:
tags: key: "cache-linux-release"
- veloren-docker paths:
script: - veloren/
- cargo fmt --all -- --check when: delayed
start_in: 5 seconds
# # Coverage needs to be disabled until an issue in the Rust compiler is fixed
# # https://github.com/rust-lang/rust/issues/58375
# coverage:
# stage: post-build
# image: registry.gitlab.com/veloren/veloren-docker-ci
# tags:
# - veloren-docker
# script:
# - cargo tarpaulin --all
# allow_failure: true
# For now, Clippy will just care about performance improvements as much of the
# codebase is not in a place that cleaning warnings will be benificial
clippy:
stage: post-build
image: registry.gitlab.com/veloren/veloren-docker-ci
tags:
- veloren-docker
script:
- cargo clippy -- -W clippy::all
.commit: &commit
stage: post-build
image: registry.gitlab.com/veloren/veloren-docker-ci
tags:
- veloren-docker
except:
- schedules
only: only:
refs: refs:
- master - /^r[0-9]+\.[0-9]+\.[0-9]+/
- /^v[0-9]+\.[0-9]+\.[0-9]+/
- /^master$/
artifacts: artifacts:
paths: paths:
- ./ - veloren/artifact
expire_in: 1 week tags:
- veloren-docker
commit:linux-debug:
<<: *commit
script: script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build) - mkdir artifact
- (cd server-cli && VELOREN_ASSETS=assets cargo build) - cd voxygen && VELOREN_ASSETS=assets cargo build --release && cd ..
- cp target/debug/veloren-server-cli $CI_PROJECT_DIR - cd server-cli && VELOREN_ASSETS=assets cargo build --release && cd ..
- cp target/debug/veloren-voxygen $CI_PROJECT_DIR - cp -r target/release/veloren-server-cli ./artifact
- cp -r assets $CI_PROJECT_DIR - cp -r target/release/veloren-voxygen ./artifact
- cp -r assets ./artifact
commit:windows-debug: windows:
<<: *commit stage: post
cache:
key: "cache-windows-release"
paths:
- veloren/
when: delayed
start_in: 5 seconds
only:
refs:
- /^r[0-9]+\.[0-9]+\.[0-9]+/
- /^v[0-9]+\.[0-9]+\.[0-9]+/
- /^master$/
artifacts:
paths:
- veloren/artifact
tags:
- veloren-docker
script: script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu) - mkdir artifact
- (cd server-cli && VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu) - cd voxygen && VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu --release && cd ..
- cp target/x86_64-pc-windows-gnu/debug/veloren-server-cli.exe $CI_PROJECT_DIR - cd server-cli && VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu --release && cd ..
- cp target/x86_64-pc-windows-gnu/debug/veloren-voxygen.exe $CI_PROJECT_DIR - cp -r target/x86_64-pc-windows-gnu/release/veloren-server-cli ./artifact
- cp -r assets $CI_PROJECT_DIR - cp -r target/x86_64-pc-windows-gnu/release/veloren-voxygen ./artifact
- cp -r assets ./artifact
# --