From a6bcb3ffaef92bb7d00e39e272ed0f6a53c76648 Mon Sep 17 00:00:00 2001 From: 97gamjak <97gamjak@gmail.com> Date: Thu, 25 Apr 2024 07:55:49 +0200 Subject: [PATCH 1/6] added docstr.yaml file to workflows --- .docstr.yaml | 27 ++++++++++ .github/workflows/docstr.yml | 101 +++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 .docstr.yaml create mode 100644 .github/workflows/docstr.yml diff --git a/.docstr.yaml b/.docstr.yaml new file mode 100644 index 00000000..7f0c99c5 --- /dev/null +++ b/.docstr.yaml @@ -0,0 +1,27 @@ +paths: + - PQAnalysis + #badge: docs + #exclude: .*/test # regex + verbose: 2 # int (0-3) + skip_magic: True + skip_file_doc: True + skip_init: True + skip_class_def: False + skip_private: True + follow_links: True + #ignore_names_file: .*/test # regex + #fail_under: 90 + percentage_only: False + #ignore_patterns: # Dict with key/value pairs of file-pattern/node-pattern + # .*: method_to_ignore_in_all_files + # FileWhereWeWantToIgnoreAllSpecialMethods: "__.+__" + # SomeFile: + # - method_to_ignore1 + # - method_to_ignore2 + # - method_to_ignore3 + # a_very_important_view_file: + # - "^get$" + # - "^set$" + # - "^post$" + # detect_.*: + # - "get_val.*" \ No newline at end of file diff --git a/.github/workflows/docstr.yml b/.github/workflows/docstr.yml new file mode 100644 index 00000000..3e986245 --- /dev/null +++ b/.github/workflows/docstr.yml @@ -0,0 +1,101 @@ +name: CI + +on: + push: + branches: [dev, main] + pull_request: + branches: [dev, main] + workflow_dispatch: + +env: + RANGE: 95..100 + ENDPOINT: https://jsonbin.org/${{ github.repository_owner }}/${{ github.event.repository.name }} + TOKEN: ${{ secrets.JSONBIN_APIKEY }} + BRANCH_NAME: ${{ github.head_ref || github.ref_name}} + + +jobs: + check: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Install docstr-coverage + run: pip install docstr-coverage==2.2.0 + + - name: Get SHAs + run: | + if [[ ${{ github.event_name }} == 'push' ]]; then + echo "BASE=$(git rev-parse HEAD^)" >> $GITHUB_ENV + echo "HEAD=$(git rev-parse HEAD)" >> $GITHUB_ENV + + elif [[ ${{ github.event_name }} == 'pull_request' ]]; then + echo "BASE=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV + echo "HEAD=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV + + else + echo "Unexpected event trigger" + exit 1 + + fi + + - name: Get ${{ github.event.pull_request.base.sha }} coverage + run: | + git checkout $BASE + echo "BASE_COV=$(docstr-coverage -p)" >> $GITHUB_ENV + + - name: Test ${{ github.event.pull_request.head.sha }} coverage + run: | + echo "$BASE coverage was: $BASE_COV%" + git checkout $HEAD + docstr-coverage --fail-under=$(echo {${{ env.RANGE }}} | awk '{print $1;}') + + - name: Blame + run: | + git diff --name-only $(git merge-base $BASE $HEAD) | \ + xargs docstr-coverage --accept-empty + if: failure() + + - name: Get new coverage + run: echo "NEW_COV=$(printf "%.f" $(docstr-coverage -p))" >> $GITHUB_ENV + if: always() && github.event_name == 'push' + + - name: Set label color + run: | + if [[ $NEW_COV -ge $(echo {${{ env.RANGE }}} | awk '{print $NF;}') ]]; then + echo "COLOR=green" >> $GITHUB_ENV + + elif [[ $NEW_COV -lt $(echo {${{ env.RANGE }}} | awk '{print $1;}') ]]; then + echo "COLOR=red" >> $GITHUB_ENV + + else + echo "COLOR=orange" >> $GITHUB_ENV + + fi + if: always() && github.event_name == 'push' + + - name: Post results + run: | + echo "New coverage is: $NEW_COV%" + curl -X POST $ENDPOINT/badges/docstr-cov \ + -H "authorization: token $TOKEN" \ + -d "{ \"schemaVersion\": 1, \"label\": \"docstr-cov\", \ + \"message\": \"$NEW_COV%\", \"color\": \"$COLOR\" }" + if: always() && github.event_name == 'push' && ${{ env.BRANCH_NAME }} == 'main' + + - name: Set public endpoint + run: | + curl -X PUT $ENDPOINT/_perms -H "authorization: token $TOKEN" + if: always() && github.event_name == 'push' && ${{ env.BRANCH_NAME }} == 'main' + + - name: Show badge URL + run: echo "https://img.shields.io/endpoint?url=$ENDPOINT/badges/docstr-cov" + if: always() && github.event_name == 'push' && ${{ env.BRANCH_NAME }} == 'main' \ No newline at end of file From 91121f8fe86c5b29e587502cc64a59db788d6a0c Mon Sep 17 00:00:00 2001 From: 97gamjak <97gamjak@gmail.com> Date: Thu, 25 Apr 2024 07:59:05 +0200 Subject: [PATCH 2/6] added pkg_resources as dependency --- .github/workflows/docstr.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docstr.yml b/.github/workflows/docstr.yml index 3e986245..59446ea5 100644 --- a/.github/workflows/docstr.yml +++ b/.github/workflows/docstr.yml @@ -29,7 +29,10 @@ jobs: python-version: 3.x - name: Install docstr-coverage - run: pip install docstr-coverage==2.2.0 + run: | + pip install docstr-coverage==2.2.0 + pip install pkg_resources + - name: Get SHAs run: | From 4ea9e081283ef48fb91ee2a98d7456405aced0a5 Mon Sep 17 00:00:00 2001 From: 97gamjak <97gamjak@gmail.com> Date: Thu, 25 Apr 2024 08:02:51 +0200 Subject: [PATCH 3/6] upgrading docstr-coverage version in ci --- .github/workflows/docstr.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/docstr.yml b/.github/workflows/docstr.yml index 59446ea5..19545f6b 100644 --- a/.github/workflows/docstr.yml +++ b/.github/workflows/docstr.yml @@ -30,9 +30,7 @@ jobs: - name: Install docstr-coverage run: | - pip install docstr-coverage==2.2.0 - pip install pkg_resources - + pip install docstr-coverage - name: Get SHAs run: | From d68230c6f4be11ff751fa42ee38abb2aa94f35ec Mon Sep 17 00:00:00 2001 From: 97gamjak <97gamjak@gmail.com> Date: Thu, 25 Apr 2024 08:10:35 +0200 Subject: [PATCH 4/6] update .docstr.yaml --- .docstr.yaml | 50 ++++++++++++++++++------------------ .github/workflows/docstr.yml | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.docstr.yaml b/.docstr.yaml index 7f0c99c5..b572cfbe 100644 --- a/.docstr.yaml +++ b/.docstr.yaml @@ -1,27 +1,27 @@ paths: - PQAnalysis - #badge: docs - #exclude: .*/test # regex - verbose: 2 # int (0-3) - skip_magic: True - skip_file_doc: True - skip_init: True - skip_class_def: False - skip_private: True - follow_links: True - #ignore_names_file: .*/test # regex - #fail_under: 90 - percentage_only: False - #ignore_patterns: # Dict with key/value pairs of file-pattern/node-pattern - # .*: method_to_ignore_in_all_files - # FileWhereWeWantToIgnoreAllSpecialMethods: "__.+__" - # SomeFile: - # - method_to_ignore1 - # - method_to_ignore2 - # - method_to_ignore3 - # a_very_important_view_file: - # - "^get$" - # - "^set$" - # - "^post$" - # detect_.*: - # - "get_val.*" \ No newline at end of file +#badge: docs +#exclude: .*/test # regex +verbose: 2 # int (0-3) +skip_magic: True +skip_file_doc: True +skip_init: True +skip_class_def: False +skip_private: True +follow_links: True +#ignore_names_file: .*/test # regex +#fail_under: 90 +percentage_only: False +#ignore_patterns: # Dict with key/value pairs of file-pattern/node-pattern +# .*: method_to_ignore_in_all_files +# FileWhereWeWantToIgnoreAllSpecialMethods: "__.+__" +# SomeFile: +# - method_to_ignore1 +# - method_to_ignore2 +# - method_to_ignore3 +# a_very_important_view_file: +# - "^get$" +# - "^set$" +# - "^post$" +# detect_.*: +# - "get_val.*" \ No newline at end of file diff --git a/.github/workflows/docstr.yml b/.github/workflows/docstr.yml index 19545f6b..6436f8c7 100644 --- a/.github/workflows/docstr.yml +++ b/.github/workflows/docstr.yml @@ -57,7 +57,7 @@ jobs: run: | echo "$BASE coverage was: $BASE_COV%" git checkout $HEAD - docstr-coverage --fail-under=$(echo {${{ env.RANGE }}} | awk '{print $1;}') + docstr-coverage --fail-under=$BASE_COV - name: Blame run: | From 6bbe79aad8d46a5b8dfafcd812fd15ecb6ef25de Mon Sep 17 00:00:00 2001 From: 97gamjak <97gamjak@gmail.com> Date: Thu, 25 Apr 2024 08:16:49 +0200 Subject: [PATCH 5/6] update .docstr.yaml --- .github/workflows/docstr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docstr.yml b/.github/workflows/docstr.yml index 6436f8c7..b50e3ec8 100644 --- a/.github/workflows/docstr.yml +++ b/.github/workflows/docstr.yml @@ -51,6 +51,7 @@ jobs: - name: Get ${{ github.event.pull_request.base.sha }} coverage run: | git checkout $BASE + docstr-coverage echo "BASE_COV=$(docstr-coverage -p)" >> $GITHUB_ENV - name: Test ${{ github.event.pull_request.head.sha }} coverage From 68ef8129014a3630038dbb2ddbf13c90c24ea253 Mon Sep 17 00:00:00 2001 From: 97gamjak <97gamjak@gmail.com> Date: Thu, 25 Apr 2024 08:19:58 +0200 Subject: [PATCH 6/6] updated worklfow docstr.yaml --- .github/workflows/docstr.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/docstr.yml b/.github/workflows/docstr.yml index b50e3ec8..ef0c1ace 100644 --- a/.github/workflows/docstr.yml +++ b/.github/workflows/docstr.yml @@ -51,8 +51,7 @@ jobs: - name: Get ${{ github.event.pull_request.base.sha }} coverage run: | git checkout $BASE - docstr-coverage - echo "BASE_COV=$(docstr-coverage -p)" >> $GITHUB_ENV + echo "BASE_COV=$(docstr-coverage PQAnalysis -p)" >> $GITHUB_ENV - name: Test ${{ github.event.pull_request.head.sha }} coverage run: |