From 0956b0fa08f46402b00af1915e43f517cd25958a Mon Sep 17 00:00:00 2001 From: docker24002 <350525360+docker24002@users.noreply.github.com> Date: Sat, 31 Oct 2026 13:23:14 +0000 Subject: [PATCH] ci(#80): publier le tag exact sur un runner GitHub --- .github/workflows/ci.yml | 11 +++--- .github/workflows/guard-main.yml | 2 +- .github/workflows/release.yml | 17 +++++++--- .yamllint.yaml | 21 ++++++++++++ CHANGELOG.md | 4 +++ tests/test_workflow_release.py | 57 ++++++++++++++++++++++++++++++++ 6 files changed, 103 insertions(+), 9 deletions(-) create mode 100644 .yamllint.yaml create mode 100644 tests/test_workflow_release.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5cc56d1..e33a6d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,12 +10,15 @@ name: CI jobs: quality: name: Qualité (lint, format, tests) - runs-on: ${{ fromJSON(vars.RUNS_ON_LINUX || '{"group":"maison","labels":["self-hosted","linux"]}') }} + runs-on: ${{ fromJSON(vars.RUNS_ON_LINUX || '"ubuntu-latest"') }} steps: - name: Checkout du dépôt uses: actions/checkout@v7 + - name: Garde-fous de publication sur tag + run: python3 tests/test_workflow_release.py + - name: Installation de uv uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 with: @@ -42,7 +45,7 @@ jobs: uv run coverage run -m unittest test_asyncvnc2 test_reseau_local test_decodage_video -v uv run coverage report - - name: Journalisation loguru (issue #55, SOCLE §8) + - name: "Journalisation loguru (issue #55, SOCLE §8)" # Règles AST (pas de logging stdlib, format {}, pas de secret, except # journalisé) + audit « debug en entrée et à chaque sortie » : la # référence scripts/audit_debug_sorties.baseline ne peut que baisser. @@ -50,7 +53,7 @@ jobs: uv run python3 -m unittest test_loguru_regles -v uv run python3 scripts/audit_debug_sorties.py - - name: Licence et en-têtes SPDX (issue #72) + - name: "Licence et en-têtes SPDX (issue #72)" run: uv run python3 -m unittest test_licence -v python39: @@ -59,7 +62,7 @@ jobs: # garde les annotations `X | None` en chaînes ; vermin vérifie qu'aucune # API de la bibliothèque standard postérieure à 3.9 n'est utilisée. name: Python 3.9 (tests, vermin) - runs-on: ${{ fromJSON(vars.RUNS_ON_LINUX || '{"group":"maison","labels":["self-hosted","linux"]}') }} + runs-on: ${{ fromJSON(vars.RUNS_ON_LINUX || '"ubuntu-latest"') }} steps: - name: Checkout du dépôt diff --git a/.github/workflows/guard-main.yml b/.github/workflows/guard-main.yml index f04cb86..08892a7 100644 --- a/.github/workflows/guard-main.yml +++ b/.github/workflows/guard-main.yml @@ -18,7 +18,7 @@ permissions: jobs: garde-dev-vers-main: name: "Garde : PR vers main doit venir de dev" - runs-on: ${{ fromJSON(vars.RUNS_ON_LINUX || '{"group":"maison","labels":["self-hosted","linux"]}') }} + runs-on: ${{ fromJSON(vars.RUNS_ON_LINUX || '"ubuntu-latest"') }} steps: - name: Vérifier la branche source run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e97dbe7..dfcd3df 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,12 @@ name: Release "on": + workflow_dispatch: + inputs: + tag: + description: Tag vX.Y.Z déjà validé et livré dans main + required: true + type: string push: tags: ["v*"] @@ -14,14 +20,15 @@ permissions: jobs: release: name: Publication - runs-on: ${{ fromJSON(vars.RUNS_ON_LINUX || '{"group":"maison","labels":["self-hosted","linux"]}') }} + runs-on: ${{ fromJSON(vars.RUNS_ON_LINUX || '"ubuntu-latest"') }} env: - TAG: ${{ github.ref_name }} + TAG: ${{ inputs.tag || github.ref_name }} DEPOT: ${{ github.event.repository.name }} steps: - name: Checkout du dépôt uses: actions/checkout@v7 with: + ref: refs/tags/${{ env.TAG }} fetch-depth: 0 # python3 du runner maison trop ancien pour tomllib (Python ≥ 3.11). @@ -40,7 +47,7 @@ jobs: - name: Tag porté par main run: | git fetch --no-tags origin main - if ! git merge-base --is-ancestor "${GITHUB_SHA}" FETCH_HEAD; then + if ! git merge-base --is-ancestor "refs/tags/${TAG}^{commit}" FETCH_HEAD; then echo "::error::le commit tagué ${TAG} n'est pas sur main (passer par le relais dev → main)" exit 1 fi @@ -54,11 +61,13 @@ jobs: fi - name: Archive des sources - run: git archive --format=tar.gz --prefix="${DEPOT}-${VERSION}/" -o "${DEPOT}-${VERSION}.tar.gz" "${GITHUB_SHA}" + run: git archive --format=tar.gz --prefix="${DEPOT}-${VERSION}/" -o "${DEPOT}-${VERSION}.tar.gz" "refs/tags/${TAG}^{commit}" - name: Release GitHub uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 with: + tag_name: ${{ env.TAG }} + draft: false body_path: notes.md files: ${{ github.event.repository.name }}-*.tar.gz fail_on_unmatched_files: true diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..395caa5 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,21 @@ +# yamllint : règles du socle Mathilde-Team +extends: default +rules: + line-length: disable # lambdas C++ et templates Jinja sur une ligne + document-start: disable + truthy: + check-keys: false # clé « on: » des workflows + allowed-values: ['true', 'false', 'yes', 'no'] # ESPHome accepte yes/no (restore_value: yes) + comments: + min-spaces-from-content: 1 + comments-indentation: disable + indentation: + spaces: 2 + indent-sequences: whatever + braces: + max-spaces-inside: 1 + brackets: + max-spaces-inside: 1 +ignore: | + .venv/ + node_modules/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 18228fd..e724e89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ Format : [Keep a Changelog](https://keepachangelog.com/fr/1.1.0/). Les numéros ## [Non publié] +- CI et publication : repli GitHub autorisé, publication manuelle sur un tag + déjà livré dans main, vérification d’ascendance et archives du tag exact. + + ### Ajouté - **Licence** (#72) : ajout de `NOTICE`, qui reprend l'avis des projets amont (asyncvnc de Barney Gale, asyncvnc2 d'Andrew Shirayev, tous deux sous GPLv3) et décrit les régimes de licence. `asyncvnc2.py` reste en `GPL-3.0-only`, le reste du code passe en `GPL-3.0-or-later`. En-têtes SPDX, `license` et `license-files` dans `pyproject.toml`, `test_licence.py`. La sauvegarde `asyncvnc2.py.orig`, que rien n'utilisait, est retirée du dépôt. - **ZYWRLE complet** (#22) : décodage des tuiles à perte de QEMU. Une tuile Raw d'un rectangle ZYWRLE contient une tuile ZRLE imbriquée (coefficients d'ondelettes), reconstruite par `_zywrle_synthesize()`, port octet par octet de `ZYWRLE_SYNTHESIZE` (libvncserver). Le niveau (3 - qualité // 3) est déduit de `jpeg_quality`, désormais conservé par `Video`. Vérifié contre QEMU 10.2.1 (`test_live_qemu_zywrle.py`, job « Serveur réel »). `Enc.ZYWRLE` reste hors `Enc.default()` (à perte). diff --git a/tests/test_workflow_release.py b/tests/test_workflow_release.py new file mode 100644 index 0000000..d42eabb --- /dev/null +++ b/tests/test_workflow_release.py @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: GPL-3.0-or-later +"""Garde-fous hors réseau de la publication du tag exact depuis GitHub.""" + +import json +import unittest +from pathlib import Path + + +class PublicationSurTag(unittest.TestCase): + def setUp(self): + self.workflows = Path(__file__).resolve().parents[1] / '.github' / 'workflows' + + def test_tag_explicite_et_ascendance_main(self): + texte = (self.workflows / 'release.yml').read_text(encoding='utf-8') + self.assertIn(' workflow_dispatch:', texte) + self.assertIn(' TAG: ${{ inputs.tag || github.ref_name }}', texte) + self.assertIn(' ref: refs/tags/${{ env.TAG }}', texte) + self.assertIn(' fetch-depth: 0', texte) + self.assertIn('merge-base --is-ancestor', texte) + self.assertIn('refs/tags/${TAG}^{commit}', texte) + self.assertNotIn('${GITHUB_REF_NAME}', texte) + self.assertNotIn('${GITHUB_SHA}', texte) + self.assertIn(' draft: false', texte) + self.assertIn(' tag_name: ${{ env.TAG }}', texte) + self.assertIn(' fail_on_unmatched_files: true', texte) + + def test_repli_github_et_garde_main_conserves(self): + for nom in ('ci.yml', 'guard-main.yml', 'release.yml'): + texte = (self.workflows / nom).read_text(encoding='utf-8') + repli = 'fromJSON(vars.RUNS_ON_LINUX || \'"ubuntu-latest"\')' + direct = any( + ligne.strip() + in ( + 'runs-on: ubuntu-latest', + 'runs-on: ubuntu-24.04', + 'runs-on: ubuntu-26.04', + ) + for ligne in texte.splitlines() + ) + self.assertTrue(repli in texte or direct) + garde = (self.workflows / 'guard-main.yml').read_text(encoding='utf-8') + self.assertIn('Garde : PR vers main doit venir de dev', garde) + self.assertIn('!= "dev"', garde) + ci = (self.workflows / 'ci.yml').read_text(encoding='utf-8') + regle = json.loads( + (self.workflows.parent / 'branch-protection' / 'dev.json').read_text(encoding='utf-8') + )['required_status_checks'] + contextes = [check['context'] for check in regle.get('checks', [])] + contextes.extend(regle.get('contexts', [])) + self.assertTrue(contextes) + for contexte in contextes: + self.assertIn(contexte, ci + '\n' + garde) + self.assertIn('run: python3 tests/test_workflow_release.py', ci) + + +if __name__ == '__main__': + unittest.main()