diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index d43681074..b0adbaffa 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -10,6 +10,14 @@ on: - "development" - "test" - "gravitypdf" + schedule: + - cron: "0 17 * * *" + workflow_dispatch: + +# A push to a pull request cancels the run it replaces. Other events run in a group of their own +concurrency: + group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}" + cancel-in-progress: true jobs: diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 1232ea2f5..4bc2d328b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -7,6 +7,9 @@ on: branches: - "development" - "coverage" + schedule: + - cron: "0 17 * * *" + workflow_dispatch: jobs: diff --git a/.github/workflows/cs.yml b/.github/workflows/cs.yml deleted file mode 100644 index b0dba1ed8..000000000 --- a/.github/workflows/cs.yml +++ /dev/null @@ -1,56 +0,0 @@ -# https://help.github.com/en/categories/automating-your-workflow-with-github-actions - -name: "Coding standard check" - -on: - pull_request: - push: - branches: - - "development" - - "test" - - "gravitypdf" - -jobs: - - cs: - - name: "Coding standard" - - runs-on: ${{ matrix.operating-system }} - - strategy: - matrix: - php-version: - - "7.4" - - operating-system: [ubuntu-latest] - - steps: - - name: "Checkout" - uses: "actions/checkout@v7" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "${{ matrix.php-version }}" - extensions: "mbstring" - tools: composer:v2 - - - name: "Locate Composer cache" - id: composer-cache - shell: bash - run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" - - - name: "Cache Composer downloads" - uses: "actions/cache@v6" - with: - path: "${{ steps.composer-cache.outputs.dir }}" - key: "composer-${{ runner.os }}-php${{ matrix.php-version }}-${{ hashFiles('composer.json') }}" - restore-keys: "composer-${{ runner.os }}-php${{ matrix.php-version }}-" - - - name: "Install dependencies" - run: "composer install --no-interaction --no-progress" - - - name: "CS" - run: composer cs diff --git a/.github/workflows/einvoice-interop.yml b/.github/workflows/einvoice-interop.yml index 964c61cbb..1666fdc17 100644 --- a/.github/workflows/einvoice-interop.yml +++ b/.github/workflows/einvoice-interop.yml @@ -3,13 +3,36 @@ name: "E-invoice interop" on: + # Pull requests run this only when they change one of these paths pull_request: + paths: + - ".github/workflows/einvoice-interop.yml" + - "composer.json" + - "phpunit.xml" + - "src/Invoice/**" + - "src/Pdf/**" + - "src/Utils/**" + - "src/Writer/**" + - "src/Xmp/**" + - "tests/Mpdf/Invoice/**" + - "tests/Mpdf/InteropPackage.php" + - "tests/Mpdf/InvoiceFixtures.php" + - "tests/Mpdf/PageStreams.php" + - "tests/data/invoice/**" push: branches: - "master" - "development" - "test" - "gravitypdf" + schedule: + - cron: "0 17 * * *" + workflow_dispatch: + +# A push to a pull request cancels the run it replaces. Other events run in a group of their own +concurrency: + group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}" + cancel-in-progress: true jobs: @@ -56,7 +79,7 @@ jobs: restore-keys: "composer-${{ runner.os }}-php${{ matrix.php-version }}-einvoice-" - name: "Install dependencies" - run: "composer install --no-interaction --no-progress && composer require --dev ${{ matrix.packages }} --no-interaction --no-progress" + run: "composer require --dev ${{ matrix.packages }} --no-update && composer install --no-interaction --no-progress" - name: "Tests" run: composer test -- --group=interop diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/lint.yml similarity index 60% rename from .github/workflows/static-analysis.yml rename to .github/workflows/lint.yml index 073bb5b85..9540488f8 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,6 @@ # https://help.github.com/en/categories/automating-your-workflow-with-github-actions -name: "Static Analysis check" +name: "Lint" on: pull_request: @@ -10,23 +10,31 @@ on: - "development" - "test" - "gravitypdf" + schedule: + - cron: "0 17 * * *" + workflow_dispatch: + +# A push to a pull request cancels the run it replaces. Other events run in a group of their own +concurrency: + group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}" + cancel-in-progress: true jobs: - stan: + lint: - name: "Static Analysis check" + name: "Lint" - runs-on: ${{ matrix.operating-system }} + runs-on: ubuntu-latest strategy: + fail-fast: false matrix: + # PHPStan reports differ between PHP versions, so it runs on both php-version: - "8.2" - "8.5" - operating-system: [ubuntu-latest] - steps: - name: "Checkout" uses: "actions/checkout@v7" @@ -52,7 +60,13 @@ jobs: restore-keys: "composer-${{ runner.os }}-php${{ matrix.php-version }}-phpstan-" - name: "Install dependencies" - run: "composer install --no-interaction --no-progress && composer require \"phpstan/phpstan:^2.0\"" + id: install + run: "composer require \"phpstan/phpstan:^2.0\" --no-update && composer install --no-interaction --no-progress" + + - name: "Coding standard" + if: matrix.php-version == '8.2' + run: composer cs - - name: "Static Analysis check" + - name: "Static analysis" + if: "!cancelled() && steps.install.outcome == 'success'" run: vendor/bin/phpstan --no-progress diff --git a/.github/workflows/pdfx4-policy.yml b/.github/workflows/pdfx4-policy.yml index 7f2c7958f..f2e6a1ae5 100644 --- a/.github/workflows/pdfx4-policy.yml +++ b/.github/workflows/pdfx4-policy.yml @@ -6,13 +6,35 @@ name: "PDF/X-4 Policy" on: + # Pull requests run this only when they change one of these paths pull_request: + paths: + - ".github/workflows/pdfx4-policy.yml" + - "composer.json" + - "data/iccprofiles/**" + - "src/Color/**" + - "src/Fonts/Color/**" + - "src/Gradient.php" + - "src/Image/**" + - "src/Pdf/**" + - "src/Writer/**" + - "src/Xmp/**" + - "tests/data/icc/**" + - "utils/verapdf/**" push: branches: - "master" - "development" - "test" - "gravitypdf" + schedule: + - cron: "0 17 * * *" + workflow_dispatch: + +# A push to a pull request cancels the run it replaces. Other events run in a group of their own +concurrency: + group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}" + cancel-in-progress: true jobs: diff --git a/.github/workflows/snapshots.yml b/.github/workflows/snapshots.yml index f09fbcaa9..4b1a80b62 100644 --- a/.github/workflows/snapshots.yml +++ b/.github/workflows/snapshots.yml @@ -10,6 +10,14 @@ on: - "development" - "test" - "gravitypdf" + schedule: + - cron: "0 17 * * *" + workflow_dispatch: + +# A push to a pull request cancels the run it replaces. Other events run in a group of their own +concurrency: + group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}" + cancel-in-progress: true jobs: @@ -43,6 +51,7 @@ jobs: run: | # Older policies forbid the PDF coder. Snapshots only rasterise when they differ, so read one now to fail early sudo sed -i 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/' /etc/ImageMagick-*/policy.xml + # shellcheck disable=SC2016 php -r '$i = new Imagick(); $i->setResolution(120, 120); $i->readImage("tests/data/snapshots/fixed-position-html.pdf"); printf("%s read %d page of %dx%d px\n", Imagick::getVersion()["versionString"], $i->getNumberImages(), $i->getImageWidth(), $i->getImageHeight());' - name: "Locate Composer cache" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a005d661a..fe4d9eb31 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,12 +4,21 @@ name: "Tests" on: pull_request: + types: [opened, synchronize, reopened, labeled] push: branches: - "master" - "development" - "test" - "gravitypdf" + schedule: + - cron: "0 17 * * *" + workflow_dispatch: + +# A push to a pull request cancels the run it replaces. Other events, and a label other than full-ci, run in a group of their own +concurrency: + group: "${{ github.workflow }}-${{ (github.event.action != 'labeled' || github.event.label.name == 'full-ci') && github.event.pull_request.number || github.run_id }}" + cancel-in-progress: true jobs: @@ -17,25 +26,29 @@ jobs: name: "Tests" + if: github.event.action != 'labeled' || github.event.label.name == 'full-ci' + runs-on: ${{ matrix.operating-system }} strategy: fail-fast: false - matrix: - php-version: - - "5.6" - - "7.0" - - "7.1" - - "7.2" - - "7.3" - - "7.4" - - "8.0" - - "8.1" - - "8.2" - - "8.3" - - "8.4" - - "8.5" - operating-system: [ubuntu-latest, windows-latest] + # A pull request without the full-ci label runs 5.6 and 8.5 on both systems, and 7.4 and 8.0 on Ubuntu + matrix: >- + ${{ fromJSON( + (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) + && '{ + "php-version": ["5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4", "8.5"], + "operating-system": ["ubuntu-latest", "windows-latest"] + }' + || '{ + "php-version": ["5.6", "7.4", "8.0", "8.5"], + "operating-system": ["ubuntu-latest", "windows-latest"], + "exclude": [ + {"php-version": "7.4", "operating-system": "windows-latest"}, + {"php-version": "8.0", "operating-system": "windows-latest"} + ] + }' + ) }} steps: - name: "Checkout" @@ -48,7 +61,8 @@ jobs: php-version: "${{ matrix.php-version }}" extensions: "mbstring, gd, bcmath, bz2, fileinfo" tools: composer:v2 - ini-values: error_reporting=-1 + # setup-php turns the JIT on for PHP 8, and on 8.0, 8.4 and 8.5 it corrupts OpenType positioning in the snapshots + ini-values: error_reporting=-1, opcache.enable_cli=1, opcache.jit=disable - name: "Locate Composer cache" id: composer-cache diff --git a/CHANGELOG-GRAVITYPDF.md b/CHANGELOG-GRAVITYPDF.md index 9ace4854d..32125b486 100644 --- a/CHANGELOG-GRAVITYPDF.md +++ b/CHANGELOG-GRAVITYPDF.md @@ -324,10 +324,13 @@ These changes do not change output. * **UTF-8 decoding.** A valid UTF-8 string is decoded with mbstring. [#364] * **Snapshot tests.** Snapshot tests compare bytes first, then PDF objects, then pixels. Snapshot documents carry nothing of the machine that made them. [#72] * **Data scripts.** Composer scripts regenerate the Unicode, emoji, joining, language system, font cache, subset, shaping and grey profile data, and update snapshots. -* **CI.** [#5] [#310] [#317] [#376] [#377] +* **CI.** [#5] [#310] [#317] [#376] [#377] [#615] * CI runs on the `gravitypdf` branch, caches Composer downloads and uses current action versions. * It checks PDF/A and PDF/X-4 output with veraPDF, and tests e-invoices against the XML packages `composer.json` suggests. * The test suite runs under a 512M memory limit. + * Pull requests run 6 of the 24 PHP and OS test jobs unless labelled `full-ci`. Pushes to `gravitypdf`, a nightly run and a manual run get all 24. A newer push to a pull request cancels the run it replaces. + * Every workflow, code coverage included, also runs nightly on `gravitypdf` and can be run by hand. + * The coding standard and PHPStan run as one Lint workflow. The e-invoice and PDF/X-4 checks run on a pull request only when it changes the code they cover. * **PHPStan.** Fixes for newer PHP versions and PHPStan 2.2.15. [#6] [#295] [#319] [#451] * **Branch alias.** The Composer branch alias maps `dev-gravitypdf` to `8.x-dev`. [#3] @@ -735,3 +738,4 @@ These changes do not change output. [#564]: https://github.com/GravityPDF/mpdf/pull/564 [#563]: https://github.com/GravityPDF/mpdf/pull/563 [#565]: https://github.com/GravityPDF/mpdf/pull/565 +[#615]: https://github.com/GravityPDF/mpdf/pull/615