update for action UI #30
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: Unit Test | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
branches: | |
- master | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./Project_phase_2/ | |
strategy: | |
matrix: | |
python-version: [3.10] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.10.13 | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r test_requirements.txt | |
pip install werkzeug==2.3.0 | |
pip install coverage | |
pip install coverage-badge | |
- name: Test with coverage | |
run: | | |
cd tests/Unit_Test_Cases | |
coverage run -m pytest Unit_Test.py | |
coverage xml -o coverage.xml | |
rm -f coverage.svg | |
coverage-badge -o coverage.svg | |
- name: Commit Coverage Badge | |
run: | | |
git config --global user.name 'Waariss' | |
git config --global user.email '[email protected]' | |
# Stash any local changes | |
git stash --include-untracked | |
# Pull latest changes from the remote repository | |
git pull origin master --rebase | |
# Apply the stashed changes | |
git stash pop | |
# Add all changes to staging | |
git add -A | |
# Commit and push only if there are changes | |
git diff --staged --quiet || git commit -m "Update coverage badge" | |
git push | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v2 | |
with: | |
file: ./Project_phase_2/tests/Unit_Test_Cases/coverage.xml | |
fail_ci_if_error: true |