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

Enhancement: Synchronize with ergebnis/php-package-template #118

Merged
merged 1 commit into from Mar 13, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Expand Up @@ -13,3 +13,4 @@
/Makefile export-ignore
/psalm-baseline.xml export-ignore
/psalm.xml export-ignore
/rector.php export-ignore
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -1 +1,3 @@
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-size

* @ergebnis-bot @localheinz
59 changes: 41 additions & 18 deletions .github/CONTRIBUTING.md
Expand Up @@ -6,7 +6,6 @@ For details, take a look at the following workflow configuration files:

- [`workflows/integrate.yaml`](workflows/integrate.yaml)
- [`workflows/merge.yaml`](workflows/merge.yaml)
- [`workflows/prune.yaml`](workflows/prune.yaml)
- [`workflows/release.yaml`](workflows/release.yaml)
- [`workflows/renew.yaml`](workflows/renew.yaml)
- [`workflows/triage.yaml`](workflows/triage.yaml)
Expand Down Expand Up @@ -47,9 +46,45 @@ make dependency-analysis

to run a dependency analysis.

## Mutation Tests

We are using [`infection/infection`](https://github.com/infection/infection) to ensure a minimum quality of the tests.

Enable `Xdebug` and run

```sh
make mutation-tests
```

to run mutation tests.

## Refactoring

We are using [`rector/rector`](https://github.com/rectorphp/rector) to automatically refactor code.

Run

```sh
make refactoring
```

to automatically refactor code.

## Security Analysis

We are using [`composer`](https://github.com/composer/composer) to run a security analysis.

Run

```sh
make security-analysis
```

to run a security analysis.

## Static Code Analysis

We are using [`vimeo/psalm`](https://github.com/vimeo/psalm) to statically analyze the code.
We are using [`phpstan/phpstan`](https://github.com/phpstan/phpstan) and [`vimeo/psalm`](https://github.com/vimeo/psalm) to statically analyze the code.

Run

Expand All @@ -59,17 +94,17 @@ make static-code-analysis

to run a static code analysis.

We are also using the baseline feature of [`vimeo/psalm`](https://psalm.dev/docs/running_psalm/dealing_with_code_issues/#using-a-baseline-file).
We are also using the baseline features of [`phpstan/phpstan`](https://phpstan.org/user-guide/baseline) and [`vimeo/psalm`](https://psalm.dev/docs/running_psalm/dealing_with_code_issues/#using-a-baseline-file).

Run

```sh
make static-code-analysis-baseline
```

to regenerate the baseline in [`../psalm-baseline.xml`](../psalm-baseline.xml).
to regenerate the baselines in [`../phpstan-baseline.neon`](../phpstan-baseline.neon) and [`../psalm-baseline.xml`](../psalm-baseline.xml).

:exclamation: Ideally, the baseline should shrink over time.
:exclamation: Ideally, the baselines should shrink over time.

## Tests

Expand All @@ -83,18 +118,6 @@ make tests

to run all the tests.

## Mutation Tests

We are using [`infection/infection`](https://github.com/infection/infection) to ensure a minimum quality of the tests.

Enable `pcov` or `Xdebug` and run

```sh
make mutation-tests
```

to run mutation tests.

## Extra lazy?

Run
Expand All @@ -103,7 +126,7 @@ Run
make
```

to enforce coding standards, run a static code analysis, and run tests!
to automatically refactor code, enforce coding standards, run a static code analysis, and run tests!

## Help

Expand Down
6 changes: 2 additions & 4 deletions .github/settings.yml
Expand Up @@ -18,6 +18,8 @@ branches:
- context: "Coding Standards (8.1, locked)"
- context: "Dependency Analysis (8.1, locked)"
- context: "Mutation Tests (8.1, locked)"
- context: "Refactoring (8.1, locked)"
- context: "Security Analysis (8.1, locked)"
- context: "Static Code Analysis (8.1, locked)"
- context: "Tests (8.1, locked)"
- context: "Tests (8.2, locked)"
Expand Down Expand Up @@ -58,10 +60,6 @@ labels:
color: "ee0701"
description: ""

- name: "stale"
color: "eeeeee"
description: ""

# https://docs.github.com/en/rest/reference/repos#update-a-repository

repository:
Expand Down
106 changes: 102 additions & 4 deletions .github/workflows/integrate.yaml
Expand Up @@ -83,7 +83,7 @@ jobs:
uses: "actions/checkout@v3.3.0"

- name: "Lint YAML files"
uses: "ibiqlik/action-yamllint@v3.1"
uses: "ibiqlik/action-yamllint@v3.1.1"
with:
config_file: ".yamllint.yaml"
file_or_dir: "."
Expand Down Expand Up @@ -127,8 +127,10 @@ jobs:
uses: "actions/cache@v3.3.1"
with:
path: ".build/php-cs-fixer"
key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.sha }}"
restore-keys: "php-${{ matrix.php-version }}-php-cs-fixer-"
key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.ref_name }}"
restore-keys: |
php-${{ matrix.php-version }}-php-cs-fixer-main
php-${{ matrix.php-version }}-php-cs-fixer-

- name: "Run friendsofphp/php-cs-fixer"
run: "vendor/bin/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --dry-run --verbose"
Expand Down Expand Up @@ -156,6 +158,7 @@ jobs:
coverage: "none"
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"
tools: "phive"

- name: "Set up problem matchers for PHP"
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
Expand All @@ -175,6 +178,11 @@ jobs:
with:
dependencies: "${{ matrix.dependencies }}"

- name: "Install dependencies with phive"
uses: "ergebnis/.github/actions/phive/install@1.8.0"
with:
trust-gpg-keys: "0x033E5F8D801A2F8D"

- name: "Run maglnet/composer-require-checker"
run: ".phive/composer-require-checker check --config-file=$(pwd)/composer-require-checker.json"

Expand Down Expand Up @@ -225,6 +233,96 @@ jobs:
XDEBUG_MODE: "coverage"
run: "vendor/bin/infection --ansi --configuration=infection.json --logger-github"

refactoring:
name: "Refactoring"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "8.1"

dependencies:
- "locked"

steps:
- name: "Checkout"
uses: "actions/checkout@v3.3.0"

- name: "Set up PHP"
uses: "shivammathur/setup-php@2.24.0"
with:
coverage: "none"
extensions: "none, ctype, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""

- name: "Determine composer cache directory"
uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.8.0"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v3.3.1"
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Install ${{ matrix.dependencies }} dependencies with composer"
uses: "ergebnis/.github/actions/composer/install@1.8.0"
with:
dependencies: "${{ matrix.dependencies }}"

- name: "Create cache directory for rector/rector"
run: "mkdir -p .build/rector"

- name: "Cache cache directory for rector/rector"
uses: "actions/cache@v3.3.0"
with:
path: ".build/rector"
key: "php-${{ matrix.php-version }}-rector-${{ github.ref_name }}"
restore-keys: |
php-${{ matrix.php-version }}-rector-main
php-${{ matrix.php-version }}-rector-

- name: "Run automated refactoring with rector/rector"
run: "vendor/bin/rector --ansi --config=rector.php --dry-run"

security-analysis:
name: "Security Analysis"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "8.1"

dependencies:
- "locked"

steps:
- name: "Checkout"
uses: "actions/checkout@v3.3.0"

- name: "Set up PHP"
uses: "shivammathur/setup-php@2.24.0"
with:
coverage: "none"
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""

- name: "Validate composer.json and composer.lock"
run: "composer validate --ansi --strict"

- name: "Check installed packages for security vulnerability advisories"
run: "composer audit --ansi"

static-code-analysis:
name: "Static Code Analysis"

Expand All @@ -246,7 +344,7 @@ jobs:
uses: "shivammathur/setup-php@2.24.0"
with:
coverage: "none"
extensions: "none, ctype, curl, dom, json, mbstring, pcntl, phar, posix, simplexml, tokenizer, xml, xmlwriter"
extensions: "none, ctype, curl, dom, json, mbstring, opcache, pcntl, phar, posix, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge.yaml
Expand Up @@ -34,8 +34,8 @@ jobs:
- name: "Assign @ergebnis-bot"
uses: "ergebnis/.github/actions/github/pull-request/add-assignee@1.8.0"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
assignee: "ergebnis-bot"
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"

- name: "Approve pull request"
uses: "ergebnis/.github/actions/github/pull-request/approve@1.8.0"
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/prune.yaml

This file was deleted.

6 changes: 4 additions & 2 deletions .github/workflows/renew.yaml
Expand Up @@ -61,8 +61,10 @@ jobs:
uses: "actions/cache@v3.3.1"
with:
path: ".build/php-cs-fixer"
key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.sha }}"
restore-keys: "php-${{ matrix.php-version }}-php-cs-fixer-"
key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.ref_name }}"
restore-keys: |
php-${{ matrix.php-version }}-php-cs-fixer-main
php-${{ matrix.php-version }}-php-cs-fixer-
- name: "Run friendsofphp/php-cs-fixer"
run: "vendor/bin/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --verbose"
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
@@ -1,5 +1,7 @@
/.build/
/.notes/
/.phive/
/demo/obsidian/
!/demo/obsidian/.gitkeep
/vendor/
!/.phive/phars.xml
!/demo/obsidian/.gitkeep
2 changes: 1 addition & 1 deletion .phive/phars.xml
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="composer-require-checker" version="^4.1.0" installed="4.1.0" location="./.phive/composer-require-checker" copy="true"/>
<phar name="composer-require-checker" version="^4.5.0" installed="4.5.0" location="./.phive/composer-require-checker" copy="false"/>
</phive>