From 99f5c5ead78c1b007524cb0c8c62f8675aff62f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20De=20Keersmaeker?=
 <francois.dekeersmaeker@uclouvain.be>
Date: Mon, 14 Oct 2024 18:14:52 +0200
Subject: [PATCH] Added GitLab CI

---
 .ci_scripts/run-all-pcaps.py     |  6 ++++--
 .github/workflows/run-script.yml | 21 ---------------------
 .gitignore                       |  3 ++-
 .gitlab-ci.yml                   |  7 +++++++
 4 files changed, 13 insertions(+), 24 deletions(-)
 delete mode 100644 .github/workflows/run-script.yml
 create mode 100644 .gitlab-ci.yml

diff --git a/.ci_scripts/run-all-pcaps.py b/.ci_scripts/run-all-pcaps.py
index 7045cee..aaa1e1e 100755
--- a/.ci_scripts/run-all-pcaps.py
+++ b/.ci_scripts/run-all-pcaps.py
@@ -2,6 +2,7 @@
 
 # Imports
 import os
+from pathlib import Path
 import glob
 import pcap_fuzzer
 
@@ -10,8 +11,9 @@ import pcap_fuzzer
 if __name__ == "__main__":
 
     # Get paths
-    workspace_path = os.environ["GITHUB_WORKSPACE"]
-    traces_dir = os.path.join(workspace_path, "traces")
+    self_path = Path(os.path.abspath(__file__))
+    base_dir = self_path.parents[1]
+    traces_dir = os.path.join(base_dir, "traces")
 
     # Get all PCAP files
     all_pcaps = glob.glob(f"{traces_dir}/*.pcap")
diff --git a/.github/workflows/run-script.yml b/.github/workflows/run-script.yml
deleted file mode 100644
index 864821e..0000000
--- a/.github/workflows/run-script.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-name: Run script
-on: [push]
-
-jobs:
-
-  run-script:
-    runs-on: ubuntu-latest
-    steps:
-
-      - name: Checkout repository
-        uses: actions/checkout@v3
-
-      - name: Install dependencies
-        run: |
-          sudo apt-get update
-          sudo apt-get install -y python3-pip
-          pip3 install -r $GITHUB_WORKSPACE/requirements.txt
-          pip3 install .
-
-      - name: Run fuzzer on all PCAP files
-        run: python3 $GITHUB_WORKSPACE/.ci_scripts/run-all-pcaps.py
diff --git a/.gitignore b/.gitignore
index 9934f00..a17f01a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,8 @@
 # Environment config directories
 .vscode
 
-# Python build directories
+# Python directories
+.venv
 __pycache__
 build
 dist
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..8d9cf73
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,7 @@
+job-test:
+  script:
+    - python3 -m venv .venv                 # Create Python virtual environment
+    - source .venv/bin/activate             # Activate Python virtual environment
+    - pip3 install -r requirements.txt      # Install Python dependencies
+    - pip3 install .                        # Install the package
+    - python3 .ci_scripts/run-all-pcaps.py  # Run fuzzer on all PCAP files
-- 
GitLab