diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5508cdc --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,62 @@ +name: CI + +on: push + +jobs: + php-tests: + continue-on-error: ${{ matrix.experimental }} + strategy: + matrix: + experimental: [false] + php: + - 7.4 + - 8.0 + - 8.1 + - 8.2 + - 8.3 + - 8.4 + - 8.5 + include: + - php: 8.6 + prefer: stable + experimental: true + prefer: + - lowest + - stable + fail-fast: false + + name: Test on PHP ${{ matrix.php }} with ${{ matrix.prefer }} composer prefer option + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: Check PHP Version + run: php -v + + - name: Xdebug Action + uses: MilesChou/docker-xdebug@master + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v4 + with: + path: vendor + key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.prefer }}- + restore-keys: | + ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ matrix.prefer }}- + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: composer update --prefer-${{ matrix.prefer }} --prefer-dist --no-progress + + - name: Run tests + run: vendor/bin/phpunit --coverage-clover=coverage.xml + + - name: Upload coverage + run: bash <(curl -s https://codecov.io/bash) diff --git a/Dockerfile b/Dockerfile index e12294c..ee7a471 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM php:8.3-cli +ARG PHP_VERSION=8.4 + +FROM php:${PHP_VERSION}-cli # Composer requirements begin RUN apt-get update \ @@ -8,7 +10,7 @@ RUN apt-get update \ RUN docker-php-ext-install zip -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer # Composer requirements end diff --git a/Makefile b/Makefile index 33194be..07c98e7 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PATH := $(shell pwd)/bin:$(PATH) -$(shell cp --update=none dev.env .env) +$(shell cp -n dev.env .env) include .env install: build diff --git a/composer.json b/composer.json index aca7075..1befd92 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "license": "BSD-2-Clause", "authors": [], "require-dev": { - "phpunit/phpunit": "^12.1" + "phpunit/phpunit": "*" }, "autoload": { "psr-4": { diff --git a/dev.env b/dev.env index 9c44aa0..9504293 100644 --- a/dev.env +++ b/dev.env @@ -1,3 +1,4 @@ PHP_DEV_IMAGE=samizdam/skeleton/php-dev +PHP_VERSION=8.4 # default tag for images, replaced with CI environment value: branch or tag name REVISION=master diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 0000000..e69de29