Update test.yml with WIP tag & remove dead code #11
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
# 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: | | |
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" | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: badges | |