From e141a8e1279d1a75c0f4b023b0a590e0f88e3f77 Mon Sep 17 00:00:00 2001 From: Monika Dargiewicz Date: Sat, 12 Oct 2024 08:42:25 +0200 Subject: [PATCH 01/12] Added Log coverage to Slack step --- .github/workflows/tox.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index ade6c97..1809983 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -77,4 +77,19 @@ jobs: - name: Test with tox run: | - tox + tox>>summary.txt + cat summary.txt + + - name: 'Log coverage to Slack' + 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\":\"$line_percentage\"}" From 0e6f84a35631ec8681c0e146d878bf6a116f416f Mon Sep 17 00:00:00 2001 From: Monika Dargiewicz Date: Mon, 14 Oct 2024 12:35:32 +0200 Subject: [PATCH 02/12] Add slack coverage reporter url --- .github/workflows/tox.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 1809983..cb9138d 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -92,4 +92,4 @@ jobs: 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\":\"$line_percentage\"}" + curl -X POST -H 'Content-type: application/json' --data "{\"appName\":\"pyPredictorMapClient\", \"linePercentage\":\"$line_percentage\", \"branchPercentage\":\"$branch_percentage\", \"methodPercentage\":\"unavailable\"}" ${{ process.env.SLACK_COVERAGE_REPORTER_WORKFLOW_URL }} From 91d08e47c7f0d8a4517a22869a9f2294bba92bde Mon Sep 17 00:00:00 2001 From: Monika Dargiewicz Date: Mon, 14 Oct 2024 13:18:46 +0200 Subject: [PATCH 03/12] Minor fix - env variable --- .github/workflows/tox.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index cb9138d..2eac574 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -92,4 +92,4 @@ jobs: 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\"}" ${{ process.env.SLACK_COVERAGE_REPORTER_WORKFLOW_URL }} + curl -X POST -H 'Content-type: application/json' --data "{\"appName\":\"pyPredictorMapClient\", \"linePercentage\":\"$line_percentage\", \"branchPercentage\":\"$branch_percentage\", \"methodPercentage\":\"unavailable\"}" ${{ env.SLACK_COVERAGE_REPORTER_WORKFLOW_URL }} From 5377a371347d77aa9a574cc05d3f3baadb5441b2 Mon Sep 17 00:00:00 2001 From: Monika Dargiewicz Date: Mon, 14 Oct 2024 13:43:01 +0200 Subject: [PATCH 04/12] convert variable to secret --- .github/workflows/tox.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 2eac574..716aa25 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -92,4 +92,4 @@ jobs: 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\"}" ${{ env.SLACK_COVERAGE_REPORTER_WORKFLOW_URL }} + 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 }} From 406d087472479745fdefcb7827ead04f7a37742e Mon Sep 17 00:00:00 2001 From: Monika Dargiewicz Date: Mon, 14 Oct 2024 14:02:49 +0200 Subject: [PATCH 05/12] add condition - logging to slack only when merge pull request --- .github/workflows/tox.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 716aa25..d335a41 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -81,6 +81,7 @@ jobs: cat summary.txt - 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) From 5887e736f15e3e0ada040d587a635707f620d6c9 Mon Sep 17 00:00:00 2001 From: Monika Dargiewicz Date: Mon, 14 Oct 2024 14:22:27 +0200 Subject: [PATCH 06/12] fix if condition --- .github/workflows/tox.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index d335a41..d8db43e 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -79,9 +79,10 @@ jobs: run: | 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' + if: ${{ github.ref == 'refs/heads/main' && matrix.python-version == '3.9' }} run: | summary_file=summary.txt coverage_line=$(grep 'TOTAL' $summary_file) From 3288c46682d780605d8417a5309e0a4d2d553fe8 Mon Sep 17 00:00:00 2001 From: MeenBna Date: Mon, 14 Oct 2024 14:31:44 +0200 Subject: [PATCH 07/12] Fixed CI pipeline by updating pre-commit hooks. --- .github/workflows/ci-cd-webhook.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci-cd-webhook.yml b/.github/workflows/ci-cd-webhook.yml index ddf40b0..93267a0 100644 --- a/.github/workflows/ci-cd-webhook.yml +++ b/.github/workflows/ci-cd-webhook.yml @@ -24,6 +24,16 @@ jobs: - name: Install dependencies run: pip install -r requirements.txt + - name: Update pre-commit hooks + run: | + source .venv/bin/activate + pre-commit autoupdate + git config --global user.name 'github-actions' + git config --global user.email 'github-actions@github.com' + git add .pre-commit-config.yaml + git commit -m "Update pre-commit hooks" || echo "No changes to commit" + git push origin HEAD || echo "No changes to push" + - name: Run pre-commit checks run: pre-commit run --all-files From be6e96a3ece5bd31ff815249a959adfa638a91aa Mon Sep 17 00:00:00 2001 From: MeenBna Date: Mon, 14 Oct 2024 14:37:15 +0200 Subject: [PATCH 08/12] Fixed docformatter hook language to python in pre-commit config. --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7b4792d..a2596ae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,6 +18,7 @@ repos: hooks: - id: docformatter args: ["--in-place"] + language: python - repo: https://github.com/PyCQA/autoflake rev: v2.3.1 From 954c8ebd1fbe75f054ae02d6f77be0ebb309552e Mon Sep 17 00:00:00 2001 From: Monika Dargiewicz Date: Mon, 14 Oct 2024 15:04:46 +0200 Subject: [PATCH 09/12] comment docformatter --- .pre-commit-config.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a2596ae..187f5c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,12 +13,13 @@ repos: - id: debug-statements - id: name-tests-test -- repo: https://github.com/PyCQA/docformatter - rev: v1.7.5 - hooks: - - id: docformatter - args: ["--in-place"] - language: python +# Uncomment when fixed https://github.com/PyCQA/docformatter/pull/287 +# - repo: https://github.com/PyCQA/docformatter +# rev: v1.7.5 +# hooks: +# - id: docformatter +# args: ["--in-place"] +# language: python - repo: https://github.com/PyCQA/autoflake rev: v2.3.1 From 25ceb23658caed74173d27b7d9c75dd440550053 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 14 Oct 2024 13:05:48 +0000 Subject: [PATCH 10/12] Update pre-commit hooks --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 187f5c8..9db6a26 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_language_version: 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 @@ -28,25 +28,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"] From 135678a8962122a31560b36330952844cf1c8935 Mon Sep 17 00:00:00 2001 From: Monika Dargiewicz Date: Mon, 14 Oct 2024 15:27:31 +0200 Subject: [PATCH 11/12] uncomment docformatter --- .pre-commit-config.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9db6a26..3255470 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,13 +13,12 @@ repos: - id: debug-statements - id: name-tests-test -# Uncomment when fixed https://github.com/PyCQA/docformatter/pull/287 -# - repo: https://github.com/PyCQA/docformatter -# rev: v1.7.5 -# hooks: -# - id: docformatter -# args: ["--in-place"] -# language: python +- repo: https://github.com/PyCQA/docformatter + rev: v1.7.5 + hooks: + - id: docformatter + args: ["--in-place"] + language: python - repo: https://github.com/PyCQA/autoflake rev: v2.3.1 From 9e3750ce000e85811ced3846581dd764cedcc907 Mon Sep 17 00:00:00 2001 From: MeenBna Date: Mon, 14 Oct 2024 15:40:59 +0200 Subject: [PATCH 12/12] Updated pre-commit config to use local docformatter hook due to issues in docformatter repo. --- .github/workflows/ci-cd-webhook.yml | 12 +----------- .pre-commit-config.yaml | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci-cd-webhook.yml b/.github/workflows/ci-cd-webhook.yml index 93267a0..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 @@ -24,16 +24,6 @@ jobs: - name: Install dependencies run: pip install -r requirements.txt - - name: Update pre-commit hooks - run: | - source .venv/bin/activate - pre-commit autoupdate - git config --global user.name 'github-actions' - git config --global user.email 'github-actions@github.com' - git add .pre-commit-config.yaml - git commit -m "Update pre-commit hooks" || echo "No changes to commit" - git push origin HEAD || echo "No changes to push" - - name: Run pre-commit checks run: pre-commit run --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a2596ae..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,12 +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 - args: ["--in-place"] + 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 @@ -27,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"]