Skip to content

Commit

Permalink
Merge pull request #52 from echoix/codecov-integration
Browse files Browse the repository at this point in the history
Codecov integration
  • Loading branch information
echoix authored Feb 3, 2024
2 parents b2c4d10 + 76967fa commit d13cf59
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ jobs:
uses: codecov/codecov-action@v4
with:
verbose: true
gcov: true
# gcov: true
flags: pytest-python-${{ matrix.python-version }}
name: pytest-python-${{ matrix.python-version }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}

pytest-success:
name: pytest Result
Expand Down
49 changes: 35 additions & 14 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,41 @@ jobs:
echo "${delete[@]}"
for target in "${delete[@]}"; do
for i in "${!array[@]}"; do
if [[ ${array[i]} = $target ]]; then
if [[ ${array[i]} = "$target" ]]; then
unset 'array[i]'
fi
done
done
unset new_array
for i in "${!array[@]}"; do
new_array+=( "${array[i]}" )
new_array+=( "${array[i]}" )
done
echo "Excluded folders:"
echo "${new_array[@]}"
printf -v extra_exclude './%s/* ' "${new_array[@]}"
echo "Exclusion string to add to gunittest config"
echo "${extra_exclude}"
echo "extra-exclude=${extra_exclude}" >> "${GITHUB_OUTPUT}"
echo "Inclusion string for tags"
printf -v extra_include_tag ' %s' "${delete[@]}"
extra_include_tag="${extra_include_tag:1}" # trim extra first space
extra_include_tag=${extra_include_tag// /-} # replace spaces by hyphens
echo "${extra_include_tag}"
echo "extra-include-tag=${extra_include_tag}" >> "${GITHUB_OUTPUT}"
echo "Truncated string for codecov upload"
max_flag_len=45
max_flag_prefix_len=33 # gunittest-ubuntu-22.04_without_x-
max_flag_suffix_len=$((max_flag_len - max_flag_prefix_len))
extra_include_tag_len=${#extra_include_tag} # string's length
extra_include_tag_len_len=${#extra_include_tag_len} # length of string's length
if [[ "${extra_include_tag_len}" -gt "${max_flag_suffix_len}" ]]; then
# Extra include too long
extra_include_tag_trunc="${extra_include_tag:0:$max_flag_suffix_len-1-$extra_include_tag_len_len}.${extra_include_tag_len}"
else
extra_include_tag_trunc="${extra_include_tag}"
fi
echo "${extra_include_tag_trunc}"
echo "extra-include-tag-trunc=${extra_include_tag_trunc}" >> "${GITHUB_OUTPUT}"
env:
DELETE_ARRAY: ${{ matrix.extra-include }}

Expand All @@ -104,9 +124,11 @@ jobs:
- name: Get dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y wget git gawk findutils python3-coverage
sudo apt-get install -y wget git gawk findutils
xargs -a <(awk '! /^ *(#|$)/' ".github/workflows/apt.txt") -r -- \
sudo apt-get install -y --no-install-recommends --no-install-suggests
- name: Install python coverage tool
run: pip install coverage

- name: Create installation directory
run: |
Expand Down Expand Up @@ -158,36 +180,35 @@ jobs:
- name: Run tests
run: INITIAL_PWD="${PWD}" .github/workflows/test_thorough.sh --config .gunittest.extra.cfg
env:
PYTHON: python3-coverage run --branch --parallel-mode --concurrency=multiprocessing,thread
PYTHON: coverage run --branch --parallel-mode --concurrency=multiprocessing,thread
INITIAL_GISBASE: $HOME/install/grass84
- run: python3-coverage combine
- run: coverage combine
- name: Show python coverage report summary
run: python3-coverage report
- run: python3-coverage html
run: coverage report
- run: coverage html
- name: Make HTML test report available
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: testreport-${{ matrix.os }}-${{ matrix.config }}-${{ matrix.extra-include }}
name: testreport-${{ matrix.os }}-${{ matrix.config }}-${{ steps.get-exclude.outputs.extra-include-tag }}
path: testreport
retention-days: 3
- name: Make python-only code coverage test report available
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: python-codecoverage-report-${{ matrix.os }}-${{ matrix.config }}-${{ matrix.extra-include }}
name: python-codecoverage-report-${{ matrix.os }}-${{ matrix.config }}-${{ steps.get-exclude.outputs.extra-include-tag }}
path: coverage_html_report
retention-days: 3

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
verbose: true
gcov: true
flags: gunittest,gunittest-${{ matrix.config }},gunittest-${{ matrix.config }}-${{ matrix.extra-include }}
name: gunittest-${{ matrix.config }}-${{ matrix.extra-include }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# gcov: true
flags: gunittest,gunittest-${{ matrix.config }},gunittest-${{ matrix.config }}-${{ steps.get-exclude.outputs.extra-include-tag-trunc }}
name: gunittest-${{ matrix.config }}-${{ steps.get-exclude.outputs.extra-include-tag-trunc }}
token: ${{ secrets.CODECOV_TOKEN }}

build-and-test-success:
name: Build & Test Result
Expand Down
8 changes: 1 addition & 7 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ codecov:
# do not notify until at least 7 builds have been uploaded from the CI pipeline
# Change when more or less uploads are made, to not receive a GitHub
# comment notification too early after only pytest has uploaded coverage
after_n_builds: 5
after_n_builds: 7
coverage:
status:
project:
Expand All @@ -15,12 +15,6 @@ coverage:
informational: true

component_management:
# default_rules: # default rules that will be inherited by all components
# statuses:
# - type: project # in this case every component that doens't have a status defined will have a project type one
# target: auto
# branches:
# - "!main"
individual_components:
- component_id: modules_database # this is an identifier that should not be changed
name: db # this is a display name, and can be changed freely
Expand Down

0 comments on commit d13cf59

Please sign in to comment.