Skip to content

feat: input validation and encoding fixes across barcode types, plus … #130

feat: input validation and encoding fixes across barcode types, plus …

feat: input validation and encoding fixes across barcode types, plus … #130

Workflow file for this run

name: check
permissions:
contents: read
# Cancel the superseded pull-request runs.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
on:
push:
branches:
- 'main'
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
workflow_dispatch:
jobs:
test-php:
name: Test on php ${{ matrix.php-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php-version: ["8.2", "8.3", "8.4", "8.5"]
os: [ubuntu-latest]
coverage-extension: [xdebug]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Use php ${{ matrix.php-version }}
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
with:
php-version: ${{ matrix.php-version }}
coverage: ${{ matrix.coverage-extension }}
extensions: xdebug, bcmath, ctype, gd, imagick, pcre
ini-values: display_errors=on, error_reporting=-1, zend.assertions=1
- name: List php modules
run: php -m
- name: List php modules using "no php ini" mode
run: php -m -n
- name: Cache module
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.composer/cache/
key: composer-${{ matrix.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}
restore-keys: composer-${{ matrix.os }}-${{ matrix.php-version }}-
- name: Install dependencies
env:
GH_TOKEN: ${{ github.token }}
run: make deps
- name: Validate composer.json
run: composer validate --strict --no-check-lock
- name: Audit dependencies for known advisories
run: composer audit
- name: Run all tests
run: make qa-coverage
- name: Run all tests without the optional bcmath extension
run: php -d disable_functions=bcadd,bcmul,bcdiv,bcmod vendor/bin/phpunit --no-coverage --stderr test
- name: Run the example
run: php example/index.php > /dev/null
# Install into a throwaway prefix and load the library through the shipped autoloader.
- name: Packaging smoke test
if: matrix.os == 'ubuntu-latest'
run: |
DESTDIR="$(mktemp -d)"
make install DESTDIR="$DESTDIR"
cat > "$DESTDIR/smoke.php" <<'SMOKE'
<?php
require \getenv('DESTDIR') . '/usr/share/php/Com/Tecnick/Barcode/autoload.php';
foreach ([
'Com\Tecnick\Barcode\Barcode',
'Com\Tecnick\Barcode\Exception',
'Com\Tecnick\Barcode\Math',
'Com\Tecnick\Barcode\Type',
] as $class) {
if (!\class_exists($class)) {
\fwrite(\STDERR, 'the installed autoloader cannot load ' . $class . \PHP_EOL);
exit(1);
}
}
echo 'installed layout loads every class', \PHP_EOL;
SMOKE
DESTDIR="$DESTDIR" php "$DESTDIR/smoke.php"
- name: Send coverage
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
flags: php-${{ matrix.php-version }}-${{ matrix.os }}
name: php-${{ matrix.php-version }}-${{ matrix.os }}
test-lowest:
name: Test lowest supported dependencies on php 8.2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Use php 8.2
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
with:
php-version: "8.2"
coverage: none
extensions: bcmath, ctype, gd, imagick, pcre
ini-values: display_errors=on, error_reporting=-1, zend.assertions=1
- name: Cache module
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.composer/cache/
key: composer-lowest-${{ hashFiles('composer.json') }}
restore-keys: composer-lowest-
# composer.lock is not committed: pin the bottom of the declared ranges.
- name: Install lowest supported dependencies
env:
GH_TOKEN: ${{ github.token }}
run: composer update --prefer-lowest --prefer-stable --no-interaction
- name: Run unit tests
run: composer run test