Update test.yml #61
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 | |
on: | |
workflow_dispatch: | |
# uncomment to make it runnable after each push into master | |
push: | |
branches: [ master ] | |
#pull_request: | |
# branches: [ master ] | |
jobs: | |
pytest: | |
name: pytest | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.12] | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v2 | |
- name: Install PyTest | |
run: | | |
sudo pip install -U "pytest>=7.2.0" "pytest-cov>=4.0.0" | |
- name: Install Dependencies | |
run: | | |
sudo pip install -U -r utils/requirements.txt | |
sudo pip install pydantic | |
sudo pip install openai | |
sudo pip install pgmpy | |
sudo pip install ipython | |
- name: Testing | |
run: | | |
pytest --cov=code --cov-report=xml --cov-report=html --cov-report=term-missing tests/ # Generate HTML report | |
- name: Upload Coverage Report as Artifact | |
uses: actions/upload-artifact@v4 # Updated to v4 | |
with: | |
name: coverage-report | |
path: htmlcov/ # Path to the HTML coverage report directory | |
- name: Generate coverage badge | |
run: | | |
python utils/badge_generator.py | |
- name: List HTML Coverage Directory | |
run: | | |
ls -la htmlcov/ | |
- name: Commit and push coverage report | |
run: | | |
# Configure git | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
# Create gh-pages branch if it doesn't exist or switch to it | |
git checkout -b gh-pages || git checkout gh-pages | |
rm -rf coverage | |
# Create a new directory for coverage reports | |
mkdir coverage | |
# Copy all files from htmlcov to the coverage directory | |
cp -r htmlcov/* coverage/ # Copy all HTML files from htmlcov to the new coverage directory | |
cp coverage-badge.svg coverage/ # Copy the generated badge into the coverage directory | |
# Add all changes | |
git add * -f # Add all files in the current directory | |
# Commit changes | |
git commit -m "Update coverage report" || echo "No changes to commit." | |
# Push changes to gh-pages branch | |
git push origin gh-pages # --force # Force push in case of history divergence |