Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

415: Update docker setup and php version #13

Merged
merged 11 commits into from
Jan 17, 2025
Merged
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
78 changes: 37 additions & 41 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,53 @@
on: pull_request
name: PR Review
jobs:
test-composer-files:
name: Validate composer
test-composer-install:
name: Validate composer (${{ matrix.php }}) / (${{ matrix.dependency-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: [ '7.4', '8.0' ]
php: [ '8.3', '8.4' ]
dependency-version: [ prefer-lowest, prefer-stable ]
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: json
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Validate composer files
run: |
composer validate composer.json --strict
- name: Ensure dependencies resolve
run: composer validate composer.json --strict

- name: Install dependencies
run: |
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction

php-check-coding-standards:
name: PHP - Check Coding Standards
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '8.3', '8.4' ]
dependency-version: [ prefer-lowest, prefer-stable ]
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: ${{ matrix.php }}
extensions: json
coverage: none
tools: composer:v2
Expand All @@ -51,7 +56,7 @@ jobs:
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -61,16 +66,22 @@ jobs:
composer install --no-interaction --no-progress
- name: PHPCS
run: |
composer check-coding-standards
composer coding-standards-check

unit_tests:
name: Unit tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '8.3', '8.4' ]
dependency-version: [ prefer-lowest, prefer-stable ]
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: ${{ matrix.php }}
extensions: json
coverage: none
tools: composer:v2
Expand All @@ -79,7 +90,7 @@ jobs:
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -90,27 +101,12 @@ jobs:
- name: Unit tests
run: php vendor/bin/phpunit tests --coverage-clover=coverage/unit.xml

markdownlint:
name: markdownlint
markdown-lint:
name: Markdown lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn packages
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Yarn install
uses: actions/setup-node@v2
with:
node-version: '12'
- run: yarn install
- name: markdownlint
run: yarn markdownlint README.md
uses: actions/checkout@v4

- name: Markdown lint
run: docker run --rm --volume "$PWD:/md" peterdavehello/markdownlint markdownlint --ignore vendor '**/*.md'
13 changes: 13 additions & 0 deletions .markdownlint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"default": true,
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
"line-length": {
"line_length": 120,
"code_blocks": false,
"tables": false
},
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
"no-duplicate-heading": {
"siblings_only": true
}
}
7 changes: 7 additions & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#ignoring-files
vendor/
LICENSE.md

# Local Variables:
# mode: gitignore
# End:
1 change: 0 additions & 1 deletion .php-version

This file was deleted.

72 changes: 30 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

Composer package for the Azure AD Delta Sync flow.

## References

* [Microsoft Graph group members](https://docs.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=http)

## Usage

If you are looking to use this in a Symfony or Drupal project you should use
either:

* Symfony: [itk-dev/adgangsstyring-bundle](https://github.com/itk-dev/adgangsstyring-bundle)
* Drupal: [itk-dev/adgangsstyring_drupal](https://github.com/itk-dev/adgangsstyring_drupal)
- Symfony: [itk-dev/azure-ad-delta-sync-symfony](https://github.com/itk-dev/azure-ad-delta-sync-symfony)
- Drupal: [itk-dev/azure-ad-delta-sync-drupal](https://github.com/itk-dev/azure-ad-delta-sync-drupal)

### Direct installation

Expand All @@ -28,7 +24,7 @@ To start the flow one needs to call the
`Controller` `run(HandlerInterface $handler)` command.

Therefore, you must create your own handler that implements
`HandlerInterface`.
`HandlerInterface`.

#### Example Usage

Expand Down Expand Up @@ -56,9 +52,6 @@ class SomeHandler implements HandlerInterface
}
```

Be aware that `removeUsersFromDeletionList()` may be called multiple times,
as we are limited to 100 users per request.

To start the flow provide a HTTP Client that implements
[PSR-18](https://www.php-fig.org/psr/psr-18/) `CLientInterface`,
and the required options seen in the example beneath.
Expand All @@ -73,10 +66,9 @@ use ItkDev\AzureAdDeltaSync\Controller;


$options = [
'tenant_id' => 'something.onmicrosoft.com', // Tenant id
'client_id' => 'some_client_id', // Client id assigned by authorizer
'client_secret' => 'some_client_secret', // Client password assigned by authorizer
'group_id' => 'some_group_id', // Group id provided by authorizer
'uri' => 'https://aarhus.../RetrieveProvisioningData/...', // System provisioning uri
'security_key' => 'some_security_key', // Provisioning data security key
'client_secret' => 'some_client_secret', // System provisioning client secret
];

$handler = new SomeHandler();
Expand All @@ -91,18 +83,19 @@ $controller->run($handler);

Note that this package does not do the synchronization
of users, instead it provides a list of all users that
currently are assigned to the group in question.
currently has access to the system in question.

Should the specified group contain no users an exception will be
Should the configured system contain no users an exception will be
thrown. This is to avoid using systems to be under the impression
that every single user should be deleted.

## Development Setup

A `docker-compose.yml` file with a PHP 7.4 image is included in this project.
A `docker-compose.yml` file with a PHP 8.2 image is included in this project.
To install the dependencies you can run

```shell
docker compose pull
docker compose up -d
docker compose exec phpfpm composer install
```
Expand All @@ -119,20 +112,30 @@ docker compose exec phpfpm ./vendor/bin/phpunit tests
The test suite uses [Mocks](https://phpunit.de/manual/6.5/en/test-doubles.html)
for generation of test doubles.

### Check Coding Standard
### Coding Standard

* PHP files (PHP_CodeSniffer)
#### PHP files (PHP_CodeSniffer)

```shell
docker compose exec phpfpm composer check-coding-standards
```
Check PHP coding standards

```shell
docker compose run --rm phpfpm composer install
docker compose run --rm phpfpm composer coding-standards-check
```

Apply coding standard changes

```shell
docker compose run --rm phpfpm composer coding-standards-apply
```

* Markdown files (markdownlint standard rules)
#### Markdown files

```shell
docker run -v ${PWD}:/app itkdev/yarn:latest install
docker run -v ${PWD}:/app itkdev/yarn:latest check-coding-standards
```
```shell
docker run --rm --volume "$PWD:/md" peterdavehello/markdownlint markdownlint '**/*.md'
```shell
docker run --rm --volume "$PWD:/md" peterdavehello/markdownlint markdownlint '**/*.md' --fix
```

### GitHub Actions

Expand All @@ -152,21 +155,6 @@ individual workflow jobs that can be run, e.g.
act -P ubuntu-latest=shivammathur/node:focal pull_request --job phpcsfixer
```

### Apply Coding Standards

* PHP files (PHP_CodeSniffer)

```shell
docker compose exec phpfpm composer apply-coding-standards
```

* Markdown files (markdownlint standard rules)

```shell
docker run -v ${PWD}:/app itkdev/yarn:latest install
docker run -v ${PWD}:/app itkdev/yarn:latest apply-coding-standards
```

## Versioning

We use [SemVer](http://semver.org/) for versioning.
Expand Down
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
}
},
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"ext-json": "*",
"symfony/options-resolver": "^4.4 || ^5.0",
"symfony/options-resolver": "^5.4 || ^6.0",
"psr/http-client": "^1.0",
"nyholm/psr7": "^1.4"
},
Expand All @@ -36,10 +36,10 @@
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1"
},
"scripts": {
"check-coding-standards": [
"coding-standards-check": [
"vendor/bin/phpcs --standard=phpcs.xml.dist"
],
"apply-coding-standards": [
"coding-standards-apply": [
"vendor/bin/phpcbf --standard=phpcs.xml.dist"
],
"install-codestandards": [
Expand All @@ -48,5 +48,10 @@
"post-install-cmd": [
"@install-codestandards"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# itk-version: 1.0.0

version: "3"

services:
phpfpm:
image: itkdev/php7.4-fpm:latest
image: itkdev/php8.2-fpm:latest
environment:
sinejespersen marked this conversation as resolved.
Show resolved Hide resolved
- XDEBUG_MODE=${XDEBUG_MODE:-off}
- XDEBUG_SESSION=${XDEBUG_SESSION:-0}
- COMPOSER_VERSION=2
- DOCKER_HOST_DOMAIN=${COMPOSE_DOMAIN}
- PHP_IDE_CONFIG=serverName=localhost
volumes:
- .:/app:delegated
- .:/app:delegated
11 changes: 0 additions & 11 deletions package.json

This file was deleted.

Loading
Loading