From 7939ab05a8d2b3d2acee54d733701278c032c113 Mon Sep 17 00:00:00 2001 From: "Federico E. Benelli" Date: Thu, 29 Feb 2024 10:06:10 -0300 Subject: [PATCH] details --- .github/workflows/CI.yml | 4 +- README.md | 4 +- fpm.toml | 8 +++- tools/ci.sh | 81 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 tools/ci.sh diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b93a95f..299367f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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: | @@ -69,4 +69,4 @@ jobs: # - name: Upload coverage report # uses: codecov/codecov-action@v2 # with: - # files: build/coverage/coverage.info \ No newline at end of file + # files: build/coverage/coverage.info diff --git a/README.md b/README.md index bffd069..2689e6f 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# fchem_db +# forsus + +Pure chemical compounds database and general API. diff --git a/fpm.toml b/fpm.toml index b3b18cc..eb05d3b 100644 --- a/fpm.toml +++ b/fpm.toml @@ -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" } diff --git a/tools/ci.sh b/tools/ci.sh new file mode 100644 index 0000000..4f76ee4 --- /dev/null +++ b/tools/ci.sh @@ -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 \ No newline at end of file