Skip to content

add test method to pipeline #60

add test method to pipeline

add test method to pipeline #60

Workflow file for this run

name: Test GlassFlow Python SDK
on:
pull_request:
branches:
- main
- release/*
permissions:
contents: write
checks: write
pull-requests: write
jobs:
tests:
name: Run pytest tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python environment
uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: 'pip'
cache-dependency-path: setup.py
- name: Install dependencies
run: pip install -e .[dev]
- name: Run Tests
run: pytest
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.INTEGRATION_PERSONAL_ACCESS_TOKEN }}
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverageReport
path: tests/reports/
checks:
name: Run code checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python environment
uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: 'pip'
cache-dependency-path: setup.py
- name: Install dependencies
run: pip install -e .[dev]
- name: Run ruff linter checks
run: ruff check .
- name: Run ruff formatting checks
run: ruff format --check .
coverage:
runs-on: ubuntu-latest
needs: [tests]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: coverageReport
- name: Pytest coverage comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-xml-coverage-path: ./coverage.xml
junitxml-path: ./pytest.xml
- name: Update Readme with Coverage Html
if: ${{ github.ref == 'refs/heads/main' }}
run: |
sed -i '/<!-- Pytest Coverage Comment:Begin -->/,/<!-- Pytest Coverage Comment:End -->/c\<!-- Pytest Coverage Comment:Begin -->\n\${{ steps.coverageComment.outputs.coverageHtml }}\n<!-- Pytest Coverage Comment:End -->' ./README.md
- name: Commit & Push changes to Readme
id: commit
if: ${{ github.ref == 'refs/heads/main' }}
run: |
git config --global user.name 'GitHub Actions Workflow glassflow-python-sdk/.github/workflows/on_pr.yaml'
git config --global user.email 'glassflow-actions-workflow@users.noreply.github.com'
git add README.md
git commit -m "Update coverage on Readme"
git push origin master