Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 0 additions & 98 deletions .circleci/config.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/*
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "contentful-management.php",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"PHP_VERSION": "${localEnv:PHP_VERSION:8.1}"
}
},
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"remoteUser": "vscode",
"postCreateCommand": ".devcontainer/post-create.sh",
"customizations": {
"vscode": {
"extensions": [
"bmewburn.vscode-intelephense-client",
"xdebug.php-debug"
]
}
}
}
29 changes: 29 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/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

# 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'
<?php

$composer = json_decode(file_get_contents('composer.json'), true, 512, JSON_THROW_ON_ERROR);
unset($composer['require-dev']['roave/backward-compatibility-check']);

file_put_contents(
'composer.devcontainer.json',
json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL
);
PHP

COMPOSER="$temp_composer" composer install -n --prefer-dist
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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@v5
with:
fetch-depth: 0

- name: Install devcontainer CLI
run: npm install -g @devcontainers/cli@0

- name: Run syntax checks in dev container
env:
PHP_VERSION: "8.1"
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@v5
with:
fetch-depth: 0

- name: Install devcontainer CLI
run: npm install -g @devcontainers/cli@0

- name: Run static analysis in dev container
env:
PHP_VERSION: "8.1"
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@v5
with:
fetch-depth: 0

- name: Install devcontainer CLI
run: npm install -g @devcontainers/cli@0

- name: Check backwards compatibility in dev container
env:
PHP_VERSION: "8.1"
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 }})
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@v5
with:
fetch-depth: 0

- name: Install devcontainer CLI
run: npm install -g @devcontainers/cli@0

- name: Run test suite in dev container
env:
PHP_VERSION: ${{ matrix.php-version }}
run: |
devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . bash -lc "composer test-quick-fail"
32 changes: 0 additions & 32 deletions .github/workflows/codeql.yml

This file was deleted.

39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Contributing

Thanks for helping improve `contentful-management.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.

### 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
```

## 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.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Packagist](https://img.shields.io/packagist/v/contentful/contentful-management.svg?style=for-the-badge)](https://packagist.org/packages/contentful/contentful-management)
[![PHP version](https://img.shields.io/packagist/php-v/contentful/contentful-management.svg?style=for-the-badge)](https://packagist.org/packages/contentful/contentful-management)
[![Packagist](https://img.shields.io/github/license/contentful/contentful-management.php.svg?style=for-the-badge)](https://packagist.org/packages/contentful/contentful-management.php)
[![CircleCI](https://circleci.com/gh/contentful/contentful-management.php.svg?style=shield)](https://circleci.com/gh/contentful/contentful-management.php)
[![CI](https://github.com/contentful/contentful-management.php/actions/workflows/ci.yml/badge.svg)](https://github.com/contentful/contentful-management.php/actions/workflows/ci.yml)

> PHP SDK for [Contentful's](https://www.contentful.com) Content Management API. The SDK requires at least PHP 7.2 or PHP 8.0 and up.

Expand Down Expand Up @@ -597,9 +597,17 @@ $proxy->create($env); //this call will retry two times (so three calls couting t

If the retry should happen in more than 60 seconds (as defined by the X-Contentful-RateLimit-Second-Remaining header [here](https://www.contentful.com/developers/docs/references/content-management-api/#/introduction/api-rate-limits) ), the call will throw a RateWaitTooLongException exception. This was implemented so that your scripts do not run for too long.

## Contributinng
## Contributing

PRs are welcome! If you want to develop locally, however, you will need to install with `--ignore-platform-reqs`, as one of the libraries used for testing does currently not officially support PHP8.
PRs are welcome. 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.


## About Contentful
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"test": "vendor/bin/phpunit",
"test-quick-fail": "php vendor/bin/phpunit --stop-on-error --stop-on-failure -v",
"test-for-bc-breaks": "php -d memory_limit=-1 vendor/bin/roave-backward-compatibility-check",
"lint-static-analysis": "php vendor/bin/phpstan analyse src --level=5"
"lint-static-analysis": "php -d memory_limit=-1 vendor/bin/phpstan analyse src --level=5"
},
"suggest": {
"nikic/php-parser": "Allows generating content type classes"
Expand Down
2 changes: 1 addition & 1 deletion scripts/php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

return function (string $packageName, bool $usePhp7, array $directories, array $exclude = []): Config {
return static function (string $packageName, bool $usePhp7, array $directories, array $exclude = []): Config {
$year = \date('Y');

$fileHeaderComment = <<<COMMENT
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Command/GenerateEntryClassesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function configure()
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$spaceId = $input->getOption('space-id');
$environmentId = $input->getOption('environment-id');
Expand All @@ -74,7 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$this->writeReport($output, $spaceId, $environmentId, $dir);

return 0;
return Command::SUCCESS;
}

/**
Expand Down
Loading