feat(ci): aggiungi varianti -github dei reusable e fix audit Python

- crea gemelli X-github.yml per ogni reusable con action da github.com (fallback mirror gitea.com)
- python-dependency-check/outdated: audit in venv isolata (fix falsi positivi da runner ML)
- python-dependency-check/outdated: deduplica issue (commento invece di nuova issue)
- examples: aggiungi ci-github.yml e release-github.yml in tutte le cartelle

Fixes #3 @3h
This commit is contained in:
LucaZanni
2026-07-06 19:53:01 +02:00
parent e5411d9d2d
commit f0896d775d
24 changed files with 1410 additions and 28 deletions
+33 -14
View File
@@ -38,25 +38,28 @@ jobs:
${{ runner.os }}-pip-${{ inputs.python-version }}-
${{ runner.os }}-pip-
- name: Install dependencies
- name: Install dependencies (isolated venv)
run: |
python -m pip install --upgrade pip
# venv pulita: elenca come obsolete SOLO le dipendenze dichiarate dal repo,
# non i pacchetti globali del runner (torch/cuda/nvidia su runner ML/GPU)
python -m venv .audit-venv
.audit-venv/bin/pip install --upgrade pip
if [ -n "${{ inputs.install-extras }}" ]; then
pip install -e ".[${{ inputs.install-extras }}]"
.audit-venv/bin/pip install -e ".[${{ inputs.install-extras }}]"
elif [ -f requirements.txt ]; then
pip install -r requirements.txt
.audit-venv/bin/pip install -r requirements.txt
else
pip install -e "."
.audit-venv/bin/pip install -e "."
fi
- name: Check outdated packages
id: outdated
run: |
pip list --outdated --format=json > outdated.json 2>/dev/null || echo '[]' > outdated.json
.audit-venv/bin/pip list --outdated --format=json > outdated.json 2>/dev/null || echo '[]' > outdated.json
COUNT=$(python3 -c "import json; print(len(json.load(open('outdated.json'))))")
echo "count=$COUNT" >> $GITHUB_OUTPUT
- name: Open issue if packages outdated
- name: Open or update issue if packages outdated
if: steps.outdated.outputs.count != '0'
env:
GITEA_TOKEN: ${{ gitea.token }}
@@ -65,6 +68,7 @@ jobs:
run: |
COUNT="${{ steps.outdated.outputs.count }}"
DATE=$(date '+%Y-%m-%d')
TITLE_PREFIX="Dipendenze Python:"
OUTDATED_LIST=$(python3 -c "
import json
@@ -79,11 +83,26 @@ jobs:
printf '## Dipendenze Python Obsolete — %s\n\n### Pacchetti da aggiornare: %s\n\n```\n%s\n```\n' \
"$DATE" "$COUNT" "$OUTDATED_LIST" > /tmp/body.md
curl -s -X POST \
-H "Content-Type: application/json" \
# Deduplica: se esiste già una issue aperta con lo stesso prefisso,
# aggiungi un commento invece di aprirne una nuova
EXISTING=$(curl -s \
-H "Authorization: token $GITEA_TOKEN" \
"$SERVER_URL/api/v1/repos/$REPOSITORY/issues" \
-d "{
\"title\": \"[$DATE] Dipendenze Python: $COUNT pacchetti obsoleti\",
\"body\": $(jq -Rs . /tmp/body.md)
}"
"$SERVER_URL/api/v1/repos/$REPOSITORY/issues?state=open&type=issues&limit=50" \
| jq -r --arg p "$TITLE_PREFIX" '[.[] | select(.title | contains($p))] | (first // {}) | .number // empty')
if [ -n "$EXISTING" ]; then
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Authorization: token $GITEA_TOKEN" \
"$SERVER_URL/api/v1/repos/$REPOSITORY/issues/$EXISTING/comments" \
-d "{ \"body\": $(jq -Rs . /tmp/body.md) }"
else
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Authorization: token $GITEA_TOKEN" \
"$SERVER_URL/api/v1/repos/$REPOSITORY/issues" \
-d "{
\"title\": \"[$DATE] Dipendenze Python: $COUNT pacchetti obsoleti\",
\"body\": $(jq -Rs . /tmp/body.md)
}"
fi