From 5172c0e4f0a4c70d3052d31ed7f5398e719b0365 Mon Sep 17 00:00:00 2001
From: Volker Schukai <volker.schukai@schukai.com>
Date: Sun, 21 Apr 2024 11:54:07 +0200
Subject: [PATCH] fix: cleanup script

---
 .gitlab-ci.yml                            |  2 +-
 .idea/workspace.xml                       |  6 +++++-
 flake.nix                                 |  6 ++++++
 nix/scripts/{cleanup.nix => clean-up.nix} |  3 +++
 nix/scripts/go-task.nix                   |  1 +
 nix/scripts/run-extended-tests.nix        | 23 ++++++++++++++++++-----
 6 files changed, 34 insertions(+), 7 deletions(-)
 rename nix/scripts/{cleanup.nix => clean-up.nix} (82%)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 42ac17e..3f959fb 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -55,7 +55,7 @@ deploy:
   script:
     - nix develop --command deploy
   after_script:
-    - nix develop --command cleanup 
+    - nix develop --command clean-up 
 
   when: on_success
 
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2b23e35..74c38da 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,8 +5,12 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="9979eb22-471e-4f2f-b624-fd3edb5e8c6e" name="Changes" comment="">
+      <change beforePath="$PROJECT_DIR$/.gitlab-ci.yml" beforeDir="false" afterPath="$PROJECT_DIR$/.gitlab-ci.yml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/nix/scripts/run-ci-tests.nix" beforeDir="false" afterPath="$PROJECT_DIR$/nix/scripts/run-ci-tests.nix" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/flake.nix" beforeDir="false" afterPath="$PROJECT_DIR$/flake.nix" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/nix/scripts/cleanup.nix" beforeDir="false" afterPath="$PROJECT_DIR$/nix/scripts/clean-up.nix" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/nix/scripts/go-task.nix" beforeDir="false" afterPath="$PROJECT_DIR$/nix/scripts/go-task.nix" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/nix/scripts/run-extended-tests.nix" beforeDir="false" afterPath="$PROJECT_DIR$/nix/scripts/run-extended-tests.nix" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
diff --git a/flake.nix b/flake.nix
index a3d03cb..c2558ef 100644
--- a/flake.nix
+++ b/flake.nix
@@ -23,6 +23,9 @@
       script-run-ci-tests = pkgs'.callPackage ./nix/scripts/run-ci-tests.nix {};
       script-check-code = pkgs'.callPackage ./nix/scripts/check-code.nix {};
       script-build-cover-report = pkgs'.callPackage ./nix/scripts/build-cover-report.nix {};
+      
+      script-clean-up = pkgs'.callPackage ./nix/scripts/clean-up.nix {};
+      script-deploy = pkgs'.callPackage ./nix/scripts/deploy.nix {};
 
       import-version = version.packages.${system}.version;
     in {
@@ -38,6 +41,9 @@
               script-check-code
               script-build-cover-report
               script-task
+              
+              script-clean-up
+              script-deploy
 
               import-version
 
diff --git a/nix/scripts/cleanup.nix b/nix/scripts/clean-up.nix
similarity index 82%
rename from nix/scripts/cleanup.nix
rename to nix/scripts/clean-up.nix
index 8dc2182..4b80e16 100644
--- a/nix/scripts/cleanup.nix
+++ b/nix/scripts/clean-up.nix
@@ -10,7 +10,10 @@ in
 
     echo_header "Cleaning up"
 
+    echo_step "Removing credentials"
     ${pkgs.git}/bin/git config --global --unset credential.helper
     if [ -f /root/.docker/config.json ]; then rm /root/.docker/config.json; fi
+    
+    echo_ok "Cleaned up"
 
   ''
diff --git a/nix/scripts/go-task.nix b/nix/scripts/go-task.nix
index 15c7eb2..19cd514 100644
--- a/nix/scripts/go-task.nix
+++ b/nix/scripts/go-task.nix
@@ -24,6 +24,7 @@
           - ret
         env:
           TEST_BY_TASK: true
+          USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"          
         cmds:
           - run-extended-tests
         silent: true
diff --git a/nix/scripts/run-extended-tests.nix b/nix/scripts/run-extended-tests.nix
index eca5e38..04276ae 100644
--- a/nix/scripts/run-extended-tests.nix
+++ b/nix/scripts/run-extended-tests.nix
@@ -9,32 +9,45 @@ in
 
     ${common}
 
-    echo_header "Running tests"
-    echo_step "Downloading docker images"
+    echo_header "Running extended tests"
 
     download_test_images
     setup_go_env
+    cd_working_dir
 
-    echo_section "Running tests"
+    echo_step "Running tests"
     if ! ${pkgs.go}/bin/go test -tags "runOnTask" -cover ./...
     then
       echo_fail "Failed to run tests"
       exit 1
     fi
+    echo_ok "All tests passed"
 
-    echo_section "Running tests"
+    echo_step "Running benchmarks"
     if ! ${pkgs.go}/bin/go test -tags "runOnTask,bench" -bench ./...
     then
       echo_fail "Failed to run benchmarks"
       exit 1
     fi
+    echo_ok "Benchmarks passed"
 
-    echo_section "Running tests"
+    echo_step "Running race tests"
     if ! ${pkgs.go}/bin/go test -tags "runOnTask,race" -race ./...
     then
       echo_fail "Failed to run race tests"
       exit 1
     fi
+    echo_ok "race tests passed"
+    
+    echo_step "Running fuzz tests"
+    if ! ${pkgs.go}/bin/go test -tags "runOnTask,fuzz" -fuzz ./...
+    then
+      echo_fail "Failed to run fuzz tests"
+      exit 1
+    fi
+    
+    echo_ok "Fuzz tests passed"
+    echo_ok "All tests passed"
 
 
   ''
-- 
GitLab