Skip to content

Commit 3864bd2

Browse files
authored
Merge pull request #11 from seamplex/playwright-tests
Unit tests
2 parents d9c64d3 + 32f43eb commit 3864bd2

27 files changed

Lines changed: 691 additions & 65 deletions

File tree

.github/workflows/playwright.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Playwright Tests
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
playwrigth-standalone:
11+
timeout-minutes: 60
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '18'
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: '8.3'
26+
extensions: yaml
27+
28+
- name: Install System Dependencies
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y unzip patchelf wget php-cli php-yaml gnuplot
32+
33+
- name: Install SunCAE Dependencies (FeenoX & Gmsh) standalone
34+
run: ./deps.sh
35+
36+
- name: Check script
37+
run: php html/check.php
38+
39+
- name: Install Node Dependencies
40+
run: npm ci
41+
42+
- name: Install Playwright Browsers
43+
run: npx playwright install --with-deps
44+
45+
- name: Run Playwright tests
46+
run: npx playwright test
47+
48+
- name: Upload Playwright Report
49+
if: failure()
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: playwright-report-standalone
53+
path: playwright-report-stanadlone/
54+
retention-days: 30
55+
56+
playwrigth-apt:
57+
timeout-minutes: 60
58+
runs-on: ubuntu-latest
59+
60+
steps:
61+
- uses: actions/checkout@v4
62+
63+
- name: Setup Node.js
64+
uses: actions/setup-node@v4
65+
with:
66+
node-version: '18'
67+
68+
- name: Setup PHP
69+
uses: shivammathur/setup-php@v2
70+
with:
71+
php-version: '8.3'
72+
extensions: yaml
73+
74+
- name: Install System Dependencies
75+
run: |
76+
sudo apt-get update
77+
sudo apt-get install -y unzip patchelf wget php-cli php-yaml gnuplot
78+
79+
# feenox 1.2 is not available in ubuntu 24.04, only in 25.10
80+
- name: Install SunCAE Dependencies (FeenoX & Gmsh) from apt
81+
run: |
82+
sudo apt-get install -y python3-gmsh pandoc
83+
./deps.sh
84+
85+
- name: Check script
86+
run: php html/check.php
87+
88+
- name: Install Node Dependencies
89+
run: npm ci
90+
91+
- name: Install Playwright Browsers
92+
run: npx playwright install --with-deps
93+
94+
- name: Run Playwright tests
95+
run: npx playwright test
96+
97+
- name: Upload Playwright Report
98+
if: failure()
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: playwright-report-apt
102+
path: playwright-report-apt/
103+
retention-days: 30

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
bin
22
deps
33
data
4+
node_modules/
5+
test-results/
6+
playwright-report/

autoclean.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ if [ ! -d auths ]; then
1616
echo 1
1717
fi
1818

19-
for i in bin deps data; do
19+
# cat .gitgnore?
20+
for i in bin deps data node_modules test-results playwright-report; do
2021
echo -n "cleaning ${i}... "
2122
rm -rf ${i} || exit 1
2223
echo "ok"
@@ -32,3 +33,8 @@ for i in $(find . -name .gitignore); do
3233
cd ${pwd}
3334
fi
3435
done
36+
37+
# more
38+
for i in x3dom.js x3dom.css; do
39+
find . -name {$i} | xargs rm -f
40+
done

cadimporters/upload/gmshcheck.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

cadprocessors/gmsh/cad2stl.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/python3
22
import sys
3-
sys.path.append("../../../../bin")
4-
import gmsh
53
import os
4+
5+
script_dir = os.path.dirname(os.path.abspath(__file__))
6+
bin_dir = os.path.join(script_dir, '../../', 'bin') # if bin is one level up
7+
if os.path.exists(bin_dir):
8+
sys.path.insert(0, bin_dir)
9+
import gmsh
10+
611
import math
712
import random
813
import colorsys

cadprocessors/gmsh/cadcheck.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/python3
22
import sys
3-
sys.path.append("../../../../bin")
4-
import gmsh
53
import os
4+
5+
script_dir = os.path.dirname(os.path.abspath(__file__))
6+
bin_dir = os.path.join(script_dir, '../../', 'bin') # if bin is one level up
7+
if os.path.exists(bin_dir):
8+
sys.path.insert(0, bin_dir)
9+
import gmsh
10+
611
import math
712
import json
813

cadprocessors/gmsh/cadimport.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#!/usr/bin/python3
22
import sys
3-
sys.path.append("../../../../bin")
4-
import gmsh
53
import os
4+
5+
script_dir = os.path.dirname(os.path.abspath(__file__))
6+
bin_dir = os.path.join(script_dir, '../../', 'bin') # if bin is one level up
7+
if os.path.exists(bin_dir):
8+
sys.path.insert(0, bin_dir)
69
import gmsh
10+
11+
import os
712
import math
813
import random
914
import colorsys

cadprocessors/gmsh/gmshcheck.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/python3
2+
import sys
3+
import os
4+
5+
script_dir = os.path.dirname(os.path.abspath(__file__))
6+
bin_dir = os.path.join(script_dir, '../../', 'bin') # if bin is one level up
7+
if os.path.exists(bin_dir):
8+
sys.path.insert(0, bin_dir)
9+
import gmsh
10+
11+
# Initialize the Gmsh API
12+
gmsh.initialize()
13+
14+
# Get the Gmsh version string
15+
version = gmsh.option.getString("General.Version")
16+
17+
# Print the version
18+
print(version)
19+
20+
# Finalize the Gmsh API
21+
gmsh.finalize()

cadprocessors/gmsh/process.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@
1414
return_error_json("username is empty");
1515
}
1616

17-
$cad_dir = "../../data/{$username}/cads/{$cad_hash}";
17+
$cad_dir = $data_dir . "{$username}/cads/{$cad_hash}";
1818
if (file_exists($cad_dir) === false) {
19-
mkdir($cad_dir, $permissions, true);
19+
if (mkdir($cad_dir, $permissions, true) === false) {
20+
return_error_json("cannot mkdir {$cad_dir}");
21+
}
22+
}
23+
if (chdir($cad_dir) === false) {
24+
return_error_json("cannot chdir to {$cad_dir}");
2025
}
21-
chdir($cad_dir);
2226

2327
// ------------------------------------------------------------
2428
if (file_exists("cad.json") === false) {
2529
exec(sprintf("%s/cadimport.py 2>&1", __DIR__), $output, $error_level);
26-
30+
2731
// TODO: keep output
2832
if ($error_level != 0) {
2933
$error_message = "Error {$error_level} when importing CAD: ";

deps.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@ for i in wget tar unzip python3; do
1919
fi
2020
done
2121

22+
# create gitignored directories
23+
mkdir -p deps bin
24+
25+
# this one needs to be either world writable or owned by the user running the web server
26+
# we start with 0777 but a sane admin would change it back to 0744 (or less)
2227
if [ ! -d data ]; then
2328
mkdir -p data
2429
chmod 0777 data
2530
fi
2631

27-
mkdir -p deps
2832

2933

30-
# Function to compare versions (include in main deps.sh or source from a utils file)
34+
# Function to compare versions
3135
version_ge() {
3236
printf '%s\n%s\n' "$2" "$1" | sort -V -C
3337
return $?

0 commit comments

Comments
 (0)