From ae8b992eed4c4a03051d934c1485477b00a6f0e9 Mon Sep 17 00:00:00 2001
From: Vincent Lafeychine <vincent.lafeychine@proton.me>
Date: Sat, 29 Oct 2022 21:28:09 +0200
Subject: [PATCH] fix(ci): Remove cache for coverage - There is too many issues
 with it

---
 .gitlab-ci.yml | 40 +++++++++++++++++++---------------------
 flake.nix      |  4 ++--
 2 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6b39240b..33422f7a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,29 +1,27 @@
-image: vlafeychine/rust
-
 .push-zamok: &push-zamok
   - eval $(ssh-agent -s)
   - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
   - \[ -d ${ZAMOK_SOURCE} \] && 
         rsync -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -rqz ${ZAMOK_SOURCE}/. v-lafeychine@zamok.crans.org:www/proost/${ZAMOK_TARGET} || true
 
-stages: [check, build, tests, docs]
+default:
+  image: vlafeychine/rust
+  interruptible: true
+  cache:
+    paths:
+      - .cache/cargo/
+      - target/
 
 variables:
   CARGO_HOME: "$CI_PROJECT_DIR/.cache/cargo/"
   RUSTFLAGS: "-D warnings"
 
-cache:
-  key: "$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"
-  paths:
-    - .cache/cargo/
-    - target/
 
-default:
-  interruptible: true
+stages: [ check, build, tests, docs ]
 
 format:
-  cache: []
   stage: check
+  cache: []
   script:
     - cargo fmt --check
 
@@ -39,7 +37,6 @@ build:
 
 tests:
   stage: tests
-
   variables:
     CARGO_INCREMENTAL: 0
     EXCLUDE_BR_REGEXP: "#\\[|unreachable!|assert(_eq)?!"
@@ -50,34 +47,35 @@ tests:
     ZAMOK_SOURCE: coverage
     ZAMOK_TARGET: coverage/${CI_COMMIT_REF_SLUG}
 
+  cache:
+    paths:
+      - .cache/cargo/
+
   script:
     - cargo test
-    - ${GRCOV} --ignore "*cargo*" -t cobertura -o ./coverage.xml &&
-        xsltproc --novalid --output ./target/coverage.xml ./.gitlab-cov.xsl ./coverage.xml || true
-    - ${GRCOV} --ignore "*cargo*" -t lcov -o ./target/coverage.lcov &&
-        genhtml --branch --no-function-coverage --precision 2 ./target/coverage.lcov -o ./coverage || true
-    - find ./target \( -name "*.gcda" -or -name "*.gcno" \) -delete
+    - ${GRCOV} --ignore "*cargo*" -t cobertura -o ./coverage_raw.xml &&
+        xsltproc --novalid --output ./coverage.xml ./.gitlab-cov.xsl ./coverage_raw.xml || true
+    - ${GRCOV} --ignore "*cargo*" -t lcov -o ./coverage.lcov &&
+        genhtml --branch --no-function-coverage --precision 2 ./coverage.lcov -o ./coverage || true
     - *push-zamok
 
   artifacts:
     reports:
       coverage_report:
         coverage_format: cobertura
-        path: ./target/coverage.xml
+        path: ./coverage.xml
 
   coverage: '/^  branches...: \d+.\d+%/'
 
 
 docs:
   stage: docs
-
   variables:
     ZAMOK_SOURCE: target/doc
     ZAMOK_TARGET: doc
 
   only:
-    refs:
-      - main
+    refs: [ main ]
 
   script:
     - cargo doc --no-deps
diff --git a/flake.nix b/flake.nix
index 86e021f4..7c5546b2 100644
--- a/flake.nix
+++ b/flake.nix
@@ -53,7 +53,7 @@
 
             copyToRoot = pkgs.buildEnv {
               name = "proost-dependencies";
-              paths = (with pkgs; [ coreutils findutils gcc gnugrep gnused grcov lcov libxslt openssh rsync rust-ci ])
+              paths = (with pkgs; [ coreutils gcc gnugrep gnused grcov lcov libxslt openssh rsync rust-ci ])
                 ++ (with pkgs.dockerTools; [ binSh caCertificates fakeNss ]);
               pathsToLink = [ "/bin" "/etc" ];
             };
@@ -70,7 +70,7 @@
           commands = [{
             name = "coverage";
             command = let 
-              excl_br_regexp = "#\\[|unreachable!()|assert(_eq)?!";
+              excl_br_regexp = "#\\[|unreachable!|assert(_eq)?!";
               excl_regexp = "//!|///|#\\[|use";
               env = "CARGO_INCREMENTAL=0"
                   + " RUSTFLAGS=\"-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort\""
-- 
GitLab