|
| 1 | +name: Package Integrity |
| 2 | + |
| 3 | +# Guards the split-package contract that the monorepo's local autoload hides: |
| 4 | +# - undeclared-deps (B7-class): each split component must declare in its OWN composer.json |
| 5 | +# every third-party/sibling package its source uses. Locally the root |
| 6 | +# autoload + root vendor mask missing requires; this installs each |
| 7 | +# component in isolation and statically checks for used-but-undeclared symbols. |
| 8 | +# - php-matrix (B6-class): the suite must run on the declared PHP floor (8.3) AND the |
| 9 | +# latest (8.4), so a too-low floor or version-specific syntax fails CI. |
| 10 | + |
| 11 | +on: |
| 12 | + pull_request: |
| 13 | + push: |
| 14 | + branches: [ main ] |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +jobs: |
| 20 | + undeclared-deps: |
| 21 | + name: Undeclared deps (${{ matrix.repo }}) |
| 22 | + runs-on: ubuntu-latest |
| 23 | + env: |
| 24 | + COMPOSER_NO_INTERACTION: 1 |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + # Generated Models/ is intentionally excluded (regenerated, not hand-authored). |
| 29 | + include: |
| 30 | + - path: src/Component/Metadata |
| 31 | + repo: fhir-metadata |
| 32 | + - path: src/Component/Serialization |
| 33 | + repo: fhir-serialization |
| 34 | + - path: src/Component/FHIRPath |
| 35 | + repo: fhir-path |
| 36 | + - path: src/Component/CodeGeneration |
| 37 | + repo: fhir-code-generation |
| 38 | + - path: src/Component/Validation |
| 39 | + repo: fhir-validation |
| 40 | + - path: src/Bundle/FHIRBundle |
| 41 | + repo: fhir-bundle |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Setup PHP |
| 46 | + uses: shivammathur/setup-php@v2 |
| 47 | + with: |
| 48 | + php-version: '8.3' |
| 49 | + extensions: ctype, iconv, zip |
| 50 | + tools: composer-require-checker |
| 51 | + |
| 52 | + # Sibling ardenexal/* packages are released together and the new (0.4.x) versions are |
| 53 | + # not on Packagist yet, so resolve them from the in-repo source via path repositories. |
| 54 | + # Each sibling carries a dev-main -> 0.4.x-dev branch-alias, so relax stability for this |
| 55 | + # isolation install only (the edits below land on the ephemeral CI checkout, never the |
| 56 | + # committed manifest). Once 0.4.0 is tagged, siblings resolve as stable and these are no-ops. |
| 57 | + - name: Wire sibling path repositories |
| 58 | + working-directory: ${{ matrix.path }} |
| 59 | + run: | |
| 60 | + composer config minimum-stability dev |
| 61 | + composer config prefer-stable true |
| 62 | + self=$(jq -r '.name' composer.json) |
| 63 | + for dir in "$GITHUB_WORKSPACE"/src/Component/* "$GITHUB_WORKSPACE"/src/Bundle/*; do |
| 64 | + [ -f "$dir/composer.json" ] || continue |
| 65 | + name=$(jq -r '.name // empty' "$dir/composer.json") |
| 66 | + [ -z "$name" ] && continue |
| 67 | + [ "$name" = "$self" ] && continue |
| 68 | + key=$(echo "$name" | tr '/' '-') |
| 69 | + composer config "repositories.$key" path "$dir" |
| 70 | + # Pin an explicit dev version on the sibling so detached-HEAD CI checkouts |
| 71 | + # don't fall back to dev-<sha> (which the dev-main branch-alias can't match) |
| 72 | + # and the ^0.4 sibling constraints resolve. No-op once 0.4.0 is tagged. |
| 73 | + composer config version 0.4.x-dev --working-dir="$dir" |
| 74 | + done |
| 75 | +
|
| 76 | + - name: Install in isolation (declared production deps only) |
| 77 | + working-directory: ${{ matrix.path }} |
| 78 | + run: composer install --no-dev --no-progress --prefer-dist |
| 79 | + |
| 80 | + - name: Check for undeclared dependencies |
| 81 | + working-directory: ${{ matrix.path }} |
| 82 | + run: composer-require-checker check --config-file="$GITHUB_WORKSPACE/.github.qkg1.topposer-require-checker.json" |
| 83 | + |
| 84 | + php-matrix: |
| 85 | + name: PHP ${{ matrix.php }} |
| 86 | + runs-on: ubuntu-latest |
| 87 | + env: |
| 88 | + XDEBUG_MODE: off |
| 89 | + COMPOSER_NO_INTERACTION: 1 |
| 90 | + strategy: |
| 91 | + fail-fast: false |
| 92 | + matrix: |
| 93 | + php: [ '8.3', '8.4' ] |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v4 |
| 96 | + with: |
| 97 | + fetch-depth: 0 |
| 98 | + |
| 99 | + - name: Setup PHP |
| 100 | + uses: shivammathur/setup-php@v2 |
| 101 | + with: |
| 102 | + php-version: ${{ matrix.php }} |
| 103 | + extensions: ctype, iconv, zip |
| 104 | + |
| 105 | + - name: Install dependencies |
| 106 | + run: composer install --prefer-dist --no-progress |
| 107 | + |
| 108 | + - name: Validate composer manifests |
| 109 | + run: composer validate --strict |
| 110 | + |
| 111 | + - name: Run unit suite |
| 112 | + run: composer run test-ai-unit |
| 113 | + |
| 114 | + # Fan-in gate for branch protection: require this single check instead of the |
| 115 | + # individual matrix legs so the ruleset survives future matrix changes. |
| 116 | + package-integrity-passed: |
| 117 | + runs-on: ubuntu-latest |
| 118 | + needs: [ undeclared-deps, php-matrix ] |
| 119 | + if: ${{ always() }} |
| 120 | + steps: |
| 121 | + - name: Check matrix results |
| 122 | + run: | |
| 123 | + if [ "${{ needs.undeclared-deps.result }}" != "success" ] || [ "${{ needs.php-matrix.result }}" != "success" ]; then |
| 124 | + echo "undeclared-deps: ${{ needs.undeclared-deps.result }}, php-matrix: ${{ needs.php-matrix.result }}" |
| 125 | + exit 1 |
| 126 | + fi |
0 commit comments