veloren/.gitlab-ci.yml
2019-08-15 23:56:14 -04:00

304 lines
8.7 KiB
YAML

stages:
- build
- test
- post-build
- executable
# 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:
- mkdir -p /cache/veloren
- rm -rf /cache/veloren/bin
- cd /cache/veloren
- if [ -d .git ]; then
echo "is git dir";
else
git clone $CI_REPOSITORY_URL . ;
fi;
- mkdir -p /cache/veloren/bin
- rm -f .git/index.lock
- rm -f .git/shallow.lock
- rm -f .git/HEAD.lock
- rm -f .git/hocks/post-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;
- git lfs install;
- git lfs fetch;
- git lfs checkout;
- git status
- rustup -v show
- if [ -d target ]; then
ls -la target;
fi;
#############
# BUILD
#############
build-voxygen:
stage: build
image: registry.gitlab.com/veloren/veloren-docker-ci
tags:
- veloren-docker
script:
- (cd voxygen && cargo rustc -v -- -D warnings)
build-server-cli:
stage: build
image: registry.gitlab.com/veloren/veloren-docker-ci
tags:
- veloren-docker
script:
- (cd server-cli && cargo rustc -v -- -D warnings)
#############
# TEST
#############
unittests:
stage: test
image: registry.gitlab.com/veloren/veloren-docker-ci
tags:
- veloren-docker
script:
- cargo test
benchmarktests:
stage: test
image: registry.gitlab.com/veloren/veloren-docker-ci
tags:
- veloren-docker
script:
- cargo bench
allow_failure: true
#############
# POST-BUILD
#############
clean-code:
stage: post-build
image: registry.gitlab.com/veloren/veloren-docker-ci
tags:
- veloren-docker
script:
- cargo fmt --all -- --check
# # 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 build
#############
.commit: &commit
stage: executable
image: registry.gitlab.com/veloren/veloren-docker-ci
tags:
- veloren-docker
except:
- schedules
only:
refs:
- master
commit:linux-debug:
<<: *commit
script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build)
- (cd server-cli && VELOREN_ASSETS=assets cargo build)
- rm -r -f commit-build
- mkdir commit-build
- cp target/debug/veloren-server-cli commit-build
- cp target/debug/veloren-voxygen commit-build
- cp -r assets commit-build/
- tar -cvjSf bin/commit-linux-debug.tar.bz2 commit-build
- cp bin/commit-linux-debug.tar.bz2 $CI_PROJECT_DIR
artifacts:
paths:
- commit-linux-debug.tar.bz2
expire_in: 1 week
commit:windows-debug:
<<: *commit
script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu)
- (cd server-cli && VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu)
- rm -r -f commit-build
- mkdir commit-build
- cp target/x86_64-pc-windows-gnu/debug/veloren-server-cli.exe commit-build
- cp target/x86_64-pc-windows-gnu/debug/veloren-voxygen.exe commit-build
- cp -r assets commit-build/
- zip -r bin/commit-windows-debug.zip commit-build
- cp bin/commit-windows-debug.zip $CI_PROJECT_DIR
artifacts:
paths:
- commit-windows-debug.zip
expire_in: 1 week
#############
# Optional build
#############
.optional: &optional
stage: executable
image: registry.gitlab.com/veloren/veloren-docker-ci
tags:
- veloren-docker
except:
- schedules
when: manual
optional:linux-debug:
<<: *optional
script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build)
- (cd server-cli && VELOREN_ASSETS=assets cargo build)
- rm -r -f optional-build
- mkdir optional-build
- cp target/debug/veloren-server-cli optional-build
- cp target/debug/veloren-voxygen optional-build
- cp -r assets optional-build/
- tar -cvjSf bin/optional-linux-debug.tar.bz2 optional-build
- cp bin/optional-linux-debug.tar.bz2 $CI_PROJECT_DIR
artifacts:
paths:
- optional-linux-debug.tar.bz2
expire_in: 1 week
optional:windows-debug:
<<: *optional
script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu)
- (cd server-cli && VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu)
- rm -r -f optional-build
- mkdir optional-build
- cp target/x86_64-pc-windows-gnu/debug/veloren-server-cli.exe optional-build
- cp target/x86_64-pc-windows-gnu/debug/veloren-voxygen.exe optional-build
- cp -r assets optional-build/
- zip -r bin/optional-windows-debug.zip optional-build
- cp bin/optional-windows-debug.zip $CI_PROJECT_DIR
artifacts:
paths:
- optional-windows-debug.zip
expire_in: 1 week
#############
# Optional release build
#############
.optional-release: &optional-release
stage: executable
image: registry.gitlab.com/veloren/veloren-docker-ci
tags:
- veloren-docker
except:
- schedules
when: manual
optional-release:linux-debug:
<<: *optional-release
script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build --release)
- (cd server-cli && VELOREN_ASSETS=assets cargo build --release)
- rm -r -f optional-release-build
- mkdir optional-release-build
- cp target/debug/veloren-server-cli optional-release-build
- cp target/debug/veloren-voxygen optional-release-build
- cp -r assets optional-release-build/
- tar -cvjSf bin/optional-release-linux-debug.tar.bz2 optional-release-build
- cp bin/optional-release-linux-debug.tar.bz2 $CI_PROJECT_DIR
artifacts:
paths:
- optional-release-linux-debug.tar.bz2
expire_in: 1 month
optional-release:windows-debug:
<<: *optional-release
script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build --release --target=x86_64-pc-windows-gnu)
- (cd server-cli && VELOREN_ASSETS=assets cargo build --release --target=x86_64-pc-windows-gnu)
- rm -r -f optional-release-build
- mkdir optional-release-build
- cp target/x86_64-pc-windows-gnu/debug/veloren-server-cli.exe optional-release-build
- cp target/x86_64-pc-windows-gnu/debug/veloren-voxygen.exe optional-release-build
- cp -r assets optional-release-build/
- zip -r bin/optional-release-windows-debug.zip optional-release-build
- cp bin/optional-release-windows-debug.zip $CI_PROJECT_DIR
artifacts:
paths:
- optional-release-windows-debug.zip
expire_in: 1 month
#############
# NIGHTLY
#############
.nightly: &nightly
stage: executable
image: registry.gitlab.com/veloren/veloren-docker-ci
tags:
- veloren-docker
only:
- schedules
nightly:linux-optimized:
<<: *nightly
script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build --release)
- (cd server-cli && VELOREN_ASSETS=assets cargo build --release)
- rm -r -f nightly-build
- mkdir nightly-build
- cp target/release/veloren-server-cli nightly-build
- cp target/release/veloren-voxygen nightly-build
- cp -r assets nightly-build/
- tar -cvjSf bin/nightly-linux-optimized.tar.bz2 nightly-build
- cp bin/nightly-linux-optimized.tar.bz2 $CI_PROJECT_DIR
artifacts:
paths:
- nightly-linux-optimized.tar.bz2
expire_in: 2 days
nightly:windows-optimized:
<<: *nightly
script:
- (cd voxygen && VELOREN_ASSETS=assets cargo build --release --target=x86_64-pc-windows-gnu)
- (cd server-cli && VELOREN_ASSETS=assets cargo build --release --target=x86_64-pc-windows-gnu)
- rm -r -f nightly-build
- mkdir nightly-build
- cp target/x86_64-pc-windows-gnu/release/veloren-server-cli.exe nightly-build
- cp target/x86_64-pc-windows-gnu/release/veloren-voxygen.exe nightly-build
- cp -r assets nightly-build/
- zip -r bin/nightly-windows-optimized.zip nightly-build
- cp bin/nightly-windows-optimized.zip $CI_PROJECT_DIR
artifacts:
paths:
- nightly-windows-optimized.zip
expire_in: 2 days