📦 build(ci): aggiungi workflow CI, release e manutenzione python
- aggiunto esempio workflow CI per python con quality gates
- aggiunto esempio workflow manutenzione con branch cleanup, audit sicurezza e check pacchetti obsoleti
- aggiunto esempio workflow release per build docker e auto-release gitea
📦 build(shared-actions): aggiungi shared-actions python per CI/CD
- aggiunto python-quality-gates.yml per lint, format, type check e test
- aggiunto python-auto-release.yml per changelog e rilascio automatico
- aggiunto python-docker-release.yml per build e push immagini docker
- aggiunto python-dependency-check.yml per audit sicurezza dipendenze
- aggiunto python-dependency-outdated.yml per verifica pacchetti obsoleti
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
name: Python Dependency Outdated
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
python-version:
|
||||
type: string
|
||||
default: '3.11'
|
||||
install-extras:
|
||||
type: string
|
||||
default: 'dev'
|
||||
working-directory:
|
||||
type: string
|
||||
default: '.'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
python-dependency-outdated:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://gitea.com/actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: https://github.com/actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ inputs.python-version || '3.11' }}
|
||||
|
||||
- name: Cache pip
|
||||
uses: https://gitea.com/actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ inputs.python-version }}-${{ hashFiles('**/pyproject.toml', '**/requirements*.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-${{ inputs.python-version }}-
|
||||
${{ runner.os }}-pip-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
if [ -n "${{ inputs.install-extras }}" ]; then
|
||||
pip install -e ".[${{ inputs.install-extras }}]"
|
||||
elif [ -f requirements.txt ]; then
|
||||
pip install -r requirements.txt
|
||||
else
|
||||
pip install -e "."
|
||||
fi
|
||||
|
||||
- name: Check outdated packages
|
||||
id: outdated
|
||||
run: |
|
||||
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
|
||||
if: steps.outdated.outputs.count != '0'
|
||||
env:
|
||||
GITEA_TOKEN: ${{ gitea.token }}
|
||||
SERVER_URL: ${{ gitea.server_url }}
|
||||
REPOSITORY: ${{ gitea.repository }}
|
||||
run: |
|
||||
COUNT="${{ steps.outdated.outputs.count }}"
|
||||
DATE=$(date '+%Y-%m-%d')
|
||||
|
||||
OUTDATED_LIST=$(python3 -c "
|
||||
import json
|
||||
try:
|
||||
data = json.load(open('outdated.json'))
|
||||
lines = [f\"- {p['name']}: {p['version']} → {p['latest_version']}\" for p in data[:20]]
|
||||
print('\n'.join(lines))
|
||||
except Exception:
|
||||
print('N/A')
|
||||
")
|
||||
|
||||
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" \
|
||||
-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)
|
||||
}"
|
||||
Reference in New Issue
Block a user