Update ci-main-test-coverage.yml #5
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 - Main | |
on: | |
push: | |
branches: [main] | |
paths: | |
- replaceme/** | |
- tests/** | |
- pytest.ini | |
- requirements-test.txt | |
- /*requirements.txt | |
- run-ci.sh | |
- .github/workflows/ci-main* | |
workflow_dispatch: | |
jobs: | |
cache-requirements-install: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Cache pip dependencies | |
uses: actions/cache@v4 | |
id: cache-dependencies | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
if: steps.cache-dependencies.outputs.cache-hit != 'true' | |
run: | | |
pip install -r requirements-test.txt | |
test: | |
needs: cache-requirements-install | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Restore pip cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
pip install -r requirements-test.txt | |
- name: Test | |
run: | | |
pytest && rm htmlcov/.gitignore | |
- name: Upload coverage artifacts | |
uses: actions/upload-artifact@v4 | |
if: ${{ success() }} | |
with: | |
name: coverage-output | |
path: htmlcov | |
retention-days: 1 | |
- name: Generate Allure Report | |
uses: simple-elf/allure-report-action@master | |
if: always() | |
with: | |
allure_results: allure-results | |
subfolder: test-results | |
allure_report: allure-report | |
allure_history: allure-history | |
keep_reports: 100 | |
- name: Generate badges | |
run: | | |
python generate_badges.py | |
- name: Upload tests artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-output | |
path: allure-history/test-results/ | |
retention-days: 1 | |
- name: Upload badges artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: badges-output | |
path: badges | |
retention-days: 1 | |
publish: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download coverage artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage-output | |
path: coverage | |
- name: Download test artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: test-output | |
path: allure-history | |
- name: Download badges artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: badges-output | |
path: badges | |
- name: Create reports directory | |
run: | | |
mkdir ./reports | |
mv allure-history ./reports/test-results | |
mv coverage ./reports/test-coverage | |
mv badges ./reports/badges | |
- name: Checkout gh-pages | |
uses: actions/checkout@v4 | |
if: always() | |
continue-on-error: true | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: Publish reports to gh-pages | |
if: always() | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_branch: gh-pages | |
publish_dir: ./reports | |