Skip to content

Add extra check for invalid UTF-8 BOM of IFC files #63

Add extra check for invalid UTF-8 BOM of IFC files

Add extra check for invalid UTF-8 BOM of IFC files #63

Workflow file for this run

name: Model validation
on: [push, pull_request, workflow_dispatch]
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 5
- name: Setup python environment
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --user pyparsing lark-parser==0.12.0 networkx requests sqlalchemy sqlalchemy-utils pytest
mkdir -p ~/.local/lib/python3.11/site-packages
wget -q https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-311-v0.7.0-f7c03db-linux64.zip
unzip ifcopenshell-python-311-v0.7.0-f7c03db-linux64.zip -d ~/.local/lib/python3.11/site-packages
git clone --depth 1 https://github.com/IfcOpenShell/step-file-parser
pip install --user -r ./step-file-parser/requirements.in
- name: Check for UTF-8 BOM
run: "! find ./models -name '*.ifc' -print0 | xargs -0 grep -l $'^\\xEF\\xBB\\xBF' | grep ."
- name: Validate IFC example files
run: |
valid_count=0
invalid_count=0
set +e
while IFS= read -r file; do
printf "Validating $file ..."
python ./step-file-parser/main.py "$file" > validate.log 2>&1
exit_code=$?
if [ $exit_code -eq 0 ]; then
((valid_count++))
printf " valid\n"
else
((invalid_count++))
printf " invalid\n"
fi
done < <(find ./models -type f -name '*.ifc')
echo "Number of valid files: $valid_count"
echo "Number of invalid files: $invalid_count"
set -e
if [ $invalid_count -gt 0 ]; then
exit 1
fi
- name: Model validation
run: |
./validate.sh