Feature/adjust login with cpf instead email #5
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
name: Test, format, and check coverage | |
on: | |
pull_request: | |
branches: [main] | |
jobs: | |
test-format-and-check-coverage: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Run tests and calculate coverage | |
run: | | |
coverage run --source='.' --omit='*/migrations/*,*/tests/*' manage.py test | |
COVERAGE_PERCENTAGE=$(coverage report --fail-under=90 | grep TOTAL | awk '{print $4}') | |
echo "Coverage: $COVERAGE_PERCENTAGE" | |
if [ $(echo "$COVERAGE_PERCENTAGE > 90" | bc -l) -eq 1 ]; then | |
echo "Coverage is above 90%, continuing with formatting." | |
black --check . | |
isort --check-only . | |
NEEDS_FORMATTING=$? | |
if [ $NEEDS_FORMATTING -eq 0 ]; then | |
echo "No formatting needed, continuing with commit." | |
else | |
echo "Formatting needed, formatting code." | |
black . | |
isort . | |
git add . | |
git commit -m "Format code with Black and isort" | |
fi | |
else | |
echo "Coverage is below 90%, blocking commit." | |
exit 1 | |
fi |