Bump poetry version #102
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: Dynamic Badges | |
on: | |
push: | |
branches: [main] | |
jobs: | |
coverage-badge: | |
name: Update Coverage and Tests Passing Badge | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check-out repository | |
uses: actions/checkout@v3 | |
- name: Setup python | |
id: setup-python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Load cached Poetry installation | |
id: cached-poetry | |
uses: actions/cache@v3 | |
with: | |
path: ~/.local | |
key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }} | |
- name: Install Poetry | |
if: steps.cached-poetry.outputs.cache-hit != 'true' | |
uses: snok/install-poetry@v1 | |
- name: Configure Poetry | |
run: poetry config virtualenvs.in-project true | |
- name: Load cached venv | |
id: cached-poetry-dependencies-2 | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies-2.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root --with dev | |
- name: Install project | |
run: poetry install --no-interaction --with dev | |
- name: Run Coverage | |
run: | | |
poetry run pytest --cov src/* | |
echo "COVERAGE=$(poetry run coverage report --format markdown --precision 1 | awk -F'|' 'END{gsub(/ *(\*\*|%)* */, "", $(NF-1)); print $(NF-1)}')" >> $GITHUB_ENV | |
- name: Create Coverage Badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 1ab4eefed81ec381e29f7d4feb9856bc | |
filename: coverage.json | |
label: test coverage | |
message: ${{ env.COVERAGE }}% | |
valColorRange: ${{ env.COVERAGE }} | |
minColorRange: 0 | |
maxColorRange: 100 | |
- name: Run Tests | |
run: | | |
echo "COLLECTED=$(poetry run pytest --collect-only | grep -m 1 "collected" | awk '{print $2;}' | tr -d '[:space:]\n')" >> $GITHUB_ENV | |
echo "PASSED=$(poetry run pytest --verbose | grep -o "PASSED" | wc -l | tr -d '[:space:]\n')" >> $GITHUB_ENV | |
- name: Create Tests Passing Badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 1ab4eefed81ec381e29f7d4feb9856bc | |
filename: tests.json | |
label: tests passing | |
message: ${{ env.PASSED }} / ${{ env.COLLECTED }} | |
valColorRange: ${{ env.PASSED }} | |
minColorRange: 0 | |
maxColorRange: ${{ env.COLLECTED }} | |
update-badges: | |
name: Update CLOC Badges | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Download cloc | |
run: sudo apt-get update -y && sudo apt-get install -y cloc | |
- name: Get the Numbers | |
run: | | |
echo "CODE_LINES=$(.github/cloc.sh --loc)" >> $GITHUB_ENV | |
echo "COMMENT_PERCENTAGE=$(.github/cloc.sh --percentage)" >> $GITHUB_ENV | |
- name: Create Lines-of-Code Badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 1ab4eefed81ec381e29f7d4feb9856bc | |
filename: loc.json | |
label: lines of code | |
message: ${{ env.CODE_LINES }} | |
color: blue | |
- name: Create Comments Badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 1ab4eefed81ec381e29f7d4feb9856bc | |
filename: comments.json | |
label: comment percentage | |
message: ${{ env.COMMENT_PERCENTAGE }}% | |
valColorRange: ${{ env.COMMENT_PERCENTAGE }} | |
maxColorRange: 40 | |
minColorRange: 0 |