Skip to content

Minor fixes (#108)

Minor fixes (#108) #2

Workflow file for this run

name: CI
on:
pull_request:
branches: [ "main" ]
push:
branches: [ "main" ]
jobs:
coverage:
runs-on: ubuntu-latest
name: Check coverage
permissions:
# Gives the action the necessary permissions for publishing new
# comments in pull requests.
pull-requests: write
# Gives the action the necessary permissions for pushing data to the
# python-coverage-comment-action branch, and for editing existing
# comments (to avoid publishing multiple comments in the same PR)
contents: write
env: # Define environment variables for the entire job
HUGGINGFACE_TOKEN: ${{ secrets.HUGGINGFACE_TOKEN }} # Inject HuggingFace token to pull gated models
steps:
- uses: actions/checkout@v3
- name: Install system dependencies
shell: bash
run: |
if [ "$(uname)" = "Linux" ]; then
sudo apt-get update
sudo apt-get install -y portaudio19-dev
elif [ "$(uname)" = "Darwin" ]; then
brew install portaudio
else
echo "No system dependencies required for Windows"
fi
- name: Create .coveragerc dynamically
run: |
echo "[run]" > .coveragerc
echo "relative_files = true" >> .coveragerc
echo "source = verbatim" >> .coveragerc
echo "branch = true" >> .coveragerc
echo "omit = " >> .coveragerc
echo " tests/*" >> .coveragerc
echo "[report]" >> .coveragerc
echo "show_missing = true" >> .coveragerc
echo "exclude_lines = " >> .coveragerc
echo " if __name__ == .__main__.:" >> .coveragerc
echo " if debug" >> .coveragerc
echo "[html]" >> .coveragerc
echo "directory = coverage_html_report" >> .coveragerc
echo "title = Code Coverage Report" >> .coveragerc
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then
pip install -r requirements.txt
pip install coverage pytest
else
echo "No requirements.txt found, skipping dependencies installation"
fi
- name: Launch tests & generate report
run: coverage run -m pytest
- name: Generate coverage report
run: |
coverage xml -o coverage.xml
coverage report
- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
COVERAGE_PATH: .
- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v3
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
# If you use a different name, update COMMENT_ARTIFACT_NAME accordingly
name: python-coverage-comment-action
# If you use a different name, update COMMENT_FILENAME accordingly
path: python-coverage-comment-action.txt