Ruff root files #4314
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
# Log in to jsonbin.org with tardis-bot GitHub account to get an API key and | |
# store it as a repository secret. | |
# Updated badge will be available at: | |
# https://img.shields.io/endpoint?url=https://jsonbin.org/tardis-bot/tardis/badges/docstr-cov | |
name: docstr-cov | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
env: | |
THRESHOLD: 0.05 | |
RANGE: 50..75 | |
ENDPOINT: https://jsonbin.org/tardis-bot/${{ github.event.repository.name }} | |
TOKEN: ${{ secrets.JSONBIN_APIKEY }} | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install interrogate | |
run: pip install interrogate==1.5.0 parse==1.19.0 setuptools | |
- 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=$(interrogate tardis -c pyproject.toml | python .ci-helpers/get_min_docstr_cov.py)" >> $GITHUB_ENV | |
- name: Test ${{ github.event.pull_request.head.sha }} coverage | |
run: | | |
echo "$BASE coverage was: $BASE_COV%" | |
git checkout $HEAD | |
interrogate tardis -c pyproject.toml --fail-under=$BASE_COV -v | |
- name: Blame | |
run: git diff --name-only $(git merge-base $BASE $HEAD) -- 'tardis/**/*.py' | xargs -i interrogate {} -c pyproject.toml --fail-under=100 -v | |
if: failure() | |
- name: Get new coverage | |
run: echo "NEW_COV=$(interrogate tardis -c pyproject.toml | python .ci-helpers/get_min_docstr_cov.py)" >> $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' | |
- name: Set public endpoint | |
run: | | |
curl -X PUT $ENDPOINT/_perms -H "authorization: token $TOKEN" | |
if: always() && github.event_name == 'push' | |
- name: Show badge URL | |
run: echo "https://img.shields.io/endpoint?url=$ENDPOINT/badges/docstr-cov" | |
if: always() && github.event_name == 'push' |