feat: add window method to Trajectory class #51
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docstring Coverage | |
on: | |
push: | |
branches: [dev, main] | |
pull_request: | |
branches: ['*'] | |
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 | |
- 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 PQAnalysis -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=$BASE_COV | |
- 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' |