Skip to content

Add git fetch and git checkout badges to workflow #13

Add git fetch and git checkout badges to workflow

Add git fetch and git checkout badges to workflow #13

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Testing[WIP]
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
jobs:
test:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:4.4
ports:
- 27017:27017
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
- name: Test with pytest
id: test
run: |
coverage run -m pytest
coverage report -m
echo "coverage_score=$(coverage report -m | awk 'END{print$4}')" >> "${GITHUB_OUTPUT}"
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> "${GITHUB_OUTPUT}"
id: extract_branch
- name: Prepare badge
id: prepare
run: |
git fetch
git checkout badges
echo "coverage_badge_path=${{steps.extract_branch.outputs.branch}}" >> "${GITHUB_OUTPUT}"
mkdir -p ${{steps.extract_branch.outputs.branch}}
- name: Add coverage badge
uses: emibcn/badge-action@v2.0.2
with:
label: 'Test coverage'
status: ${{ steps.test.outputs.coverage_score }}
color: 'blue'
path: ${{ steps.prepare.outputs.coverage_badge_path }}/coverage.svg
- name: Commit badge
id: commit
run: |
ls ${{ steps.prepare.outputs.coverage_badge_path }}/coverage.svg
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add ${{ steps.prepare.outputs.coverage_badge_path }}
git commit -m "Add coverage badge"
git push