From 0a81f7c14a7ab0c519c5d014d5143322e87feeec Mon Sep 17 00:00:00 2001 From: Scott Aubrey Date: Fri, 18 Oct 2024 08:36:21 +0100 Subject: [PATCH] Stop testing the library with the lowest dependencies While the goal is laudable, by we arbitrarily restrict the window of supported versions of PHP by allowing the lowest supported versions of a library's dependency (which may have an even lower ceiling than us) to dictate our maximum supported version via the test suite. Since we're now testing against multiple versions of PHP, that will provide a better show of our range of supported PHP versions, and it's down to consuming libraries to make sure they are compatible with any sub-dependency requirements --- .dockerignore | 4 ++++ .github/workflows/ci.yaml | 10 ++++------ Dockerfile | 9 ++++++++- Makefile | 24 ++++++++++-------------- project_tests.sh | 9 +-------- 5 files changed, 27 insertions(+), 29 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..1ef8ea08 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +/build/ +/composer.lock +/.php_cs.cache +/vendor/ diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6158748d..399f0328 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,20 +16,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php_version: [7.1, 7.2, 7.3, 7.4] - task: ['test', 'test-lowest'] + php_version: ["7.1", "7.2", "7.3", "7.4"] steps: - uses: actions/checkout@v4 - name: Run tests - run: make PHP_VERSION=${{ matrix.php_version }} ${{ matrix.task }} + run: make PHP_VERSION=${{ matrix.php_version }} test tests-future-versions: runs-on: ubuntu-latest strategy: matrix: - php_version: [8.0, 8.1, 8.2, 8.3] - task: ['test', 'test-lowest'] + php_version: ["8.0", "8.1", "8.2", "8.3"] steps: - uses: actions/checkout@v4 - name: Run tests against all major versions of PHP - run: make PHP_VERSION=${{ matrix.php_version }} ${{ matrix.task }} + run: make PHP_VERSION=${{ matrix.php_version }} test continue-on-error: true diff --git a/Dockerfile b/Dockerfile index 3bd78acb..3ed8688e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,12 @@ -ARG PHP_VERSION=7.4 +ARG PHP_VERSION=latest FROM php:${PHP_VERSION} RUN apt-get update && apt-get install -y git unzip && rm -rf /var/lib/apt/lists/* COPY --from=composer:2.2 /usr/bin/composer /usr/bin/composer + +WORKDIR /code + +COPY composer.json composer.json +RUN composer install + +COPY . . diff --git a/Makefile b/Makefile index 5cef6930..2fabf9f0 100644 --- a/Makefile +++ b/Makefile @@ -4,31 +4,27 @@ build: docker buildx build --build-arg=PHP_VERSION=$(PHP_VERSION) -t php-composer:$(PHP_VERSION) . lint: build - docker run --rm -v ./:/code -v/code/vendor php-composer:$(PHP_VERSION) bash -c 'cd /code && composer update && vendor/bin/phpcs --standard=phpcs.xml.dist --warning-severity=0 -p src/ test/' + docker run --rm -v ./:/code -v/code/vendor php-composer:$(PHP_VERSION) bash -c 'vendor/bin/phpcs --standard=phpcs.xml.dist --warning-severity=0 -p src/ scripts/ test/' test: build lint - docker run --rm -v ./:/code -e dependencies=highest -v/code/vendor php-composer:$(PHP_VERSION) bash -c 'cd /code && composer update && ./project_tests.sh' - -test-lowest: build lint - docker run --rm -v ./:/code -e dependencies=lowest -v/code/vendor php-composer:$(PHP_VERSION) bash -c 'cd /code && ./project_tests.sh' - + docker run --rm -v ./:/code -v/code/vendor php-composer:$(PHP_VERSION) bash -c './project_tests.sh' test-7.1: - @$(MAKE) PHP_VERSION=7.1 test test-lowest + @$(MAKE) PHP_VERSION=7.1 test test-7.2: - @$(MAKE) PHP_VERSION=7.2 test test-lowest + @$(MAKE) PHP_VERSION=7.2 test test-7.3: - @$(MAKE) PHP_VERSION=7.3 test test-lowest + @$(MAKE) PHP_VERSION=7.3 test test-7.4: - @$(MAKE) PHP_VERSION=7.4 test test-lowest + @$(MAKE) PHP_VERSION=7.4 test test-8.0: - @$(MAKE) PHP_VERSION=8.0 test test-lowest + @$(MAKE) PHP_VERSION=8.0 test test-8.1: - @$(MAKE) PHP_VERSION=8.1 test test-lowest + @$(MAKE) PHP_VERSION=8.1 test test-8.2: - @$(MAKE) PHP_VERSION=8.2 test test-lowest + @$(MAKE) PHP_VERSION=8.2 test test-8.3: - @$(MAKE) PHP_VERSION=8.3 test test-lowest + @$(MAKE) PHP_VERSION=8.3 test test-all: test-7.1 test-7.2 test-7.3 test-7.4 test-8.0 test-8.1 test-8.2 test-8.3 diff --git a/project_tests.sh b/project_tests.sh index 4470a220..6a639985 100755 --- a/project_tests.sh +++ b/project_tests.sh @@ -2,12 +2,5 @@ #!/bin/bash set -e -: "${dependencies:?Need to set dependencies environment variable}" -if [ "$dependencies" = "lowest" ]; then - composer update --prefer-lowest --no-interaction - vendor/bin/phpcs --standard=phpcs.xml.dist --warning-severity=0 -p src/ - vendor/bin/phpcs --standard=phpcs.xml.dist --warning-severity=0 -p scripts/ test/ -else - composer update --no-interaction -fi +vendor/bin/phpcs --standard=phpcs.xml.dist --warning-severity=0 -p src/ scripts/ test/ vendor/bin/phpunit --log-junit="build/${dependencies}-phpunit.xml"