diff --git a/.github/workflows/ci-cd-webhook.yml b/.github/workflows/ci-cd-webhook.yml index ddf40b0..92a8938 100644 --- a/.github/workflows/ci-cd-webhook.yml +++ b/.github/workflows/ci-cd-webhook.yml @@ -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 diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index ade6c97..d8db43e 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -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 }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7b4792d..859a79f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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 @@ -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"]