Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .fz/calculators/Cast3m.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if [ -z "$DGIBI_FILE" ]; then
fi

# Validate the .dgibi file path (basic validation)
if [[ ! "$DGIBI_FILE" =~ ^[a-zA-Z0-9._/ -]+$ ]]; then
if [[ ! "$DGIBI_FILE" =~ ^[a-zA-Z0-9./_-]+$ ]]; then
echo "Error: Invalid characters in .dgibi filename"
exit 1
fi
Expand Down
File renamed without changes.
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

permissions:
contents: read

jobs:
test:
name: Test Plugin Structure
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Install fz framework
run: |
pip install git+https://github.com/Funz/fz.git

- name: Validate JSON files
run: |
echo "Validating model files..."
for f in .fz/models/*.json; do
echo " Checking $f"
python -m json.tool "$f" > /dev/null
done
echo "Validating calculator config files..."
for f in .fz/calculators/*.json; do
echo " Checking $f"
python -m json.tool "$f" > /dev/null
done

- name: Check shell script syntax
run: |
echo "Checking shell scripts..."
for f in .fz/calculators/*.sh; do
echo " Checking $f"
bash -n "$f"
done

- name: Test fzi (parse variables)
run: |
python -c "
import fz
variables = fz.fzi('examples/Cast3m/poutre_parametric.dgibi', 'Cast3m')
print(f'Variables found: {list(variables.keys())}')
assert 'long' in variables, 'Variable long not found'
assert 'haut' in variables, 'Variable haut not found'
print('✓ fzi test passed')
"

- name: Test fzc (compile input)
run: |
python -c "
import fz
import tempfile
import os
with tempfile.TemporaryDirectory() as tmpdir:
fz.fzc('examples/Cast3m/poutre_parametric.dgibi', {'long': 0.30, 'haut': 0.001, 'larg': 0.01, 'F': 1.0}, 'Cast3m', output_dir=tmpdir)
# Find compiled file in subdirectory
compiled = None
for root, dirs, files in os.walk(tmpdir):
if 'poutre_parametric.dgibi' in files:
compiled = os.path.join(root, 'poutre_parametric.dgibi')
break
assert compiled is not None, 'Compiled file not created'
with open(compiled) as f:
content = f.read()
assert '0.30' in content or '0.3' in content, 'Variable not substituted'
print('✓ fzc test passed')
"

- name: Run plugin tests
run: |
python tests/test_plugin.py

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check shell scripts are executable
run: |
for f in .fz/calculators/*.sh; do
if [ ! -x "$f" ]; then
echo "Error: $f is not executable"
exit 1
fi
done

docs:
name: Check Documentation
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check required documentation files
run: |
for f in README.md LICENSE; do
if [ ! -f "$f" ]; then
echo "Error: Missing $f"
exit 1
fi
echo "✓ $f exists"
done

- name: Check example files
run: |
if [ ! -f "examples/Cast3m/poutre_parametric.dgibi" ]; then
echo "Error: Missing example input file"
exit 1
fi
echo "✓ Example files present"
26 changes: 10 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
# Results and temporary files
results/
*.out
*.msg
*.html
PID

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
venv/
ENV/
*.egg-info/
dist/
build/
.venv

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# Test results
results/
compiled/
*.out
*.log
# fz temporary files
.fz/tmp/

# Cast3m specific
*.hermes
Expand Down
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2025, Funz Contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading