Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changelog/release-phar-cadence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
category: fixed
type: patch
---

Build runtime-affecting pull requests once and qualify the same executable on
all supported PHP versions before automatically refreshing their compiled
distribution. Skip rebuilds for documentation-only changes, refuse refreshes
of closed or superseded branches, and qualify the final merged tree before
atomically including the executable in its native version PR. Bind preparation
and exact-head feedback to the qualified source and preserve automatic fragment
pull-request references.
98 changes: 96 additions & 2 deletions .github/workflows/repository-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ on:
workflow_dispatch:
permissions: {}
jobs:
quality:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/repository-ci.yml
permissions:
contents: read
changelog:
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
permissions:
contents: write
pull-requests: write
Expand All @@ -22,11 +28,99 @@ jobs:
with:
runs-on: '["ubuntu-latest"]'
base-branch: main
managed-branch: changelog/version-recovery-98
managed-branch: changelog/version-phar
source: tags
prepare-release: true
resolve-pull-requests: true
generated-files: '["dist/code-standards"]'
prepare-release: false
publish: true
publish-app-client-id: 'Iv23liHqRng02H747IYa'
publish-environment: release-channels
secrets:
publish-app-private-key: ${{ secrets.RELEASE_CHANNEL_APP_PRIVATE_KEY }}
version:
needs: quality
if: >-
(github.event_name == 'push' || github.event_name == 'workflow_dispatch') &&
github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 15
concurrency:
group: changelog-${{ github.repository }}-main
cancel-in-progress: false
outputs:
pull-request: ${{ steps.version.outputs.pull-request }}
head-sha: ${{ steps.version.outputs.head-sha }}
permissions:
contents: write
pull-requests: write
issues: read
steps:
- name: Skip a qualification superseded by a newer main
id: base
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
QUALIFIED_BASE: ${{ github.sha }}
shell: bash
run: |
current=$(gh api "repos/$GH_REPO/git/ref/heads/main" --jq '.object.sha')
[[ "$current" =~ ^[0-9a-f]{40}$ ]]
if test "$current" = "$QUALIFIED_BASE"; then
echo 'current=true' >> "$GITHUB_OUTPUT"
else
echo 'current=false' >> "$GITHUB_OUTPUT"
echo 'A newer main superseded this qualification; its run prepares the version.' >> "$GITHUB_STEP_SUMMARY"
fi
- if: steps.base.outputs.current == 'true'
uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
fetch-depth: 0
persist-credentials: false
- name: Require the successful qualification's artifact identity
if: steps.base.outputs.current == 'true'
env:
QUALIFIED_ARTIFACT: ${{ needs.quality.outputs.artifact }}
run: test -n "$QUALIFIED_ARTIFACT"
- if: steps.base.outputs.current == 'true'
uses: actions/[email protected]
with:
artifact-ids: ${{ needs.quality.outputs.artifact }}
merge-multiple: true
path: ${{ runner.temp }}/phar
- name: Stage the qualified executable as data
if: steps.base.outputs.current == 'true'
run: |
test -f dist/code-standards && test ! -L dist && test ! -L dist/code-standards
test -f "$RUNNER_TEMP/phar/code-standards" && test ! -L "$RUNNER_TEMP/phar/code-standards"
install -m 755 "$RUNNER_TEMP/phar/code-standards" dist/code-standards
- name: Prepare the version with the qualified executable
if: steps.base.outputs.current == 'true'
id: version
uses: php-fast-forward/changelog/.github/actions/version@v0
with:
base-branch: main
base-ref: ${{ github.sha }}
managed-branch: changelog/version-phar
source: tags
generated-files: '["dist/code-standards"]'
resolve-pull-requests: true
feedback:
needs: version
if: needs.version.outputs.pull-request != '' && needs.version.outputs.head-sha != ''
permissions:
contents: read
pull-requests: write
issues: read
statuses: write
uses: php-fast-forward/changelog/.github/workflows/changelog-pr-status.yml@v0
with:
pull-request: ${{ fromJSON(needs.version.outputs.pull-request) }}
head-sha: ${{ needs.version.outputs.head-sha }}
base-sha: ${{ github.sha }}
base-branch: main
managed-branch: changelog/version-phar
source: tags
generated-files: '["dist/code-standards"]'
resolve-pull-requests: true
173 changes: 145 additions & 28 deletions .github/workflows/repository-ci.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,76 @@
name: 'Repository: Quality'
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
workflow_call:
outputs:
artifact:
description: Fully qualified canonical executable artifact ID.
value: ${{ jobs.compiled.outputs.artifact }}
permissions:
contents: read
jobs:
tests:
inputs:
runs-on: ubuntu-latest
outputs:
build: ${{ steps.inputs.outputs.build }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
persist-credentials: false
- id: inputs
env:
BASE: ${{ github.event.pull_request.base.sha || github.event.before }}
HEAD: ${{ github.event.pull_request.head.sha || github.sha }}
EVENT: ${{ github.event_name }}
shell: bash
run: |
if test "$EVENT" != pull_request; then
echo 'build=true' >> "$GITHUB_OUTPUT"
exit 0
fi
build=true
if git cat-file -e "$BASE^{commit}" 2>/dev/null; then
if test "$EVENT" = pull_request; then
BASE=$(git merge-base "$BASE" "$HEAD")
fi
git diff --no-renames --name-only -z "$BASE" "$HEAD" > "$RUNNER_TEMP/phar-inputs"
build=false
while IFS= read -r -d '' path; do
case "$path" in
tests/Distribution/*|tests/Fixtures/*|.github/workflows/repository-ci.yml|.github/workflows/repository-phar-refresh.yml) build=true ;;
docs/*|.changelog/*|tests/*|.github/*|README.md|CHANGELOG.md|AGENTS.md|.editorconfig|.gitignore|phpunit.xml*) ;;
*) build=true ;;
esac
done < "$RUNNER_TEMP/phar-inputs"
fi
echo "build=$build" >> "$GITHUB_OUTPUT"
build:
needs: inputs
if: needs.inputs.outputs.build == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
php: ['8.3', '8.4', '8.5']
outputs:
stale: ${{ steps.parity.outputs.stale }}
artifact: ${{ steps.candidate.outputs.artifact-id }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
php-version: '8.3'
extensions: dom, posix
coverage: none
tools: composer:v2, box:4.7.1
- run: composer install --no-plugins --no-scripts --no-interaction --prefer-dist --no-progress
env:
COMPOSER_HOME: ${{ runner.temp }}/standards-composer-home
COMPOSER_CACHE_DIR: ${{ runner.temp }}/standards-composer-cache
- run: composer validate --strict
- name: Check Composer normalization
env:
STANDARDS_ROOT: ${{ github.workspace }}
STANDARDS_DIRECTORY: ${{ github.workspace }}
run: |
php "$STANDARDS_ROOT/bin/code-standards" normalize-composer "--directory=$STANDARDS_DIRECTORY"
- run: composer check
- name: Qualify ready PHAR distribution and native runtime
- name: Build once with the canonical PHP runtime
env:
COMPOSER_HOME: ${{ runner.temp }}/standards-phar-composer-home
COMPOSER_CACHE_DIR: ${{ runner.temp }}/standards-composer-cache
Expand All @@ -47,7 +80,6 @@ jobs:
box compile --no-parallel --sort-compiled-files --config="$RUNNER_TEMP/standards-runtime/box.json"
install -m 755 "$RUNNER_TEMP/standards-runtime/dist/code-standards" "$RUNNER_TEMP/code-standards"
box verify "$RUNNER_TEMP/code-standards"
STANDARDS_PHAR="$RUNNER_TEMP/code-standards" vendor/bin/phpunit tests/Distribution/ArchiveTest.php --filter testCompiledDistributionRunsInDisposableConsumers
- name: Compare the committed executable before execution
id: parity
shell: bash
Expand All @@ -61,10 +93,75 @@ jobs:
1) echo 'stale=true' >> "$GITHUB_OUTPUT" ;;
*) exit "$status" ;;
esac
- name: Qualify the committed Composer distribution
if: steps.parity.outputs.stale == 'false'
- id: candidate
uses: actions/upload-artifact@v7
with:
name: code-standards-build-${{ github.event.pull_request.head.sha || github.sha }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/code-standards
compression-level: 0
if-no-files-found: error
runtime:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
php: ['8.3', '8.4', '8.5']
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, posix
coverage: none
tools: composer:v2
- run: composer install --no-plugins --no-scripts --no-interaction --prefer-dist --no-progress
env:
COMPOSER_HOME: ${{ runner.temp }}/standards-composer-home
COMPOSER_CACHE_DIR: ${{ runner.temp }}/standards-composer-cache
- uses: actions/[email protected]
with:
artifact-ids: ${{ needs.build.outputs.artifact }}
merge-multiple: true
path: ${{ runner.temp }}/phar
- name: Qualify the same compiled bytes on every supported PHP
run: |
chmod 755 "$RUNNER_TEMP/phar/code-standards"
STANDARDS_PHAR="$RUNNER_TEMP/phar/code-standards" vendor/bin/phpunit tests/Distribution/ArchiveTest.php --filter testCompiledDistributionRunsInDisposableConsumers
tests:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
php: ['8.3', '8.4', '8.5']
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, posix
coverage: none
tools: composer:v2
Comment thread
coisa marked this conversation as resolved.
Resolved
- run: composer install --no-plugins --no-scripts --no-interaction --prefer-dist --no-progress
env:
COMPOSER_HOME: ${{ runner.temp }}/standards-composer-home
COMPOSER_CACHE_DIR: ${{ runner.temp }}/standards-composer-cache
- run: composer validate --strict
- name: Check Composer normalization
env:
STANDARDS_ROOT: ${{ github.workspace }}
STANDARDS_DIRECTORY: ${{ github.workspace }}
run: |
STANDARDS_PHAR="$GITHUB_WORKSPACE/dist/code-standards" vendor/bin/phpunit tests/Distribution/ArchiveTest.php --filter testCompiledDistributionRunsInDisposableConsumers
php "$STANDARDS_ROOT/bin/code-standards" normalize-composer "--directory=$STANDARDS_DIRECTORY"
- run: composer check
- name: Provision isolated Twig evaluation dependencies
run: composer install --working-dir=tests/Evaluation/Twig --no-dev --no-plugins --no-scripts --no-interaction --prefer-dist --no-progress
env:
Expand All @@ -77,16 +174,36 @@ jobs:
TWIG_EVALUATION_AUTOLOAD: ${{ runner.temp }}/standards-twig-vendor/autoload.php
TWIG_EVALUATION_TEMP: ${{ runner.temp }}
- run: git diff --exit-code
- name: Retain the reviewed PHP 8.3 build
if: matrix.php == '8.3'
compiled:
needs: [build, tests, runtime]
if: always() && needs.build.result != 'skipped'
runs-on: ubuntu-latest
outputs:
artifact: ${{ needs.build.outputs.artifact }}
steps:
- name: Require successful source and artifact qualification
env:
BUILD: ${{ needs.build.result }}
TESTS: ${{ needs.tests.result }}
RUNTIME: ${{ needs.runtime.result }}
run: |
test "$BUILD" = success && test "$TESTS" = success && test "$RUNTIME" = success
- if: github.event_name == 'pull_request' && needs.build.outputs.stale == 'true'
uses: actions/[email protected]
with:
artifact-ids: ${{ needs.build.outputs.artifact }}
merge-multiple: true
path: ${{ runner.temp }}/phar
- name: Retain only a fully qualified update
if: github.event_name == 'pull_request' && needs.build.outputs.stale == 'true'
uses: actions/upload-artifact@v7
with:
name: code-standards-${{ steps.parity.outputs.stale == 'true' && 'update-' || '' }}${{ github.event.pull_request.head.sha || github.sha }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/code-standards
name: code-standards-update-${{ github.event.pull_request.head.sha || github.sha }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/phar/code-standards
compression-level: 0
if-no-files-found: error
- name: Require the compiled refresh to pass on its own commit
if: steps.parity.outputs.stale == 'true'
- name: Require the refresh to pass before merge
if: github.event_name == 'pull_request' && needs.build.outputs.stale == 'true'
run: |
echo 'The committed executable is stale. The trusted refresh workflow may update this same-repository PR; CI must pass again on that commit.' >&2
echo 'The executable needs the qualified update. CI must pass on the refreshed commit before merge.' >&2
exit 1
Loading
Loading