feat: add caching and performance improvements to CSV Generator Lite #367
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# Copyright 2022 Arcangelo Massari <arcangelo.massari@unibo.it> | |
# | |
# Permission to use, copy, modify, and/or distribute this software for any purpose | |
# with or without fee is hereby granted, provided that the above copyright notice | |
# and this permission notice appear in all copies. | |
# | |
# THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | |
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, | |
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | |
# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS | |
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
# SOFTWARE. | |
name: Run tests | |
on: | |
push: | |
branches: | |
- "**" # Tutti i branch, inclusi quelli con / | |
pull_request: | |
branches: [master] | |
jobs: | |
CheckCoverage: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.10", "3.11", "3.12", "3.13"] | |
services: | |
redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Setup Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Install dependencies | |
run: | | |
sudo apt install -y python-is-python3 libncurses5 | |
poetry install | |
- name: Start Virtuoso | |
run: | | |
cd virtuoso-opensource/bin | |
./virtuoso-t & | |
cd ../.. | |
python3 scripts/wait_for_virtuoso.py | |
if [ $? -ne 0 ]; then | |
echo "Errore: Virtuoso non si è avviato correttamente" | |
exit 1 | |
fi | |
- name: Run tests with coverage | |
run: | | |
poetry run coverage run --rcfile=test/coverage/.coveragerc | |
echo "=== Coverage Report ===" | |
poetry run coverage report | |
echo "COVERAGE=$(poetry run coverage report | grep TOTAL | awk '{print $4}')" >> $GITHUB_ENV | |
- name: Generate HTML coverage report | |
run: | | |
poetry run coverage html -d htmlcov | |
- name: Upload coverage report | |
if: github.ref == 'refs/heads/master' && matrix.python-version == '3.10' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: htmlcov/ | |
retention-days: 14 | |
- name: Generate coverage badge | |
if: github.ref == 'refs/heads/master' && matrix.python-version == '3.10' | |
uses: RubbaBoy/BYOB@v1.3.0 | |
with: | |
name: opencitations-oc_meta_coverage | |
label: "Coverage" | |
status: ${{ env.COVERAGE }} | |
color: green | |
github_token: ${{ secrets.GIST_PAT }} | |
repository: arcangelo7/badges | |
actor: arcangelo7 |