Skip to content

Commit

Permalink
details
Browse files Browse the repository at this point in the history
  • Loading branch information
fedebenelli committed Feb 29, 2024
1 parent d308062 commit 7939ab0
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Run tests
run: |
fpm test --profile debug --flag -coverage
bash ci/ci.sh
bash tools/ci.sh
# - name: Create coverage report
# run: |
Expand All @@ -69,4 +69,4 @@ jobs:
# - name: Upload coverage report
# uses: codecov/codecov-action@v2
# with:
# files: build/coverage/coverage.info
# files: build/coverage/coverage.info
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# fchem_db
# forsus

Pure chemical compounds database and general API.
8 changes: 6 additions & 2 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
name = "fchem_db"
name = "forsus"
version = "0.1.0"
license = "license"
author = "Federico E. Benelli"
maintainer = "fedebenelli@outlook.com"
maintainer = "federico.benelli@mi.unc.edu.ar"
copyright = "Copyright 2024, Federico E. Benelli"

[build]
auto-executables = true
auto-tests = true
auto-examples = true
module-naming = false

[install]
library = false

[fortran]
implicit-typing = false
implicit-external = false
source-form = "free"

[dependencies]
json-fortran = {git = "https://github.com/jacobwilliams/json-fortran" }
81 changes: 81 additions & 0 deletions tools/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
DESIRED_COVERAGE=90

DID_TEST=0

COVER=0

echoerr() { echo -e "$@" 1>&2; }

install_fpm() {
apt install pipx
pipx install fpm
}

green() {
echo -e "\e[1;32m$@\e[m"
}

red() {
echo -e "\e[1;31m$@\e[m"
}

run_test() {
echo y | fpm clean
DID_TEST=1
echo Checking tests files names...
NAMING_ERRORS=0
for file in $(find test/*f90); do
filename="$(basename $file)"
prefix="$(echo $filename | cut -d '_' -f1)"

if [ "$prefix" = "test" ]; then
green "$file [OK]"
else
NAMING_ERRORS=$((NAMING_ERRORS + 1))
red "$file [X]"
fi
done

[ $NAMING_ERRORS -ge 1 ] &&
echoerr "There are wrongly named files in the test directory"

echo Running tests...
fpm test --flag "--coverage"
}

run_coverage() {
COVER=$(gcovr \
--exclude "build" \
--exclude "test/test_runner.f90" \
--exclude "src/adiff/hyperdual.f90" \
--exclude "example" \
--exclude "src/legacy/*" \
--exclude "app"\
--exclude "tools" \
--fail-under-branch 90)
echo "$COVER"
COVER=$(echo "$COVER" | grep TOTAL | awk '{print $4}' | tr -d '%')
}

resumee() {
[ $DID_TEST = 1 ] &&
echo There has been $NAMING_ERRORS test naming errors

if [ ${COVER} -le 90 ]; then
echo "COVERAGE: " $(red $COVER)
else
echo "COVERAGE: " $(green $COVER)
fi
}

case $1 in
"install") install_fpm;;
"test") run_test;;
"coverage") run_coverage;;
*)
run_test
run_coverage;;
esac

resumee

0 comments on commit 7939ab0

Please sign in to comment.