Skip to content

Commit

Permalink
Panal 104 set up the slack notifications for the code coverage of py …
Browse files Browse the repository at this point in the history
…prediktor map client (#68)

* Send coverage info to Slack channel step in Python package pipeline
* Updated pre-commit config to use local docformatter hook due to issues in docformatter repo.

---------

Co-authored-by: MeenBna <[email protected]>
Co-authored-by: github-actions <[email protected]>
  • Loading branch information
3 people authored Oct 14, 2024
1 parent 2679228 commit 7af2356
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd-webhook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
python-version: 3.11

- name: Create virtual environment
run: python -m venv .venv
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,21 @@ jobs:
- name: Test with tox
run: |
tox
tox>>summary.txt
cat summary.txt
echo ${{ github.ref }}
- name: 'Log coverage to Slack'
if: ${{ github.ref == 'refs/heads/main' && matrix.python-version == '3.9' }}
run: |
summary_file=summary.txt
coverage_line=$(grep 'TOTAL' $summary_file)
line_coverage=$(echo $coverage_line | awk '{print $2}')
missing_line_coverage=$(echo $coverage_line | awk '{print $3}')
line_percentage=$(printf "%.2f%%" $( echo "($line_coverage - $missing_line_coverage) / $line_coverage * 100" | bc -l))
echo "Line coverage: $line_percentage"
branch_coverage=$(echo $coverage_line | awk '{print $4}')
pr_branch_coverage=$(echo $coverage_line | awk '{print $5}')
branch_percentage=$(printf "%.2f%%" $( echo "($branch_coverage - $pr_branch_coverage) / $branch_coverage * 100" | bc -l))
echo "Branch coverage: $branch_percentage"
curl -X POST -H 'Content-type: application/json' --data "{\"appName\":\"pyPredictorMapClient\", \"linePercentage\":\"$line_percentage\", \"branchPercentage\":\"$branch_percentage\", \"methodPercentage\":\"unavailable\"}" ${{ secrets.SLACK_COVERAGE_REPORTER_WORKFLOW_URL }}
20 changes: 12 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
default_language_version:
python: python3.12
python: python3.11

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -13,11 +13,15 @@ repos:
- id: debug-statements
- id: name-tests-test

- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
- repo: local
hooks:
- id: docformatter
name: docformatter
entry: docformatter
language: python
types: [python]
args: ["--in-place"]
additional_dependencies: [docformatter==1.7.5]

- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
Expand All @@ -26,25 +30,25 @@ repos:
args: ["--remove-all-unused-imports", "--in-place"]

- repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.10.0
hooks:
- id: black
args: ["--line-length", "79"]

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.1.1
hooks:
- id: flake8
args: ["--ignore=E501,W503"]

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.7.10
hooks:
- id: bandit
args: ["-x", "tests/*"]

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.9.0
rev: v5.10.1
hooks:
- id: isort
args: ["--profile", "black", "--line-length", "79"]

0 comments on commit 7af2356

Please sign in to comment.