From 28bc56ced697dcf6fa17ed97e4c0a7c5a99c276a Mon Sep 17 00:00:00 2001
From: Anton Bagliy <taccessviolation@gmail.com>
Date: Thu, 28 Jan 2021 20:20:28 +0300
Subject: [PATCH] ADD: run all test stages in gitlab ci and pass in names

---
 .gitlab-ci.yml               | 88 ++++++++++++++++++++++++++++++------
 NunitReportParser/Program.cs | 13 ++++--
 grade.sh                     | 16 +++----
 3 files changed, 91 insertions(+), 26 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e6c05e4..6a11a86 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -17,18 +17,18 @@ build_all:
     - ./build.sh
   tags:
     - docker
-  artifacts:
-    paths:
-      - ./NunitReportParser/bin/Debug/NunitReportParser.exe
-      - ./TestSimpleLexer/bin/Debug/TestSimpleLexer.dll
-      - ./TestLexer/bin/Debug/TestLexer.dll
-      - ./TestGeneratedLexer/bin/Debug/TestGeneratedLexer.dll
-      - ./TestDescentParser/bin/Debug/TestDescentParser.dll
-      - ./TestGeneratedParser/bin/Debug/TestGeneratedParser.dll
-      - ./TestASTParser/bin/Debug/TestASTParser.dll
-      - ./TestVisitors/bin/Debug/TestVisitors.dll
-      - ./TestCodeGenerator/bin/Debug/TestCodeGenerator.dll
-    expire_in: 1 week
+  #artifacts:
+  #  paths:
+  #    - ./NunitReportParser/bin/Debug/NunitReportParser.exe
+  #    - ./TestSimpleLexer/bin/Debug/TestSimpleLexer.dll
+  #    - ./TestLexer/bin/Debug/TestLexer.dll
+  #    - ./TestGeneratedLexer/bin/Debug/TestGeneratedLexer.dll
+  #    - ./TestDescentParser/bin/Debug/TestDescentParser.dll
+  #    - ./TestGeneratedParser/bin/Debug/TestGeneratedParser.dll
+  #    - ./TestASTParser/bin/Debug/TestASTParser.dll
+  #    - ./TestVisitors/bin/Debug/TestVisitors.dll
+  #    - ./TestCodeGenerator/bin/Debug/TestCodeGenerator.dll
+  #  expire_in: 1 week
 
 
 testsimplelexer:
@@ -36,8 +36,9 @@ testsimplelexer:
   image: czen/ubuntu_xbuild
   script:
     - ./prebuild.sh
+    - ./build.sh
     - mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestSimpleLexer/bin/Debug/TestSimpleLexer.dll
-    - mono NunitReportParser/bin/Debug/NunitReportParser.exe ${TRAVIS_BUILD_DIR} ${TRAVIS_REPO_SLUG}
+    - mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
   tags:
     - docker
   
@@ -46,8 +47,9 @@ testlexer:
   image: czen/ubuntu_xbuild
   script:
     - ./prebuild.sh
+    - ./build.sh
     - mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestLexer/bin/Debug/TestLexer.dll
-    - mono NunitReportParser/bin/Debug/NunitReportParser.exe ${TRAVIS_BUILD_DIR} ${TRAVIS_REPO_SLUG}
+    - mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
   tags:
     - docker
 
@@ -56,8 +58,64 @@ testgeneratedlexer:
   image: czen/ubuntu_xbuild
   script:
     - ./prebuild.sh
+    - ./build.sh
     - mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestGeneratedLexer/bin/Debug/TestGeneratedLexer.dll
-    - mono NunitReportParser/bin/Debug/NunitReportParser.exe ${TRAVIS_BUILD_DIR} ${TRAVIS_REPO_SLUG}
+    - mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
   tags:
     - docker    
+
+testdescentparser:
+  stage: descentparser
+  image: czen/ubuntu_xbuild
+  script:
+    - ./prebuild.sh
+    - ./build.sh
+    - mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestDescentParser/bin/Debug/TestDescentParser.dll
+    - mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
+  tags:
+    - docker        
+
+testgeneratedparser:
+  stage: generatedparser
+  image: czen/ubuntu_xbuild
+  script:
+    - ./prebuild.sh
+    - ./build.sh
+    - mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestGeneratedParser/bin/Debug/TestGeneratedParser.dll
+    - mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
+  tags:
+    - docker            
+
+testastparser:
+  stage: astparser
+  image: czen/ubuntu_xbuild
+  script:
+    - ./prebuild.sh
+    - ./build.sh
+    - mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestASTParser/bin/Debug/TestASTParser.dll
+    - mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
+  tags:
+    - docker                
+
+testvisitors:
+  stage: visitors
+  image: czen/ubuntu_xbuild
+  script:
+    - ./prebuild.sh
+    - ./build.sh
+    - mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestVisitors/bin/Debug/TestVisitors.dll
+    - mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
+  tags:
+    - docker                
+
+testcodegenerator:
+  stage: codegenerator
+  image: czen/ubuntu_xbuild
+  script:
+    - ./prebuild.sh
+    - ./build.sh
+    - mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestCodeGenerator/bin/Debug/TestCodeGenerator.dll
+    - mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
+  tags:
+    - docker                    
   
\ No newline at end of file
diff --git a/NunitReportParser/Program.cs b/NunitReportParser/Program.cs
index 5aff321..6adbc08 100644
--- a/NunitReportParser/Program.cs
+++ b/NunitReportParser/Program.cs
@@ -1,4 +1,4 @@
-п»їusing System;
+using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Runtime.CompilerServices;
@@ -165,8 +165,15 @@ namespace NunitReport
                 basePath = args[0];
                 filePath = basePath + @"/TestResult.xml";
                 //userName = args[1].Split('/')[0];
-                string repoName = args[1].Split('/')[1];
-                userName = repoName.Substring(23, repoName.Length - 23);
+                nameparts = args[1].Split('/');
+                string repoName = "";
+                string userName = "";
+                if (nameparts.Length > 1) {
+                    repoName = nameparts[1];
+                    userName = repoName.Substring(23, repoName.Length - 23);
+                } else {
+                    userName = args[1];
+                }
             }
             else
             {
diff --git a/grade.sh b/grade.sh
index 4d27c44..71213cd 100755
--- a/grade.sh
+++ b/grade.sh
@@ -1,16 +1,16 @@
  mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestSimpleLexer/bin/Debug/TestSimpleLexer.dll
- mono NunitReportParser/bin/Debug/NunitReportParser.exe ${TRAVIS_BUILD_DIR} ${TRAVIS_REPO_SLUG}
+ mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
  mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestLexer/bin/Debug/TestLexer.dll
- mono NunitReportParser/bin/Debug/NunitReportParser.exe ${TRAVIS_BUILD_DIR} ${TRAVIS_REPO_SLUG}
+ mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
  mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestGeneratedLexer/bin/Debug/TestGeneratedLexer.dll
- mono NunitReportParser/bin/Debug/NunitReportParser.exe ${TRAVIS_BUILD_DIR} ${TRAVIS_REPO_SLUG}
+ mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
  mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestDescentParser/bin/Debug/TestDescentParser.dll
- mono NunitReportParser/bin/Debug/NunitReportParser.exe ${TRAVIS_BUILD_DIR} ${TRAVIS_REPO_SLUG}
+ mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
  mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestGeneratedParser/bin/Debug/TestGeneratedParser.dll
- mono NunitReportParser/bin/Debug/NunitReportParser.exe ${TRAVIS_BUILD_DIR} ${TRAVIS_REPO_SLUG}
+ mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
  mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestASTParser/bin/Debug/TestASTParser.dll
- mono NunitReportParser/bin/Debug/NunitReportParser.exe ${TRAVIS_BUILD_DIR} ${TRAVIS_REPO_SLUG}
+ mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
  mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestVisitors/bin/Debug/TestVisitors.dll
- mono NunitReportParser/bin/Debug/NunitReportParser.exe ${TRAVIS_BUILD_DIR} ${TRAVIS_REPO_SLUG}
+ mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
  mono packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe --labels=ON TestCodeGenerator/bin/Debug/TestCodeGenerator.dll
- mono NunitReportParser/bin/Debug/NunitReportParser.exe ${TRAVIS_BUILD_DIR} ${TRAVIS_REPO_SLUG}
\ No newline at end of file
+ mono NunitReportParser/bin/Debug/NunitReportParser.exe ${CI_PROJECT_DIR} ${GITLAB_USER_LOGIN}
\ No newline at end of file
-- 
GitLab