From 9e2851091638bc105c5b27e60b646245c10fa84e Mon Sep 17 00:00:00 2001 From: Tyler Collins Date: Fri, 20 Mar 2026 17:34:35 -0600 Subject: [PATCH 1/6] chore: add devcontainer contributor workflow --- .circleci/config.yml | 98 --------------------------------- .devcontainer/Dockerfile | 20 +++++++ .devcontainer/devcontainer.json | 21 +++++++ .github/workflows/ci.yml | 84 ++++++++++++++++++++++++++++ CONTRIBUTING.md | 28 ++++++++++ README.md | 12 +++- 6 files changed, 163 insertions(+), 100 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .github/workflows/ci.yml create mode 100644 CONTRIBUTING.md diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 331731d4..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,98 +0,0 @@ -version: 2.1 - -workflows: - version: 2 - - main: - jobs: - - lintSyntax - - lintStaticAnalysis - - checkBcBreaks - - test80 - - test81 - - test82 - - test83 - - test84 - -jobs: - lintStaticAnalysis: - docker: - - image: cimg/php:8.1 - steps: - - checkout - - run: - name: "Install dependencies" - command: sudo composer self-update && composer install -n --prefer-dist - - run: - name: Static analysis - command: composer run lint-static-analysis - - lintSyntax: - docker: - - image: cimg/php:8.1 - steps: - - checkout - - run: - name: "Install dependencies" - command: sudo composer self-update && composer install -n --prefer-dist - - run: - name: Install php-cs-fixer - command: mkdir -p tools/php-cs-fixer && composer require --working-dir=tools/php-cs-fixer friendsofphp/php-cs-fixer - - run: - name: Run syntax test - command: tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation -v - - checkBcBreaks: - docker: - - image: cimg/php:8.1 - steps: - - checkout - - run: - name: "Install dependencies" - command: sudo composer self-update && composer install -n --prefer-dist - - run: - name: Check for backwards-compatibility breaks - command: composer run test-for-bc-breaks || true - - - test80: - docker: - - image: cimg/php:8.0 - steps: - - checkout - - run: { name: "Install dependencies", command: "sudo composer self-update && composer install -n --prefer-dist" } - - run: { name: "Test suite", command: "composer test-quick-fail" } - - test81: - docker: - - image: cimg/php:8.1 - steps: - - checkout - - run: { name: "Install dependencies", command: "sudo composer self-update && composer install -n --prefer-dist" } - - run: { name: "Test suite", command: "composer test-quick-fail" } - - test82: - docker: - - image: cimg/php:8.2 - steps: - - checkout - - run: { name: "Install dependencies", command: "sudo composer self-update && composer install -n --prefer-dist" } - # This test is knee-kapped for now, since a PHP bug causes the tests to segfault. See v7.0.0 changelog. - - run: { name: "Test suite", command: "composer test-quick-fail" } - - test83: - docker: - - image: cimg/php:8.3 - steps: - - checkout - - run: { name: "Install dependencies", command: "sudo composer self-update && composer install -n --prefer-dist" } - - run: { name: "Test suite", command: "composer test-quick-fail" } - - test84: - docker: - - image: cimg/php:8.4 - steps: - - checkout - - run: { name: "Install dependencies", command: "sudo composer self-update && composer install -n --prefer-dist" } - - run: { name: "Test suite", command: "composer test-quick-fail" } - diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..f72faf28 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,20 @@ +ARG PHP_VERSION=8.1 +FROM php:${PHP_VERSION}-cli + +RUN groupadd --gid 1000 vscode \ + && useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash vscode \ + && apt-get update \ + && export DEBIAN_FRONTEND=noninteractive \ + && apt-get install -y --no-install-recommends \ + curl \ + git \ + libicu-dev \ + libonig-dev \ + libxml2-dev \ + libzip-dev \ + unzip \ + zip \ + && docker-php-ext-install -j"$(nproc)" bcmath dom intl mbstring soap xml zip \ + && curl -fsSL https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ + && git config --system --add safe.directory '*' \ + && rm -rf /var/lib/apt/lists/* diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..395895a9 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,21 @@ +{ + "name": "contentful.php", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": { + "PHP_VERSION": "${localEnv:PHP_VERSION:8.1}" + } + }, + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "remoteUser": "vscode", + "postCreateCommand": "composer install -n --prefer-dist", + "customizations": { + "vscode": { + "extensions": [ + "bmewburn.vscode-intelephense-client", + "xdebug.php-debug" + ] + } + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..7b128c69 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,84 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + lint-syntax: + name: Lint syntax (PHP 8.1) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run syntax checks in dev container + uses: devcontainers/ci@v0.3 + env: + PHP_VERSION: "8.1" + with: + push: never + runCmd: >- + bash -lc "mkdir -p tools/php-cs-fixer && + composer require --working-dir=tools/php-cs-fixer + friendsofphp/php-cs-fixer && + tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run + --stop-on-violation -v" + + static-analysis: + name: Static analysis (PHP 8.1) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run static analysis in dev container + uses: devcontainers/ci@v0.3 + env: + PHP_VERSION: "8.1" + with: + push: never + runCmd: composer run lint-static-analysis + + backwards-compatibility: + name: Backwards compatibility (PHP 8.1) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check backwards compatibility in dev container + uses: devcontainers/ci@v0.3 + env: + PHP_VERSION: "8.1" + with: + push: never + runCmd: bash -lc "composer run test-for-bc-breaks || true" + + test: + name: Test (PHP ${{ matrix.php-version }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-version: ["8.0", "8.1", "8.2", "8.3", "8.4"] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run test suite in dev container + uses: devcontainers/ci@v0.3 + env: + PHP_VERSION: ${{ matrix.php-version }} + with: + push: never + runCmd: composer test-quick-fail diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..1c01eaa5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,28 @@ +# Contributing + +Thanks for helping improve `contentful.php`. + +## Development with Dev Containers + +This repository includes a `.devcontainer` configuration for a reproducible local setup. GitHub Actions uses the same devcontainer configuration for CI. + +1. Install Docker and a devcontainer-compatible editor. Visual Studio Code with the Dev Containers extension works well. +2. Open the repository in the dev container and wait for the post-create setup to finish. +3. Verify the environment: + +```bash +composer test-quick-fail +``` + +## Other Useful Commands + +```bash +composer run lint-static-analysis +composer run test-for-bc-breaks +``` + +## Pull Requests + +1. Fork the repository and create a branch for your change. +2. Run the relevant checks from the dev container. +3. Open a pull request with a short summary of the change and any follow-up context. diff --git a/README.md b/README.md index 47ea06d6..9323e95d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ [![Packagist](https://img.shields.io/packagist/v/contentful/contentful.svg?style=for-the-badge)](https://packagist.org/packages/contentful/contentful) [![PHP version](https://img.shields.io/packagist/php-v/contentful/contentful.svg?style=for-the-badge)](https://packagist.org/packages/contentful/contentful) [![Packagist](https://img.shields.io/github/license/contentful/contentful.php.svg?style=for-the-badge)](https://packagist.org/packages/contentful/contentful) -[![CircleCI](https://circleci.com/gh/contentful/contentful.php.svg?style=shield)](https://circleci.com/gh/contentful/contentful.php) +[![CI](https://github.com/contentful/contentful.php/actions/workflows/ci.yml/badge.svg)](https://github.com/contentful/contentful.php/actions/workflows/ci.yml) > PHP library for the Contentful [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/) and [Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/). It helps you to easily access your Content stored in Contentful with your PHP applications. @@ -200,7 +200,15 @@ For details about how to upgrade from version 2.x to version 3, please check the [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?maxAge=31557600)](http://makeapullrequest.com) -**Important**: Right now, the API has `php-vcr` as a development dependency, which does not officially support PHP8 yet. If you want to develop on PHP8, you will need to install the dependencies with `composer install --ignore-platform-reqs` to overwrite this requirement. +For a reproducible local setup, open this repository in its included dev container. The container installs the project dependencies automatically when it is created. + +After the container is ready, run: + +```bash +composer test-quick-fail +``` + +See [CONTRIBUTING.md](CONTRIBUTING.md) for the full contributor workflow. ## License From 2d12faf23ebba2267ce6e76714ebc10cc5c28ee7 Mon Sep 17 00:00:00 2001 From: Tyler Collins Date: Fri, 20 Mar 2026 17:58:52 -0600 Subject: [PATCH 2/6] fix: restore PHP matrix devcontainer checks --- .devcontainer/devcontainer.json | 2 +- .devcontainer/post-create.sh | 25 +++++++++++++++++++++++++ .github/workflows/ci.yml | 2 +- .github/workflows/codeql.yml | 32 -------------------------------- composer.json | 2 +- src/Resource/DeletedAsset.php | 2 +- 6 files changed, 29 insertions(+), 36 deletions(-) create mode 100755 .devcontainer/post-create.sh delete mode 100644 .github/workflows/codeql.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 395895a9..35f002cb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,7 +9,7 @@ }, "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", "remoteUser": "vscode", - "postCreateCommand": "composer install -n --prefer-dist", + "postCreateCommand": ".devcontainer/post-create.sh", "customizations": { "vscode": { "extensions": [ diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100755 index 00000000..c94c0ad0 --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +temp_composer="composer.devcontainer.json" +temp_lock="composer.devcontainer.lock" + +cleanup() { + rm -f "$temp_composer" "$temp_lock" +} + +trap cleanup EXIT + +php <<'PHP' + Date: Fri, 20 Mar 2026 18:07:49 -0600 Subject: [PATCH 3/6] fix: align PHP syntax checks with repo validation --- .github/workflows/ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caba3c0e..3beb6cf8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,11 +25,7 @@ jobs: with: push: never runCmd: >- - bash -lc "mkdir -p tools/php-cs-fixer && - composer require --working-dir=tools/php-cs-fixer - friendsofphp/php-cs-fixer && - tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run - --stop-on-violation -v" + bash -lc "git ls-files -z '*.php' | xargs -0 -n1 php -l" static-analysis: name: Static analysis (PHP 8.1) From b372af745df3efa2d3f260f1043880ed60c91df5 Mon Sep 17 00:00:00 2001 From: Tyler Collins Date: Fri, 20 Mar 2026 19:16:37 -0600 Subject: [PATCH 4/6] fix: replace deprecated workflow runtimes --- .github/workflows/ci.yml | 49 +++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3beb6cf8..75630129 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,50 +14,55 @@ jobs: name: Lint syntax (PHP 8.1) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 + - name: Install devcontainer CLI + run: npm install -g @devcontainers/cli@0 + - name: Run syntax checks in dev container - uses: devcontainers/ci@v0.3 env: PHP_VERSION: "8.1" - with: - push: never - runCmd: >- - bash -lc "git ls-files -z '*.php' | xargs -0 -n1 php -l" + run: | + devcontainer up --workspace-folder . + devcontainer exec --workspace-folder . bash -lc "git ls-files -z '*.php' | xargs -0 -n1 php -l" static-analysis: name: Static analysis (PHP 8.1) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 + - name: Install devcontainer CLI + run: npm install -g @devcontainers/cli@0 + - name: Run static analysis in dev container - uses: devcontainers/ci@v0.3 env: PHP_VERSION: "8.1" - with: - push: never - runCmd: composer run lint-static-analysis + run: | + devcontainer up --workspace-folder . + devcontainer exec --workspace-folder . bash -lc "composer run lint-static-analysis" backwards-compatibility: name: Backwards compatibility (PHP 8.1) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 + - name: Install devcontainer CLI + run: npm install -g @devcontainers/cli@0 + - name: Check backwards compatibility in dev container - uses: devcontainers/ci@v0.3 env: PHP_VERSION: "8.1" - with: - push: never - runCmd: bash -lc "composer install -n --prefer-dist && composer run test-for-bc-breaks || true" + run: | + devcontainer up --workspace-folder . + devcontainer exec --workspace-folder . bash -lc "composer install -n --prefer-dist && composer run test-for-bc-breaks || true" test: name: Test (PHP ${{ matrix.php-version }}) @@ -67,14 +72,16 @@ jobs: matrix: php-version: ["8.0", "8.1", "8.2", "8.3", "8.4"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 + - name: Install devcontainer CLI + run: npm install -g @devcontainers/cli@0 + - name: Run test suite in dev container - uses: devcontainers/ci@v0.3 env: PHP_VERSION: ${{ matrix.php-version }} - with: - push: never - runCmd: composer test-quick-fail + run: | + devcontainer up --workspace-folder . + devcontainer exec --workspace-folder . bash -lc "composer test-quick-fail" From 82521b9307c0269805f8f881c04046b01f962417 Mon Sep 17 00:00:00 2001 From: Tyler Collins Date: Fri, 20 Mar 2026 19:23:30 -0600 Subject: [PATCH 5/6] docs: explain devcontainer bootstrap script --- .devcontainer/post-create.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh index c94c0ad0..a63ef263 100755 --- a/.devcontainer/post-create.sh +++ b/.devcontainer/post-create.sh @@ -10,6 +10,10 @@ cleanup() { trap cleanup EXIT +# Install a devcontainer-only dependency set without the BC checker. This repo +# does not commit a lockfile, and roave/backward-compatibility-check can force +# incompatible resolutions during post-create; the dedicated BC CI job still +# exercises that tooling separately. php <<'PHP' Date: Fri, 20 Mar 2026 19:38:23 -0600 Subject: [PATCH 6/6] docs: clarify devcontainer workflows --- CONTRIBUTING.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c01eaa5..8269d3d8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,9 +6,20 @@ Thanks for helping improve `contentful.php`. This repository includes a `.devcontainer` configuration for a reproducible local setup. GitHub Actions uses the same devcontainer configuration for CI. -1. Install Docker and a devcontainer-compatible editor. Visual Studio Code with the Dev Containers extension works well. -2. Open the repository in the dev container and wait for the post-create setup to finish. -3. Verify the environment: +### Visual Studio Code + +Open the repository in Visual Studio Code, install the Dev Containers extension if needed, then run `Dev Containers: Reopen in Container`. Wait for the container build and post-create setup to finish. + +### Terminal or other editors + +Install Docker and the Dev Container CLI (`npm install -g @devcontainers/cli`). From the repository root, run: + +```bash +devcontainer up --workspace-folder . +devcontainer exec --workspace-folder . bash +``` + +### Verify the environment ```bash composer test-quick-fail