forked from firetools/qgis2fds
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request firetools#2 from johodges/github-actions
Automate verification on ubuntu in github actions
- Loading branch information
Showing
77 changed files
with
8,632 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
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 | ||
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: 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: 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 }}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/bin/bash | ||
#BASE_DIR=$1 | ||
#NEW_DIR=$2 | ||
#DIFF_DIR=$3 | ||
#ERROR_DIR=$4 | ||
#TOLERANCE=$5 | ||
|
||
BASE_DIR=fds/ | ||
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" | ||
fi | ||
done |
Oops, something went wrong.