diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac29629..0a6fe21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,67 @@ on: pull_request: branches: [main, master] +# Superseded PR runs are cancelled. Push runs (main/master) get their own group (run_id), so a main run is never +# cancelled, not even while pending: tag_when_green.sh needs a completed run on every release commit. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: + # Light mode (docs/GITHUB_CI.md#light-mode-for-deps-and-docs-only-prs): one representative cell plus the cheap + # gates. The org (or repo) Actions variable NOWO_CI_PR_MODE picks the PR mode: light = every PR light; full = every + # PR full; auto / unset = light only when the PR touches nothing but composer.json / composer.lock (root or demo), + # docs/**, *.md, .github/ISSUE_TEMPLATE/**, specs/** or .cursor/**. push, tags, workflow_dispatch and schedule are + # always full. Fail-closed: any error, unknown value or empty output means full (jobs reduce only on 'light'). + changes: + name: Change scope (light or full) + runs-on: ubuntu-latest + outputs: + mode: ${{ steps.classify.outputs.mode }} + steps: + - name: Checkout code (PR merge commit and its base parent) + if: github.event_name == 'pull_request' + uses: actions/checkout@v7 + with: + fetch-depth: 2 + + - name: Classify the change + id: classify + env: + EVENT: ${{ github.event_name }} + SWITCH: ${{ vars.NOWO_CI_PR_MODE }} + LIGHT: '^((demo/([^/]+/)?)?composer\.(json|lock)|docs/.*|specs/.*|\.cursor/.*|\.github/ISSUE_TEMPLATE/.*|.*\.md)$' + run: | + mode=full; paths="" + if [ "$EVENT" != pull_request ]; then + reason="event '$EVENT' always runs full" + else + case "$SWITCH" in + light) mode=light; reason="NOWO_CI_PR_MODE=light: every PR is light" ;; + full) reason="NOWO_CI_PR_MODE=full: every PR is full" ;; + ''|auto) + if files=$(git diff --name-only --no-renames HEAD^1 HEAD); then + mode=light; reason="NOWO_CI_PR_MODE=${SWITCH:-unset} (auto): only deps/docs paths changed" + while IFS= read -r f; do + [ -n "$f" ] || continue + if ! printf '%s\n' "$f" | grep -Eq "$LIGHT"; then mode=full; paths="$paths $f"; fi + done <<< "$files" + [ "$mode" = light ] || reason="NOWO_CI_PR_MODE=${SWITCH:-unset} (auto): non deps/docs paths changed:$paths" + else + reason="NOWO_CI_PR_MODE=${SWITCH:-unset} (auto): git diff failed, fail-closed" + fi ;; + *) reason="NOWO_CI_PR_MODE='$SWITCH' is not light/auto/full, fail-closed" ;; + esac + fi + echo "mode=$mode ($reason)" + echo "mode=$mode" >> "$GITHUB_OUTPUT" + { + echo "### CI mode: \`$mode\`" + echo "" + echo "$reason" + if [ "$EVENT" = pull_request ] && [ -n "${files:-}" ]; then echo ""; echo "Changed paths:"; echo '```'; echo "$files" | head -200; echo '```'; fi + } >> "$GITHUB_STEP_SUMMARY" + git-hygiene: name: Git history (no Cursor co-author) runs-on: ubuntu-latest @@ -24,6 +84,9 @@ jobs: test: name: PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }} - ${{ matrix.os }} runs-on: ${{ matrix.os }} + needs: changes + # Never skip this job: a skipped matrix job reports its un-expanded name and the required contexts never appear. + if: ${{ !cancelled() }} strategy: fail-fast: false @@ -39,11 +102,19 @@ jobs: - php: '8.3' symfony: '8.1' + env: + HEAVY: ${{ needs.changes.outputs.mode != 'light' || (matrix.php == '8.5' && matrix.symfony == '8.1') }} steps: + - name: Light mode (deps/docs-only PR) - covered by PHP 8.5 - Symfony 8.1 + if: env.HEAVY != 'true' + run: echo "Light mode, this cell has nothing to do." + - name: Checkout code + if: env.HEAVY == 'true' uses: actions/checkout@v7 - name: Setup PHP + if: env.HEAVY == 'true' uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} @@ -52,13 +123,16 @@ jobs: tools: composer:v2 - name: Validate composer.json + if: env.HEAVY == 'true' run: composer validate --strict - name: Get Composer cache directory + if: env.HEAVY == 'true' id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache Composer dependencies + if: env.HEAVY == 'true' uses: actions/cache@v6 with: path: ${{ steps.composer-cache.outputs.dir }} @@ -68,9 +142,11 @@ jobs: ${{ runner.os }}-php-${{ matrix.php }}-composer- - name: Override Composer platform PHP (composer.json pins the minimum PHP for the lock) + if: env.HEAVY == 'true' run: composer config platform.php "${{ matrix.php }}.99" - name: Install dependencies with Symfony ${{ matrix.symfony }} + if: env.HEAVY == 'true' run: | echo "๐Ÿ“ฆ Installing dependencies for Symfony ${{ matrix.symfony }}..." # doctrine/doctrine-bundle ^3.0 requires PHP ^8.4; use ^2.10 on PHP 8.2/8.3. @@ -92,10 +168,12 @@ jobs: composer require symfony/yaml:^${{ matrix.symfony }} --dev --no-interaction --no-update composer update --with-all-dependencies --no-interaction --prefer-dist --no-progress - name: Composer audit (Critical/High) + if: env.HEAVY == 'true' run: composer audit --locked - name: Run tests + if: env.HEAVY == 'true' run: | echo "๐Ÿงช Running tests on PHP ${{ matrix.php }} with Symfony ${{ matrix.symfony }}..." composer test @@ -106,7 +184,7 @@ jobs: echo "โœ… All tests passed successfully" - name: Validate coverage (PHP 8.2 with Symfony 7.4 only) - if: matrix.php == '8.2' && matrix.symfony == '7.4' + if: env.HEAVY == 'true' && (matrix.php == '8.2' && matrix.symfony == '7.4') run: | echo "๐Ÿ“Š Generating coverage report..." composer test-coverage @@ -246,6 +324,9 @@ jobs: real-databases: name: Inbound capture in an open transaction and GDPR ports on PostgreSQL and MySQL runs-on: ubuntu-latest + # Light mode: skipped (a skipped non-matrix job reports its own name with success for branch protection). + needs: changes + if: ${{ !cancelled() && needs.changes.outputs.mode != 'light' }} services: postgres: image: postgres:17-alpine @@ -327,10 +408,13 @@ jobs: database: name: Real databases (MySQL 8.4, MariaDB 11.4, PostgreSQL 16) - DBAL ${{ matrix.dbal }} runs-on: ubuntu-latest + needs: changes + # Never skip this job: a skipped matrix job reports its un-expanded name and the required contexts never appear. + if: ${{ !cancelled() }} services: mysql: - image: mysql:8.4 + image: ${{ needs.changes.outputs.mode != 'light' && 'mysql:8.4' || '' }} env: MYSQL_ROOT_PASSWORD: ci-placeholder MYSQL_DATABASE: http_log @@ -338,7 +422,7 @@ jobs: options: >- --health-cmd "mysqladmin ping -h 127.0.0.1 -pci-placeholder" --health-interval 5s --health-timeout 5s --health-retries 30 mariadb: - image: mariadb:11.4 + image: ${{ needs.changes.outputs.mode != 'light' && 'mariadb:11.4' || '' }} env: MARIADB_ROOT_PASSWORD: ci-placeholder MARIADB_DATABASE: http_log @@ -346,7 +430,7 @@ jobs: options: >- --health-cmd "healthcheck.sh --connect --innodb_initialized" --health-interval 5s --health-timeout 5s --health-retries 30 postgres: - image: postgres:16-alpine + image: ${{ needs.changes.outputs.mode != 'light' && 'postgres:16-alpine' || '' }} env: POSTGRES_PASSWORD: ci-placeholder POSTGRES_DB: http_log @@ -359,11 +443,19 @@ jobs: matrix: dbal: ['3', '4'] + env: + HEAVY: ${{ needs.changes.outputs.mode != 'light' }} steps: + - name: Light mode (deps/docs-only PR) - no database run + if: env.HEAVY != 'true' + run: echo "Light mode, this cell has nothing to do." + - name: Checkout code + if: env.HEAVY == 'true' uses: actions/checkout@v7 - name: Setup PHP + if: env.HEAVY == 'true' uses: shivammathur/setup-php@v2 with: php-version: '8.4' @@ -372,6 +464,7 @@ jobs: tools: composer:v2 - name: Install dependencies (DBAL ${{ matrix.dbal }}) + if: env.HEAVY == 'true' run: | composer config platform.php 8.4.1 composer require doctrine/dbal:^${{ matrix.dbal }} --no-interaction --no-update @@ -379,6 +472,7 @@ jobs: composer show doctrine/dbal - name: Concurrency tests on MySQL 8.4, MariaDB 11.4 and PostgreSQL 16 (REQ-RUNTIME-003) + if: env.HEAVY == 'true' timeout-minutes: 10 env: HTTPLOG_TEST_MYSQL_URL: mysql://root:ci-placeholder@127.0.0.1:3306/http_log?serverVersion=8.4.0&charset=utf8mb4 @@ -391,6 +485,7 @@ jobs: # Audit VB-5: only the skips by design may happen (the opt-in performance test, and the PostgreSQL id conversion # test of the other DBAL major); check-skips.py fails on any other skipped test. - name: Integration suite on MySQL 8.4 and PostgreSQL 16 (DBAL ${{ matrix.dbal }}) + if: env.HEAVY == 'true' timeout-minutes: 15 env: HTTPLOG_TEST_MYSQL_URL: mysql://root:ci-placeholder@127.0.0.1:3306/http_log?serverVersion=8.4.0&charset=utf8mb4 @@ -402,6 +497,7 @@ jobs: "${{ matrix.dbal == '3' && 'RollupSchemaTest::theMoveToDbal4KeepsTheIdsAndLeavesNoSchemaDiff=1' || 'RollupSchemaTest::theDbal3IdentityConversionLeavesNoSchemaDiff=1' }}" - name: Integration suite on MariaDB 11.4 and PostgreSQL 16 (DBAL ${{ matrix.dbal }}) + if: env.HEAVY == 'true' timeout-minutes: 15 env: HTTPLOG_TEST_MYSQL_URL: mysql://root:ci-placeholder@127.0.0.1:3307/http_log?serverVersion=11.4.0-MariaDB&charset=utf8mb4 @@ -453,6 +549,9 @@ jobs: coverage: name: Code Coverage runs-on: ubuntu-latest + # Light mode: skipped (a skipped non-matrix job reports its own name with success for branch protection). + needs: changes + if: ${{ !cancelled() && needs.changes.outputs.mode != 'light' }} steps: - name: Checkout code diff --git a/.github/workflows/pr-lint.yml b/.github/workflows/pr-lint.yml index 181d752..f250ddf 100644 --- a/.github/workflows/pr-lint.yml +++ b/.github/workflows/pr-lint.yml @@ -8,6 +8,10 @@ on: - reopened - synchronize +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: semantic-pr: name: Validate semantic PR title diff --git a/composer.json b/composer.json index 82218f3..2e19404 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "doctrine/orm": "^3.7", "nowo-tech/form-kit-bundle": "^2.10", "nowo-tech/transaction-contract": "^1.0", - "nowo-tech/transaction-doctrine": "^1.6", + "nowo-tech/transaction-doctrine": "^1.8.1", "nowo-tech/ui-kit-bundle": "^2.2", "psr/clock": "^1.0", "psr/event-dispatcher": "^1.0", diff --git a/composer.lock b/composer.lock index ef35b6b..ef7efaa 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1634b484b5acd52b344a74b4a322ca2a", + "content-hash": "57a027a4b8c87ab7fb9b77a66df39354", "packages": [ { "name": "doctrine/collections", @@ -197,7 +197,8 @@ "type": "tidelift" } ], - "time": "2026-11-14T18:08:09+00:00" + "time": "2026-11-14T18:08:09+00:00", + "published-time": "2026-11-14T18:18:19+00:00" }, { "name": "doctrine/deprecations", @@ -245,7 +246,8 @@ "issues": "https://github.com/doctrine/deprecations/issues", "source": "https://github.com/doctrine/deprecations/tree/1.2.0" }, - "time": "2026-11-11T10:04:49+00:00" + "time": "2026-11-11T10:04:49+00:00", + "published-time": "2026-11-11T10:12:24+00:00" }, { "name": "doctrine/doctrine-bundle", @@ -460,7 +462,8 @@ "type": "tidelift" } ], - "time": "2026-01-29T07:11:08+00:00" + "time": "2026-01-29T07:11:08+00:00", + "published-time": "2026-01-29T07:11:33+00:00" }, { "name": "doctrine/inflector", @@ -1127,16 +1130,16 @@ }, { "name": "nowo-tech/transaction-doctrine", - "version": "v1.6.1", + "version": "v1.8.1", "source": { "type": "git", "url": "https://github.com/nowo-tech/transaction-doctrine.git", - "reference": "2508e7689c0051c28ca8532a4cdf31ca7bfff311" + "reference": "58724e0ca8c3ebe3ff8c675b22a329a3d83d2ea3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nowo-tech/transaction-doctrine/zipball/2508e7689c0051c28ca8532a4cdf31ca7bfff311", - "reference": "2508e7689c0051c28ca8532a4cdf31ca7bfff311", + "url": "https://api.github.com/repos/nowo-tech/transaction-doctrine/zipball/58724e0ca8c3ebe3ff8c675b22a329a3d83d2ea3", + "reference": "58724e0ca8c3ebe3ff8c675b22a329a3d83d2ea3", "shasum": "" }, "require": { @@ -1194,7 +1197,8 @@ }, "autoload": { "psr-4": { - "Nowo\\TransactionDoctrine\\": "src/" + "Nowo\\TransactionDoctrine\\": "src/", + "Nowo\\TransactionDoctrine\\WriteUnit\\Dbal\\Dbal3\\": "compat/dbal3/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1232,8 +1236,8 @@ "issues": "https://github.com/nowo-tech/transaction-doctrine/issues", "source": "https://github.com/nowo-tech/transaction-doctrine" }, - "time": "2026-11-18T23:35:00+00:00", - "published-time": "2026-11-18T23:37:46+00:00" + "time": "2026-11-20T09:09:22+00:00", + "published-time": "2026-11-20T09:23:55+00:00" }, { "name": "nowo-tech/ui-kit-bundle", @@ -1384,7 +1388,8 @@ "support": { "source": "https://github.com/php-fig/cache/tree/3.0.0" }, - "time": "2021-02-03T23:26:27+00:00" + "time": "2021-02-03T23:26:27+00:00", + "published-time": "2021-02-03T23:27:34+00:00" }, { "name": "psr/clock", diff --git a/demo/symfony8/composer.lock b/demo/symfony8/composer.lock index 362eebd..a2d7e28 100644 --- a/demo/symfony8/composer.lock +++ b/demo/symfony8/composer.lock @@ -1049,18 +1049,18 @@ }, { "name": "nowo-tech/http-log-bundle", - "version": "dev-fix/concurrency-req-runtime-003", + "version": "dev-chore/transaction-doctrine-1.8", "dist": { "type": "path", "url": "/var/http-log-bundle", - "reference": "91ae81dd1c4d6eb79897828767755dea52a0ea3b" + "reference": "7ac459f3efe9399ad08229db813cbcc98928a245" }, "require": { "doctrine/doctrine-bundle": "^2.10 || ^3.0", "doctrine/orm": "^3.7", "nowo-tech/form-kit-bundle": "^2.10", "nowo-tech/transaction-contract": "^1.0", - "nowo-tech/transaction-doctrine": "^1.6", + "nowo-tech/transaction-doctrine": "^1.8.1", "nowo-tech/ui-kit-bundle": "^2.2", "php": ">=8.2 <8.6", "psr/clock": "^1.0", @@ -1269,16 +1269,16 @@ }, { "name": "nowo-tech/transaction-doctrine", - "version": "v1.6.1", + "version": "v1.8.1", "source": { "type": "git", "url": "https://github.com/nowo-tech/transaction-doctrine.git", - "reference": "2508e7689c0051c28ca8532a4cdf31ca7bfff311" + "reference": "58724e0ca8c3ebe3ff8c675b22a329a3d83d2ea3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nowo-tech/transaction-doctrine/zipball/2508e7689c0051c28ca8532a4cdf31ca7bfff311", - "reference": "2508e7689c0051c28ca8532a4cdf31ca7bfff311", + "url": "https://api.github.com/repos/nowo-tech/transaction-doctrine/zipball/58724e0ca8c3ebe3ff8c675b22a329a3d83d2ea3", + "reference": "58724e0ca8c3ebe3ff8c675b22a329a3d83d2ea3", "shasum": "" }, "require": { @@ -1336,7 +1336,8 @@ }, "autoload": { "psr-4": { - "Nowo\\TransactionDoctrine\\": "src/" + "Nowo\\TransactionDoctrine\\": "src/", + "Nowo\\TransactionDoctrine\\WriteUnit\\Dbal\\Dbal3\\": "compat/dbal3/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1374,8 +1375,8 @@ "issues": "https://github.com/nowo-tech/transaction-doctrine/issues", "source": "https://github.com/nowo-tech/transaction-doctrine" }, - "time": "2026-11-18T23:35:00+00:00", - "published-time": "2026-11-18T23:37:46+00:00" + "time": "2026-11-20T09:09:22+00:00", + "published-time": "2026-11-20T09:23:55+00:00" }, { "name": "nowo-tech/ui-kit-bundle", diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a193a0a..0683767 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -56,6 +56,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Requires `nowo-tech/transaction-doctrine` ^1.8.1 (fixes GHSA-9wh3-m3m5-jffx and GHSA-65w2-9r4h-848g). + ## [1.23.0] - 2026-11-19 ### Changed diff --git a/docs/GITHUB_CI.md b/docs/GITHUB_CI.md index 6a43d72..f9aac95 100644 --- a/docs/GITHUB_CI.md +++ b/docs/GITHUB_CI.md @@ -19,6 +19,10 @@ Canonical per-repo doc for **REQ-GIT-001** (no Cursor co-author trailers). Copy - [Multi-bundle (from `repositories/bundles/`)](#multi-bundle-from-repositoriesbundles) - [Prevention](#prevention) - [Common pitfalls](#common-pitfalls) +- [Light mode for deps and docs-only PRs](#light-mode-for-deps-and-docs-only-prs) + - [Classification](#classification) + - [What still runs in light mode](#what-still-runs-in-light-mode) + - [Concurrency](#concurrency) - [Acceptance criteria](#acceptance-criteria) - [References](#references) @@ -215,6 +219,65 @@ Compliance matrix: `python3 .scripts/audit-bundles-checklist.py` (checker `REQ-G --- +## Light mode for deps and docs-only PRs + +Bundle PRs run a reduced CI when they only touch dependencies or documentation, or on every PR while the +organisation switch says so, so bursts of Dependabot / docs PRs do not +hold the organisation's runner pool for hours. Releases are not affected: they are tagged from a **push** run, which +always runs everything. + +### Classification + +The `changes` job of `ci.yml` sets `mode` (and writes the reason and the changed paths to the job summary). The +organisation Actions variable `NOWO_CI_PR_MODE` decides how pull requests are treated; a repository variable with +the same name overrides it for one repo: + +| `NOWO_CI_PR_MODE` | Pull requests | push (main/master), tags, `workflow_dispatch`, `schedule` | +|-------------------|---------------|-------------------------------------------------------------| +| `light` | every PR is light, whatever it touches | always full | +| `auto`, unset or empty | light only when every changed path is `composer.json` / `composer.lock` (root or `demo//`), `docs/**`, `*.md`, `.github/ISSUE_TEMPLATE/**`, `specs/**` or `.cursor/**`; full otherwise | always full | +| `full` | every PR is full | always full | + +In `auto` the job diffs the PR merge commit against its base parent (`git diff --name-only --no-renames HEAD^1 HEAD`, +no third-party action). It is fail-closed: jobs are only reduced on `mode == 'light'`, so an error, an unknown +variable value or an empty output means a full run. + +**Switching back to full CI is a one-place change**: set the organisation variable `NOWO_CI_PR_MODE` to `auto` +(path-based) or `full` (Settings โ†’ Secrets and variables โ†’ Actions โ†’ Variables, or +`gh variable set NOWO_CI_PR_MODE --org nowo-tech --body full`). No workflow edit is needed. One repo can opt out +with a repository variable of the same name (`gh variable set NOWO_CI_PR_MODE -R nowo-tech/ --body full`). + +### What still runs in light mode + +- The newest PHP ร— newest Symfony cell of the test matrix (PHP 8.5 - Symfony 8.1): `composer validate --strict`, install, `composer + audit`, the whole PHPUnit suite. +- PHPStan, Code Style Check, Dependency floor (it validates the demo lock), Git history and the semantic PR title. + +Skipped or reduced in light mode: Code Coverage, the inbound-capture database job and the real-database matrix (its service images stay empty). + +The other matrix cells still start and report success after one echo step: a matrix job skipped with a job-level +`if:` reports its un-expanded name (`PHP ${{ matrix.php }} - โ€ฆ`), so the required contexts `PHP x - Symfony y` would +never appear and the PR would stay blocked. Matrix jobs with service containers also pass an empty service `image` in +light mode, so no database container is pulled. Non-matrix jobs (coverage, databases, demo smoke, โ€ฆ) are skipped with +a job-level `if:`: a skipped job reports its own name with a successful conclusion for branch protection. Workflows +without any required check may use `paths-ignore` with the same list plus a job-level +`if: ${{ github.event_name != 'pull_request' || vars.NOWO_CI_PR_MODE != 'light' }}` instead (never on a workflow +that holds a required check: a path-filtered workflow leaves its checks pending). + +### Concurrency + +PR workflows declare: + +```yaml +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} +``` + +A new push to a PR cancels its superseded run. Push runs use their own `run_id` group: a shared group (for example +`github.ref`) would cancel a *pending* main run when a third one queues, even with `cancel-in-progress: false`, and +`tag_when_green.sh` would then find no green run for that release commit. + ## Acceptance criteria A bundle complies when: @@ -233,6 +296,6 @@ A bundle complies when: - [CONTRIBUTING.md](CONTRIBUTING.md) โ€” hooks and contribution flow - [RELEASE.md](RELEASE.md) โ€” post-tag co-author check before push -- [.github/workflows/ci.yml](../.github/workflows/ci.yml) โ€” `git-hygiene` job +- [.github/workflows/ci.yml](../.github/workflows/ci.yml) โ€” `git-hygiene` job, `changes` job (light mode) - Shared templates: `repositories/bundles/.scripts/templates/` - Spec detail: `repositories/bundles/BUNDLES_FULL_SPECS_DETAILS.md` โ†’ REQ-GIT-001