Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2be761a
added ROS1 Laser block
BkPankaj May 21, 2024
a600cc2
added npm install yml code
BkPankaj May 29, 2024
57abe50
changed node version
BkPankaj May 29, 2024
de5a9fd
adding legacy in npm install
BkPankaj May 30, 2024
a6af77f
added backend installation
BkPankaj Jun 1, 2024
c544b5b
added CI workflow with basic frontend test
BkPankaj Jun 2, 2024
089ba3e
added permission for node modules
BkPankaj Jun 2, 2024
3bf4bad
changed node version to 18
BkPankaj Jun 2, 2024
d8bed49
modified node modules with cache
BkPankaj Jun 2, 2024
e74bdb3
added opening google.com using selenium in standalone-chrome ~ first …
BkPankaj Jun 5, 2024
226ee9f
added automatic Opening VC and clicking File and Open button of menubar
BkPankaj Jun 6, 2024
57123cc
Update first_test.py
BkPankaj Aug 12, 2024
501ea9a
Adding the frontend test 2 yml
BkPankaj Aug 14, 2024
095681a
Merge branch 'master' into gitActions/CIWorkflow
BkPankaj Aug 14, 2024
2cda3d9
added xvfb in yml
BkPankaj Aug 14, 2024
b74fd3f
changing xvfb
BkPankaj Aug 14, 2024
272bfcd
modifying display option in first_test.py
BkPankaj Aug 14, 2024
688a25a
Update CI_Workflow.yml
BkPankaj Aug 14, 2024
31498c4
Update CI_Workflow.yml .github
BkPankaj Aug 14, 2024
5051d63
adding artifacts for backend
BkPankaj Aug 16, 2024
271a07e
collectstatic added in yml
BkPankaj Aug 16, 2024
29a7a2f
Update CI_Workflow.yml
BkPankaj Aug 16, 2024
ddc6f99
Update CI_Workflow.yml
BkPankaj Aug 16, 2024
98924ad
Update CI_Workflow.yml test
BkPankaj Aug 16, 2024
eb4fb33
Update CI_Workflow.yml test frontend
BkPankaj Aug 16, 2024
b874df9
Update CI_Workflow.yml
BkPankaj Aug 16, 2024
b65efbe
Update CI_Workflow.yml
BkPankaj Aug 16, 2024
83ebbf3
Update CI_Workflow.yml
BkPankaj Aug 16, 2024
dc6eea4
Update CI_Workflow.yml
BkPankaj Aug 16, 2024
b57ff56
Update CI_Workflow.yml
BkPankaj Aug 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 70 additions & 7 deletions .github/first_test.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,50 @@

import sys

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time

import pyautogui
import os




try:
# Set up the webdriver to connect to the remote Selenium server
options = webdriver.ChromeOptions()


# Configure Chrome preferences to allow downloads
prefs = {
"download.default_directory": "/home/seluser/Downloads",
"download.prompt_for_download": False,
"safebrowsing.enabled": True,
"safebrowsing.disable_download_protection": True
}
options.add_argument('--headless') # Enable headless mode
options.add_argument('--disable-gpu') # Disable GPU acceleration in headless mode
options.add_experimental_option("prefs", prefs)
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')

# Disable headless mode to show the Chrome UI
# options.add_argument('--headless=false')

options.add_argument("--allow-running-insecure-content") # Allow insecure content
options.add_argument("--unsafely-treat-insecure-origin-as-secure=http://localhost:4000")
# Remote WebDriver URL (provided by the selenium/standalone-chrome service)
driver = webdriver.Remote(
command_executor='http://localhost:4444/wd/hub',
options=options
)

# Open the browser and go to the URL
driver.get('http://IP:4000')

driver.get('http://localhost:4000')


# time.sleep(120)

Expand All @@ -38,16 +62,55 @@
)

# Wait for the "Open" menu item to be clickable and click it
code_menu_item = WebDriverWait(driver, 20).until(
open_menu_item = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.XPATH, "//ul[@role='menu' and @aria-label='File']//li[text()='Open']"))
)
code_menu_item.click()
open_menu_item.click()

# Wait for the file input element to be present in the dialog
file_input = WebDriverWait(driver, 20).until(
EC.presence_of_element_located((By.XPATH, "//input[@type='file']"))
)

# Use pyautogui to handle the file upload dialog
time.sleep(2) # Wait for the file dialog to appear
pyautogui.write('/home/seluser/Demo_Autoparking_ROS2_1.vc3')
pyautogui.press('enter')

time.sleep(2)

# Wait for the "File" button to be clickable and click it
basic_button = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.XPATH, "//button[contains(@class, 'menu-button') and .//span[text()='File']]"))
)
basic_button.click()

# Wait for the dropdown menu to be visible
dropdown_menu = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.XPATH, "//ul[@role='menu' and @aria-label='File']"))
)

# Wait for the "Open" menu item to be clickable and click it

open_menu_item = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.XPATH, "//ul[@role='menu' and @aria-label='File']//li[text()='Build and Download']"))
)
open_menu_item.click()


time.sleep(20)

time.sleep(20)

download_directory = "/home/seluser/Downloads"
zip_files = [f for f in os.listdir(download_directory) if f.endswith('.zip')]

if zip_files:
print("Test Passed: .zip file downloaded successfully.")
sys.exit(0) # Exit with code 0 for success
else:
print("Test Failed: No .zip file found.")
sys.exit(1) # Exit with code 1 for failure

# Capture a screenshot
driver.get_screenshot_as_file('screenshot.png')

finally:
# Close the browser
Expand Down
144 changes: 139 additions & 5 deletions .github/workflows/CI_Workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ jobs:
restore-keys: |
${{ runner.os }}-node-


- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: '3.x'

- name: Create virtual environment
run: python -m venv .venv
Expand All @@ -53,17 +52,55 @@ jobs:
run: cp backend/.env.template backend/.env

- name: Generate static files
run: python backend/manage.py collectstatic
run: python backend/manage.py collectstatic --noinput

- name: Save venv
uses: actions/upload-artifact@v4
with:
name: venv
path: .venv

frontend-tests:
test-1:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Restore Node modules cache
id: restore-node-modules
uses: actions/cache@v4
with:
path: frontend/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/frontend/package-lock.json') }}

- name: Install frontend dependencies
if: steps.restore-node-modules.outputs.cache-hit != 'true'
working-directory: frontend
run: npm ci --legacy-peer-deps

- name: Permissions for node_modules
run: chmod -R +x frontend/node_modules/.bin

- name: Verify node_modules restoration
run: |
ls -la frontend/node_modules
ls -la frontend/node_modules/.bin

- name: Run frontend test
run: npm test -- --watchAll=false
working-directory: frontend

tests-2:
runs-on: ubuntu-latest
needs: setup

services:
selenium:
image: selenium/standalone-chrome
ports:
- 4444:4444

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -90,4 +127,101 @@ jobs:

- name: Run frontend test
run: npm test -- --watchAll=false
working-directory: frontend
working-directory: frontend

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Restore backend artifacts
uses: actions/download-artifact@v4
with:
name: venv
path: .venv

- name: Activate virtual environment
run: source .venv/bin/activate

- name: Install Selenium dependencies
run: |
python -m pip install --upgrade pip
pip install selenium pyautogui

- name: Install Xvfb
run: sudo apt-get install -y xvfb

- name: Add .env file
run: cp backend/.env.template backend/.env

- name: Verify Python path
run: |
which python
python --version

- name: Reinstall dependencies (ensure Django is installed)
run: pip install -r backend/requirements.txt

- name: Check if Django is installed
run: python3 -m django --version

- name: Generate static files
run: python3 backend/manage.py collectstatic --noinput

- name: Start backend server
run: python3 manage.py runserver 8080 &
working-directory: backend



- name: Start frontend server
run: npm start > frontend_server.log &
working-directory: frontend

- name: Wait for servers to start
run: sleep 30

- name: Start backend server
run: python backend/manage.py runserver 8080 > backend_server.log &
working-directory: backend

- name: Wait for servers to start
run: sleep 15

- name: Upload server logs
uses: actions/upload-artifact@v4
with:
name: server-logs
path: |
frontend/frontend_server.log
backend/backend_server.log

- name: Start Xvfb
run: |
Xvfb :99 -screen 0 1280x1024x16 &
echo "DISPLAY=:99" >> $GITHUB_ENV

- name: Check if server is running on port 8080
run: curl -I http://127.0.0.1:8080

- name: Check if server is running on port 4000
run: curl -I http://localhost:4000

- name: Run Selenium tests
run: xvfb-run -a python .github/first_test.py > selenium_test.log

- name: Upload Selenium logs
uses: actions/upload-artifact@v4
with:
name: selenium-logs
path: selenium_test.log


- name: Upload Selenium logs 1
uses: actions/upload-artifact@v4
with:
name: selenium-logs
path: |
frontend/chromedriver.log
frontend/geckodriver.log