From 22ec19ec555210009780b40f759abdc047e432da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Tue, 19 Nov 2019 16:48:12 +0100 Subject: [PATCH 1/7] make cargo check less verbose --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e607a9c78d..910f3e27ec 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -113,7 +113,7 @@ check: tags: - veloren-docker script: - - RUSTFLAGS="-D warnings" cargo check --verbose + - RUSTFLAGS="-D warnings" cargo check code-quality: stage: check-compile From 56090313917a02d0164e1c80e63c09bb6aa8b492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Tue, 19 Nov 2019 20:26:27 +0100 Subject: [PATCH 2/7] simplify before-script --- .gitlab-ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 910f3e27ec..9f93fa9f0a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,16 +11,13 @@ stages: - post before_script: - - date - source $HOME/.cargo/env - - df -h + - df -h / - free -h - - gcc -v - cargo --version - export DISABLE_GIT_LFS_CHECK=true - rm -r target || echo "target doesnt exist, which is fine" - ln -s /dockercache/veloren/target target - - date # -- optional build From 67b589b3c91bcdb1afa42c327f141292626edcb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Tue, 19 Nov 2019 22:31:51 +0100 Subject: [PATCH 3/7] add tarpaulin coverage --- .gitlab-ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9f93fa9f0a..2a67a140e0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -142,6 +142,16 @@ unittests: - echo "Workaround, cargo tests fails due some rust files are already deleted, so we just stack cargo test. if its the os error, it wont appear on them all, if its a real error, it will retry and then fail" - cargo test || cargo test || cargo test || cargo test +coverage: + stage: post + when: delayed + start_in: 5 seconds + tags: + - veloren-docker + script: + - cargo tarpaulin -v + allow_failure: true + benchmarks: stage: post when: delayed From 4123de584295f106e4798a1bbab460206810dddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Wed, 20 Nov 2019 16:30:33 +0100 Subject: [PATCH 4/7] introduce custom-profiles --- Cargo.toml | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e74b2ca445..565625a42b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["named-profiles","profile-overrides"] + [workspace] members = [ "common", @@ -9,14 +11,45 @@ members = [ "world", ] +# default profile for devs, fast to compile, okay enough to run, no debug information [profile.dev] opt-level = 2 overflow-checks = false +debug-assertions = true panic = "abort" -# debug = false - -[profile.release] -# panic = "abort" debug = false -codegen-units = 1 +codegen-units = 8 +lto = false +incremental = true +# All dependencies (but not this crate itself) +[profile.dev.overrides."*"] +opt-level = 3 +[profile.dev.overrides."veloren-common"] +opt-level = 2 +[profile.dev.overrides."veloren-client"] +opt-level = 2 +[profile.dev.overrides."veloren-chat-cli"] +opt-level = 2 +[profile.dev.overrides."veloren-server"] +opt-level = 2 +[profile.dev.overrides."veloren-server-cli"] +opt-level = 2 +[profile.dev.overrides."veloren-voxygen"] +opt-level = 2 +[profile.dev.overrides."veloren-world"] +opt-level = 2 + +# this profile is used by developers if dev doesn't has enough debug information, the name must != debug, as debug is used by dev because.... +[profile.debuginfo] +inherits= 'dev' +debug = true + +# this profil is used for veloren releases, compile time doesn't matter +# we need stacktraces, light debug information, as much checks as possible +# i would like to put it in a seperate `official_release` target, but that doesnt share caches with `cargo test` and `cargo bench` +[profile.release] +opt-level = 3 +overflow-checks = true +debug-assertions = false lto = true +debug = false From b44792c83d5232fd72c34567a53f393597dce35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Thu, 21 Nov 2019 14:11:22 +0100 Subject: [PATCH 5/7] use gold linker instead of cc which is rust default for linux, which increases Compilcation by about 30% --- .cargo/config | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .cargo/config diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000000..ac018fb4e6 --- /dev/null +++ b/.cargo/config @@ -0,0 +1,4 @@ +[target.x86_64-unknown-linux-gnu] +rustflags = [ + "-C", "link-arg=-fuse-ld=gold", +] From e0d537685222001dbc5fbf98b825bcc44c9087b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Thu, 21 Nov 2019 14:11:37 +0100 Subject: [PATCH 6/7] Simplyfy builds and checks, when doing 2 builds, rust recompiles alot files and doesnt cache them, this is avoided by just call cargo build instead --- .gitlab-ci.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2a67a140e0..1303f4f380 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,8 +32,7 @@ before_script: optional-debug:linux: <<: *optional-debug script: - - cd voxygen && VELOREN_ASSETS=assets cargo build --verbose && cd .. - - cd server-cli && VELOREN_ASSETS=assets cargo build --verbose && cd .. + - VELOREN_ASSETS=assets cargo build --verbose - cp target/debug/veloren-server-cli $CI_PROJECT_DIR - cp target/debug/veloren-voxygen $CI_PROJECT_DIR - strip --strip-all veloren-server-cli @@ -49,8 +48,7 @@ optional-debug:linux: optional-debug:windows: <<: *optional-debug script: - - cd voxygen && VELOREN_ASSETS=assets cargo build --verbose --target=x86_64-pc-windows-gnu && cd .. - - cd server-cli && VELOREN_ASSETS=assets cargo build --verbose --target=x86_64-pc-windows-gnu && cd .. + - VELOREN_ASSETS=assets cargo build --verbose --target=x86_64-pc-windows-gnu - cp target/x86_64-pc-windows-gnu/debug/veloren-server-cli.exe $CI_PROJECT_DIR - cp target/x86_64-pc-windows-gnu/debug/veloren-voxygen.exe $CI_PROJECT_DIR artifacts: @@ -72,8 +70,7 @@ optional-debug:windows: optional-release:linux: <<: *optional-release script: - - cd voxygen && VELOREN_ASSETS=assets cargo build --verbose --release && cd .. - - cd server-cli && VELOREN_ASSETS=assets cargo build --verbose --release && cd .. + - VELOREN_ASSETS=assets 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 @@ -89,8 +86,7 @@ optional-release:linux: optional-release:windows: <<: *optional-release script: - - cd voxygen && VELOREN_ASSETS=assets cargo build --verbose --target=x86_64-pc-windows-gnu --release && cd .. - - cd server-cli && VELOREN_ASSETS=assets cargo build --verbose --target=x86_64-pc-windows-gnu --release && cd .. + - VELOREN_ASSETS=assets 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: @@ -174,8 +170,7 @@ linux: tags: - veloren-docker script: - - cd voxygen && VELOREN_ASSETS=assets cargo build --release && cd .. - - cd server-cli && VELOREN_ASSETS=assets cargo build --release && cd .. + - VELOREN_ASSETS=assets cargo build --release - cp -r target/release/veloren-server-cli $CI_PROJECT_DIR - cp -r target/release/veloren-voxygen $CI_PROJECT_DIR - strip --strip-all veloren-server-cli @@ -200,8 +195,7 @@ windows: tags: - veloren-docker script: - - cd voxygen && VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu --release && cd .. - - cd server-cli && VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu --release && cd .. + - VELOREN_ASSETS=assets cargo build --target=x86_64-pc-windows-gnu --release - 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 artifacts: From 1093d51c41d640385b192b5e15c862821a2cdd35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Thu, 21 Nov 2019 15:25:08 +0100 Subject: [PATCH 7/7] tarpaulin fails because it cannot parse Cargo.toml, somehow removing these lines makes tarpaulin run again, so we use it as a workaround/quickfix --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1303f4f380..81826abd87 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -145,6 +145,8 @@ coverage: tags: - veloren-docker script: + - sed -i '/cargo-features/d' Cargo.toml + - sed -i '/profile.dev.overrides/,+1d' Cargo.toml - cargo tarpaulin -v allow_failure: true