From 07c044f2e596ba48496536cf61f35b91c96191e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Wed, 14 Jul 2021 10:25:29 +0200 Subject: [PATCH] extract relevant code in a script in order to remove duplicate coding with docker-ci repo export VELOREN_ASSETS without pwd to keep caching working --- .gitlab-ci.yml | 6 +----- .gitlab/CI/build.gitlab-ci.yml | 36 +++++++++------------------------ .gitlab/CI/check.gitlab-ci.yml | 10 ++++----- .gitlab/scripts/benchmark.sh | 4 ++++ .gitlab/scripts/ci.sh | 4 ++++ .gitlab/scripts/code-quality.sh | 6 ++++++ .gitlab/scripts/coverage.sh | 7 +++++++ .gitlab/scripts/env.sh | 6 ++++++ .gitlab/scripts/linux.sh | 6 ++++++ .gitlab/scripts/security.sh | 2 ++ .gitlab/scripts/unittest.sh | 7 +++++++ .gitlab/scripts/windows.sh | 7 +++++++ world/src/sim/erosion.rs | 2 +- 13 files changed, 65 insertions(+), 38 deletions(-) create mode 100755 .gitlab/scripts/benchmark.sh create mode 100755 .gitlab/scripts/ci.sh create mode 100755 .gitlab/scripts/code-quality.sh create mode 100755 .gitlab/scripts/coverage.sh create mode 100644 .gitlab/scripts/env.sh create mode 100755 .gitlab/scripts/linux.sh create mode 100755 .gitlab/scripts/security.sh create mode 100755 .gitlab/scripts/unittest.sh create mode 100755 .gitlab/scripts/windows.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2f165589cd..0419b023a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,11 +33,7 @@ before_script: - df -h / - free -h - cargo --version - - export DISABLE_GIT_LFS_CHECK=true - - export VELOREN_ASSETS="$(pwd)/assets" - - echo "VELOREN_ASSETS=$VELOREN_ASSETS" - - export RUSTFLAGS="-D warnings" - - export SHADERC_LIB_DIR=/shaderc/combined/ + - source ./.gitlab/scripts/env.sh - rm -rf target || echo "it seems that sometimes OLD data is left over" # 8866215 is the user that is used to sync data to the collaboration repos diff --git a/.gitlab/CI/build.gitlab-ci.yml b/.gitlab/CI/build.gitlab-ci.yml index 3fdbd8fe45..fd329f3510 100644 --- a/.gitlab/CI/build.gitlab-ci.yml +++ b/.gitlab/CI/build.gitlab-ci.yml @@ -6,11 +6,8 @@ unittests: GIT_DEPTH: 9999999999999 script: - ln -s /dockercache/target target - - rm -r target/debug/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - - cargo test --package veloren-i18n --lib test_all_localizations -- --nocapture --ignored - - cargo test --package veloren-common-assets asset_tweak::tests --features asset_tweak --lib - - rm -r target/debug/incremental* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - - cargo test + - cat ./.gitlab/scripts/unittest.sh + - source ./.gitlab/scripts/unittest.sh retry: max: 2 @@ -23,12 +20,8 @@ benchmarks: script: - unset DISABLE_GIT_LFS_CHECK - ln -s /dockercache/target target - - ls -la target/* - - rm -r target/debug/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - - rm -r target/release/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - - rm -r target/debug/incremental/* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - - rm -r target/release/incremental/* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - - cargo bench || exit 0 #temp fix + - cat ./.gitlab/scripts/benchmark.sh + - source ./.gitlab/scripts/benchmark.sh - TAGUUID="Z$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)" || echo "ignore this returncode, dont ask me why, it works" - echo $TAGUUID - echo 'SET veloren.timestamp = "'"$(git show --no-patch --no-notes --pretty='%cd' HEAD)"'";' > upload.sql @@ -48,11 +41,8 @@ coverage: image: registry.gitlab.com/veloren/veloren-docker-ci/cache/tarpaulin:${CACHE_IMAGE_TAG} script: - ln -s /dockercache/target target - - rm -r target/debug/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - - find ./* -name "Cargo.toml" -exec sed -i 's/, "simd"]/]/g' {} \; - - find ./* -name "Cargo.toml" -exec sed -i 's/"simd"]/]/g' {} \; - - sed -i 's/vek /#vek /g' ./Cargo.toml; - - cargo tarpaulin -v -- --test-threads=2 + - cat ./.gitlab/scripts/coverage.sh + - source ./.gitlab/scripts/coverage.sh retry: max: 2 @@ -61,10 +51,8 @@ coverage: image: registry.gitlab.com/veloren/veloren-docker-ci/cache/release-linux:${CACHE_IMAGE_TAG} script: - ln -s /dockercache/target target - - rm -r target/release/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - - export VELOREN_USERDATA_STRATEGY=executable - - cargo build --release -p veloren-voxygen --no-default-features --features default-publish - - cargo build --release -p veloren-server-cli + - cat ./.gitlab/scripts/linux.sh + - source ./.gitlab/scripts/linux.sh - cp -r target/release/veloren-server-cli $CI_PROJECT_DIR - cp -r target/release/veloren-voxygen $CI_PROJECT_DIR artifacts: @@ -78,13 +66,9 @@ coverage: .twindows: image: registry.gitlab.com/veloren/veloren-docker-ci/cache/release-windows:${CACHE_IMAGE_TAG} script: - - update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix - - update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix - ln -s /dockercache/target target - - rm -r target/release/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - - export VELOREN_USERDATA_STRATEGY=executable - - cargo build --target=x86_64-pc-windows-gnu --release -p veloren-voxygen --no-default-features --features default-publish - - cargo build --target=x86_64-pc-windows-gnu --release -p veloren-server-cli + - cat ./.gitlab/scripts/windows.sh + - source ./.gitlab/scripts/windows.sh - cp -r target/x86_64-pc-windows-gnu/release/veloren-server-cli.exe $CI_PROJECT_DIR - cp -r target/x86_64-pc-windows-gnu/release/veloren-voxygen.exe $CI_PROJECT_DIR - cp /usr/lib/gcc/x86_64-w64-mingw32/7.3-posix/libgcc_s_seh-1.dll $CI_PROJECT_DIR diff --git a/.gitlab/CI/check.gitlab-ci.yml b/.gitlab/CI/check.gitlab-ci.yml index c74f8d6aa1..fb8a13171a 100644 --- a/.gitlab/CI/check.gitlab-ci.yml +++ b/.gitlab/CI/check.gitlab-ci.yml @@ -5,11 +5,8 @@ code-quality: image: registry.gitlab.com/veloren/veloren-docker-ci/cache/quality:${CACHE_IMAGE_TAG} script: - ln -s /dockercache/target target - - rm -r target/debug/incremental/* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - - cargo clippy --all-targets --locked --features="bin_compression,bin_csv,bin_graphviz,bin_bot,asset_tweak" -- -D warnings - # Ensure that the veloren-voxygen default-publish feature builds as it excludes some default features - - cargo clippy -p veloren-voxygen --locked --no-default-features --features="default-publish" -- -D warnings - - cargo fmt --all -- --check + - cat ./.gitlab/scripts/code-quality.sh + - source ./.gitlab/scripts/code-quality.sh security: extends: .recompile-branch @@ -18,4 +15,5 @@ security: allow_failure: true script: - ln -s /dockercache/target target - - cargo audit + - cat ./.gitlab/scripts/security.sh + - source ./.gitlab/scripts/security.sh diff --git a/.gitlab/scripts/benchmark.sh b/.gitlab/scripts/benchmark.sh new file mode 100755 index 0000000000..492f70d10b --- /dev/null +++ b/.gitlab/scripts/benchmark.sh @@ -0,0 +1,4 @@ +#!/bin/bash +rm -r target/release/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly +rm -r target/release/incremental/* || echo "all good" # TMP FIX FOR 2021-03-22-nightly +time cargo bench \ No newline at end of file diff --git a/.gitlab/scripts/ci.sh b/.gitlab/scripts/ci.sh new file mode 100755 index 0000000000..8d72fc8339 --- /dev/null +++ b/.gitlab/scripts/ci.sh @@ -0,0 +1,4 @@ +#!/bin/bash +./.gitlab/scripts/security.sh +./.gitlab/scripts/code-quality.sh +./.gitlab/scripts/unittest.sh \ No newline at end of file diff --git a/.gitlab/scripts/code-quality.sh b/.gitlab/scripts/code-quality.sh new file mode 100755 index 0000000000..3a07d71057 --- /dev/null +++ b/.gitlab/scripts/code-quality.sh @@ -0,0 +1,6 @@ +#!/bin/bash +rm -r target/debug/incremental/* || echo "all good" # TMP FIX FOR 2021-03-22-nightly +time cargo clippy --all-targets --locked --features="bin_compression,bin_csv,bin_graphviz,bin_bot,asset_tweak" -- -D warnings && +# Ensure that the veloren-voxygen default-publish feature builds as it excludes some default features +time cargo clippy -p veloren-voxygen --locked --no-default-features --features="default-publish" -- -D warnings && +time cargo fmt --all -- --check \ No newline at end of file diff --git a/.gitlab/scripts/coverage.sh b/.gitlab/scripts/coverage.sh new file mode 100755 index 0000000000..f2a416d511 --- /dev/null +++ b/.gitlab/scripts/coverage.sh @@ -0,0 +1,7 @@ +#!/bin/bash +echo "modifying files in 5s, ctrl+c to abort" && sleep 5 +rm -r target/debug/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly +find ./* -name "Cargo.toml" -exec sed -i 's/, "simd"]/]/g' {} \; +find ./* -name "Cargo.toml" -exec sed -i 's/"simd"]/]/g' {} \; +sed -i 's/vek /#vek /g' ./Cargo.toml; +time cargo tarpaulin --skip-clean -v -- --test-threads=2; \ No newline at end of file diff --git a/.gitlab/scripts/env.sh b/.gitlab/scripts/env.sh new file mode 100644 index 0000000000..710ba8a330 --- /dev/null +++ b/.gitlab/scripts/env.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# exports default env variables in CI +export DISABLE_GIT_LFS_CHECK=true +export VELOREN_ASSETS="assets" +export RUSTFLAGS="-D warnings" +export SHADERC_LIB_DIR=/shaderc/combined/ \ No newline at end of file diff --git a/.gitlab/scripts/linux.sh b/.gitlab/scripts/linux.sh new file mode 100755 index 0000000000..3315a9366a --- /dev/null +++ b/.gitlab/scripts/linux.sh @@ -0,0 +1,6 @@ +#!/bin/bash +rm -r target/release/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly +export VELOREN_USERDATA_STRATEGY=executable +time cargo build --release --no-default-features --features default-publish && +time cargo build --release -p veloren-server-cli +# eveluate --bin instead, last time i checked (2021-07-14) it was 2 minutes slower on release (but faster on debug) \ No newline at end of file diff --git a/.gitlab/scripts/security.sh b/.gitlab/scripts/security.sh new file mode 100755 index 0000000000..34de50c299 --- /dev/null +++ b/.gitlab/scripts/security.sh @@ -0,0 +1,2 @@ +#!/bin/bash +time cargo audit \ No newline at end of file diff --git a/.gitlab/scripts/unittest.sh b/.gitlab/scripts/unittest.sh new file mode 100755 index 0000000000..a4193d3914 --- /dev/null +++ b/.gitlab/scripts/unittest.sh @@ -0,0 +1,7 @@ +#!/bin/bash +export VELOREN_ASSETS="$(pwd)/assets" +rm -r target/debug/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly +time cargo test --package veloren-i18n --lib test_all_localizations -- --nocapture --ignored && +time cargo test --package veloren-common-assets asset_tweak::tests --features asset_tweak --lib && +( rm -r target/debug/incremental* || echo "all good" ) && # TMP FIX FOR 2021-03-22-nightly +time cargo test \ No newline at end of file diff --git a/.gitlab/scripts/windows.sh b/.gitlab/scripts/windows.sh new file mode 100755 index 0000000000..bc7d849bd5 --- /dev/null +++ b/.gitlab/scripts/windows.sh @@ -0,0 +1,7 @@ +#!/bin/bash +update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix +update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix +rm -r target/release/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly +export VELOREN_USERDATA_STRATEGY=executable +time cargo build --target=x86_64-pc-windows-gnu --release --no-default-features --features default-publish && +time cargo build --target=x86_64-pc-windows-gnu --release -p veloren-server-cli \ No newline at end of file diff --git a/world/src/sim/erosion.rs b/world/src/sim/erosion.rs index c73ac49b97..7e4366a15c 100644 --- a/world/src/sim/erosion.rs +++ b/world/src/sim/erosion.rs @@ -607,7 +607,7 @@ fn get_max_slope( .into_boxed_slice() } -//simd alternative +// simd alternative #[cfg(not(feature = "simd"))] #[derive(Copy, Clone)] #[allow(non_camel_case_types)]