Skip to content

Commit

Permalink
Merge pull request #64 from johodges/dev
Browse files Browse the repository at this point in the history
Implementation of Github Actions for Verification on Ubuntu
  • Loading branch information
emanuelegissi committed Aug 7, 2023
2 parents d642202 + 2abd467 commit 2126f4e
Show file tree
Hide file tree
Showing 35 changed files with 8,646 additions and 4 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/github-actions-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Verify
run-name: ${{ github.actor }} is running verification
on:
push:
workflow_dispatch:
jobs:
Verification:
runs-on: ubuntu-latest
env:
QT_QPA_PLATFORM: offscreen
PATH: "/home/runner/FDS/FDS6/smvbin:/home/runner/FDS/FDS6/bin/INTEL/bin:/home/runner/FDS/FDS6/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/binner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/runner/.dotnet/tools"
FI_PROVIDER_PATH: "/home/runner/FDS/FDS6/bin/INTEL/prov"
LD_LIBRARY_PATH: "/home/runner/FDS/FDS6/bin/INTEL/lib:/usr/lib64:"
display_port: 1001
DISPLAY: ":1001"
PAUSE: 5
GH_TOKEN: ${{ github.token }}
steps:
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- run: sudo mkdir -m755 -p /etc/apt/keyrings
- run: sudo wget -O /etc/apt/keyrings/qgis-archive-keyring.gpg https://download.qgis.org/downloads/qgis-archive-keyring.gpg
- name: Make file
run: |
echo "Types: deb deb-src" > tmp.txt
echo "URIs: https://qgis.org/ubuntu-ltr" >> tmp.txt
echo "Suites: jammy" >> tmp.txt
echo "Architectures: amd64" >> tmp.txt
echo "Components: main" >> tmp.txt
echo "Signed-By: /etc/apt/keyrings/qgis-archive-keyring.gpg" >> tmp.txt
- run: sudo mv tmp.txt /etc/apt/sources.list.d/qgis.sources
- name: Update apt
run: sudo apt update
- name: Install qgis qgis-plugin-grass
run: sudo apt install qgis qgis-plugin-grass
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "The workflow is now ready to test your code on the runner."
- name: Configure plugin in qgis
run: sudo ln -s /home/runner/work/qgis2fds/qgis2fds /usr/share/qgis/python/plugins/qgis2fds
- name: Enable plugin in qgis
run: qgis_process plugins enable qgis2fds
#- name: Install FDS
# run: |
# wget https://github.com/firemodels/fds/releases/download/FDS-6.8.0/FDS-6.8.0_SMV-6.8.0_lnx.sh
# printf '1\n1\nyes\n' | bash FDS-6.8.0_SMV-6.8.0_lnx.sh
- name: Install FDS Nightly Build
run: |
cd /home/runner/
git clone https://github.com/firemodels/test_bundles
cd test_bundles
gh release download FDS_TEST --pattern '*_lnx.sh' -O "FDS-SMV-NIGHTLY.sh"
printf '1\n1\nyes\n' | bash FDS-SMV-NIGHTLY.sh
- name: Configure XServer
run: |
Xvfb :$display_port -fp /usr/share/X11/fonts/misc -screen 0 1280x1024x24 &
echo "setting up graphics environment (pausing $PAUSE s)"
- name: Run Verification
run: |
cd verification
source /home/runner/FDS/FDS6/bin/FDS6VARS.sh
bash headless_verify.sh
- name: Download baseline results
run: |
cd /home/runner/work/qgis2fds
git clone https://github.com/firetools/qgis2fds.figures.git
cp qgis2fds.figures/baseline/*/*.png qgis2fds.figures/baseline/
- name: Calculating image differences
run: |
cd verification
mkdir -p tests/test_out
mkdir -p tests/test_diff
mkdir -p tests/test_err
cp tests/*/output/*.png tests/test_out/
bash compare_images.sh
- name: List files in the repository
shell: bash
run: |
ls ${{ github.workspace }}/verification/tests/*/output/
NUMBER_OF_ERR_FILES=$(ls verification/tests/test_err/ -1 | wc -l)
echo "NUMBER_OF_ERR_FILES=$NUMBER_OF_ERR_FILES" >> "$GITHUB_ENV"
#- name: Setup upterm session
# uses: lhotari/action-upterm@v1
- name: Check coverage tolerance
if: ${{ env.NUMBER_OF_ERR_FILES > 0.0 }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('Rendered images out of tolerance')
- run: echo "This job's status is ${{ job.status }}."
15 changes: 11 additions & 4 deletions qgis2fds_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,12 @@ def set(cls, algo, config, project):
@classmethod
def get(cls, algo, parameters, context, feedback, project):
value = None
if parameters[cls.label]:
value = algo.parameterAsRasterLayer(parameters, cls.label, context)
try:
if parameters[cls.label]:
value = algo.parameterAsRasterLayer(parameters, cls.label, context)
except KeyError:
value = None
parameters[cls.label] = None
if value:
# Check local
url = value.source()
Expand Down Expand Up @@ -346,8 +350,11 @@ def set(cls, algo, config, project):
@classmethod
def get(cls, algo, parameters, context, feedback, project):
value = None
if parameters[cls.label]:
value = algo.parameterAsRasterLayer(parameters, cls.label, context)
try:
if parameters[cls.label]:
value = algo.parameterAsRasterLayer(parameters, cls.label, context)
except KeyError:
parameters[cls.label] = None
if value and not value.crs().isValid():
raise QgsProcessingException(
f"Texture layer CRS <{value.crs().description()}> not valid, cannot proceed."
Expand Down
75 changes: 75 additions & 0 deletions verification/compare_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash
#BASE_DIR=$1
#NEW_DIR=$2
#DIFF_DIR=$3
#ERROR_DIR=$4
#TOLERANCE=$5

BASE_DIR=../../qgis2fds.figures/baseline
NEW_DIR=tests/test_out
DIFF_DIR=tests/test_diff
ERROR_DIR=tests/test_err
TOLERANCE=0.025
METRIC=rmse

file_list=$DIFF_DIR/file_list

for f in $NEW_DIR/*.png; do
base=`basename $f`
echo "checking $base..."
blur_base=blur_$base
from_file=$BASE_DIR/$base
blur_from_file=$BASE_DIR/$blur_base
to_file=$NEW_DIR/$base
blur_to_file=$NEW_DIR/$blur_base
diff_file=$DIFF_DIR/$base
diff_file_changed=$DIFF_DIR/$base.changed
diff_file_metric=$DIFF_DIR/$base.metric
rm -f $diff_file $diff_file_changed $diff_file_metric
if [[ -e $from_file ]] && [[ -e $to_file ]]; then
convert $from_file -blur 0x2 $blur_from_file
convert $to_file -blur 0x2 $blur_to_file
diff=`compare -metric $METRIC $blur_from_file $blur_to_file $diff_file |& awk -F'(' '{printf $2}' | awk -F')' '{printf $1}i'`
composite $blur_from_file $blur_to_file -compose difference /tmp/diff.$$.png

SETGRAY=
if [ "$SETGRAY" == "1" ]; then
convert /tmp/diff.$$.png -channel RGB -negate /tmp/diff2.$$.png
convert /tmp/diff2.$$.png -colorspace Gray $diff_file
rm -f /tmp/diff.$$.png
rm -f /tmp/diff2.$$.png
else
convert /tmp/diff.$$.png -channel RGB -negate $diff_file
rm -f /tmp/diff.$$.png
fi
rm -f $blur_from_file $blur_to_file
if [ "$diff" == "" ]; then
diff=0
fi
if [[ $diff == *"e"* ]]; then
diff=$(printf "%.6f" $diff)
fi
echo $diff > $diff_file_metric
echo $base $diff >> $file_list
if [[ "$diff" != "0" ]] && [[ ! $diff == *"e"* ]]; then
iftest=`echo "${diff} > ${TOLERANCE}" | bc`
if [ 1 -eq $iftest ]; then
echo "***$FYI: The image $base has changed. $METRIC error=$diff > $TOLERANCE"
touch $diff_file_changed
IMAGE_ERRORS=$((IMAGE_ERRORS + 1))
# cp $base $ERROR_SUBDIR/.
cp $f $ERROR_DIR/.
else
echo "PASSED: The image $base has not changed. $METRIC error=$diff <= $TOLERANCE"
fi
fi
if [[ "$diff" != "0" ]]; then
DIFFS=$((DIFFS + 1))
fi
fi
if [[ ! -e $from_file ]]; then
echo "***$FYI: The base image $from_file does not exist."
echo " Copy $to_file to the fig repo"
cp $f $ERROR_DIR/.
fi
done
Binary file removed verification/fds/golden_gate_local_tex.png
Binary file not shown.
12 changes: 12 additions & 0 deletions verification/headless_verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cd tests/test_cern_meyrin
bash test_cern_meyrin_geom.sh
bash test_cern_meyrin_obst.sh
cd ../..
cd tests/test_golden_gate_local
bash test_golden_gate_local_geom.sh
bash test_golden_gate_local_obst.sh
cd ../..
cd tests/test_golden_gate_remote
bash test_golden_gate_remote_geom.sh
bash test_golden_gate_remote_obst.sh
cd ../..
Loading

0 comments on commit 2126f4e

Please sign in to comment.