Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move interrogate action to seperate file #92

Merged
merged 8 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/pr-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: PR Status

# Controls when the workflow will run
on:
pull_request_target:
branches:
- main

jobs:
documentation-status:
runs-on: ubuntu-latest
strategy:
max-parallel: 20
matrix:
python-version: ['3.9']

steps:
- uses: actions/checkout@v3
with:
ref: main
- uses: actions/checkout@v3
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements_dev.txt
run: |
function retry-with-backoff() {
for BACKOFF in 0 1 2 4 8 16 32 64; do
sleep $BACKOFF
if "$@"; then
return 0
fi
done
return 1
}
python -m pip install --upgrade pip setuptools wheel
retry-with-backoff pip install -r requirements_dev.txt
- name: documentation
id: documentation
run: |
RESULT=$(git diff --name-only origin/main | grep .py$ | xargs interrogate -f 0 -v)
RESULT=$(tail -n +3 <<< $RESULT)
STATUS=$(tail -n1 <<< $RESULT)
STATUS=$(sed 's/-//g' <<< $STATUS)
# trim
STATUS=$(echo $STATUS | xargs echo -n)
RESULT=$(head -n -1 <<< $RESULT)
# remove second to last line
RESULTA=$(head -n -2 <<< $RESULT)
RESULTB=$(tail -n1 <<< $RESULT)
NL=$'\n'
RESULT="$RESULTA${NL}||||||${NL}$RESULTB"
RESULT="$RESULT${NL}${NL}$STATUS"
RESULT="${RESULT//'%'/'%25'}"
RESULT="${RESULT//$'\n'/'%0A'}"
RESULT="${RESULT//$'\r'/'%0D'}"
echo "::set-output name=result::$RESULT"
- name: comment documentation result on PR
uses: thollander/actions-comment-pull-request@v1
with:
message: |
## Docstring Coverage Report

${{ steps.documentation.outputs.result }}
comment_includes: '## Docstring Coverage Report'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 2 additions & 31 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
run: |
pytest --durations=0 --verbose

docs:
docstrings:
runs-on: ubuntu-latest
strategy:
max-parallel: 20
Expand Down Expand Up @@ -125,38 +125,9 @@ jobs:
}
python -m pip install --upgrade pip setuptools wheel
retry-with-backoff pip install -r requirements_dev.txt
- name: documentation
id: documentation
run: |
RESULT=$(git diff --name-only origin/main | grep .py$ | xargs interrogate -f 0 -v)
RESULT=$(tail -n +3 <<< $RESULT)
STATUS=$(tail -n1 <<< $RESULT)
STATUS=$(sed 's/-//g' <<< $STATUS)
# trim
STATUS=$(echo $STATUS | xargs echo -n)
RESULT=$(head -n -1 <<< $RESULT)
# remove second to last line
RESULTA=$(head -n -2 <<< $RESULT)
RESULTB=$(tail -n1 <<< $RESULT)
NL=$'\n'
RESULT="$RESULTA${NL}||||||${NL}$RESULTB"
RESULT="$RESULT${NL}${NL}$STATUS"
RESULT="${RESULT//'%'/'%25'}"
RESULT="${RESULT//$'\n'/'%0A'}"
RESULT="${RESULT//$'\r'/'%0D'}"
echo "::set-output name=result::$RESULT"
- name: comment documentation result on PR
uses: thollander/actions-comment-pull-request@v1
with:
message: |
## Docstring Coverage Report

${{ steps.documentation.outputs.result }}
comment_includes: '## Docstring Coverage Report'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: interrogate
run: |
interrogate -c pyproject.toml .
interrogate -v -c pyproject.toml .

wheel-tests:
runs-on: ubuntu-latest
Expand Down