allure reports for all CI matrix #82
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
# | |
name: CI | |
on: | |
push: | |
branches: [ master, main ] | |
pull_request: | |
branches: [ master, main ] | |
permissions: | |
contents: write | |
jobs: | |
build: | |
strategy: | |
matrix: | |
python-version: [3.9, "3.10", 3.11, 3.12] | |
platform: [ubuntu-latest, macos-latest, windows-latest] | |
env: | |
PRIMARY_PYTHON_VERSION: '3.12' | |
PRIMARY_PLATFORM: 'ubuntu-latest' | |
PYTEST_CMD: >- | |
python -m pytest | |
--junitxml=pytest.xml | |
--cov-report=term-missing:skip-covered | |
--cov=src | |
tests/ | |
runs-on: ${{ matrix.platform }} | |
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 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Load Allure test report history | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install uv environment | |
uses: andgineer/uv-venv@v1 | |
- name: Install dependencies | |
run: uv pip install -r requirements.dev.txt | |
- name: Test with pytest | |
if: ${{ matrix.python-version != env.PRIMARY_PYTHON_VERSION || matrix.platform != env.PRIMARY_PLATFORM }} | |
run: ${{ env.PYTEST_CMD }} | |
- name: Test with pytest and Allure report | |
if: ${{ matrix.python-version == env.PRIMARY_PYTHON_VERSION && matrix.platform == env.PRIMARY_PLATFORM }} | |
run: "${{ env.PYTEST_CMD }} --alluredir=./allure-results" | |
- name: Generate Allure test report | |
uses: andgineer/allure-report@v1.4 | |
id: allure-report | |
if: always() | |
with: | |
website-source: gh-pages | |
allure-results: allure-results | |
reports-site: reports-site | |
reports-site-path: builds/tests/${{ matrix.platform }}_${{ matrix.python-version }} | |
- name: Publish Allure test report | |
uses: peaceiris/actions-gh-pages@v3 | |
if: ${{ needs.allure-report.result == 'success' }} | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_branch: gh-pages | |
publish_dir: reports-site | |
destination_dir: builds/tests/${{ matrix.platform }}_${{ matrix.python-version }} | |
- name: Post the link to the Allure test report | |
if: ${{ needs.allure-report.result == 'success' }} | |
run: | | |
echo "ls gh-pages/allure" | |
ls gh-pages/allure | |
echo "[Allure test report ${{ matrix.platform }}/${{ matrix.python-version }}](${{ steps.allure-report.outputs.REPORT_URL }})" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
- name: Coverage comment | |
id: coverage_comment | |
if: ${{ matrix.python-version == env.PRIMARY_PYTHON_VERSION && matrix.platform == env.PRIMARY_PLATFORM }} | |
uses: py-cov-action/python-coverage-comment-action@v3 | |
with: | |
GITHUB_TOKEN: ${{ github.token }} | |
MINIMUM_GREEN: 85 | |
MINIMUM_ORANGE: 70 | |
- name: Store Pull Request comment to be posted | |
uses: actions/upload-artifact@v3 | |
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' | |
with: | |
name: python-coverage-comment-action | |
path: python-coverage-comment-action.txt | |
- name: Upload coverage data to coveralls.io | |
if: ${{ matrix.python-version == env.PRIMARY_PYTHON_VERSION && matrix.platform == env.PRIMARY_PLATFORM }} | |
uses: coverallsapp/github-action@v2 | |