Release Note: v2.1.2 #18
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: CI - Code Testing Workflow | |
on: | |
pull_request: | |
branches: | |
- develop | |
- main | |
- "feature/*" | |
- "hotfix/*" | |
paths: | |
- "src/**" | |
- "tests/**" | |
permissions: | |
contents: write | |
pull-requests: write | |
checks: write | |
jobs: | |
test: | |
name: Run Tests and Post Coverage | |
runs-on: ubuntu-latest | |
env: # Load environment variables from repository secrets | |
BASE_URL: ${{ secrets.BASE_URL }} | |
API_KEY: ${{ secrets.API_KEY }} | |
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} | |
steps: | |
# Step 1: Checkout the repository code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Set up Python environment | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
# Step 3: Install dependencies | |
- name: Install dependencies | |
run: | | |
python -m venv venv # Create a virtual environment | |
source venv/bin/activate # Activate the virtual environment | |
pip install --upgrade pip # Upgrade pip | |
pip install pytest pytest-cov # Install coverage tools | |
pip install -r requirements.txt # Install project dependencies | |
# Step 4: Run tests with coverage | |
- name: Run tests with coverage | |
run: | | |
source venv/bin/activate | |
pytest --cov=src --cov-report=xml --cov-report=term > coverage.txt | |
pytest --junitxml=pytest.xml | |
# Step 5: Post coverage summary to the pull request | |
- name: Pytest coverage comment | |
uses: MishaKav/pytest-coverage-comment@main | |
with: | |
pytest-coverage-path: ./coverage.txt | |
junitxml-path: ./pytest.xml |