Skip to content

Commit

Permalink
Enhancement: Synchronize with ergebnis/php-package-template
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Jan 5, 2024
1 parent 3eb2555 commit 054145c
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ For details, take a look at the following workflow configuration files:
- [`workflows/triage.yaml`](workflows/triage.yaml)
- [`workflows/update.yaml`](workflows/update.yaml)

## Backward-compatibility Analysis
## Backward-Compatibility Analysis

We use [`roave/backward-compatibility-check`](https://github.com/Roave/BackwardCompatibilityCheck) to prevent breaking backwards-compatibility.

Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2

Expand Down
2 changes: 1 addition & 1 deletion .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ repository:
archived: false
default_branch: "main"
delete_branch_on_merge: true
description: ":musical_note: Provides a composer plugin for normalizing composer.json."
description: "🎵 Provides a composer plugin for normalizing composer.json."
enable_automated_security_fixes: true
enable_vulnerability_alerts: true
has_discussions: false
Expand Down
98 changes: 5 additions & 93 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ jobs:
- name: "Set up problem matchers for PHP"
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""

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

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

Expand Down Expand Up @@ -188,9 +185,6 @@ jobs:
- name: "Run ergebnis/composer-normalize"
run: ".phive/composer-normalize --ansi --dry-run"

- name: "Create cache directory for friendsofphp/php-cs-fixer"
run: "mkdir -p .build/php-cs-fixer/"

- name: "Cache cache directory for friendsofphp/php-cs-fixer"
uses: "actions/cache@v3.3.2"
with:
Expand All @@ -201,83 +195,7 @@ jobs:
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"

compile-phar:
name: "Compile Phar"

runs-on: "ubuntu-latest"

timeout-minutes: 5

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

dependencies:
- "locked"

env:
COMPOSER_NORMALIZE_PHAR: ".build/phar/composer-normalize.phar"
COMPOSER_VERSION: "2.6.6"

steps:
- name: "Checkout"
uses: "actions/checkout@v4.1.1"

- name: "Set up PHP"
uses: "shivammathur/setup-php@2.28.0"
with:
coverage: "none"
extensions: "none, bcmath, ctype, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
ini-values: "memory_limit=-1, phar.readonly=0"
php-version: "${{ matrix.php-version }}"
tools: "phive"

- 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.9.0"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v3.3.2"
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.9.0"
with:
dependencies: "${{ matrix.dependencies }}"

- name: "Require composer/composer"
run: "composer require composer/composer:${{ env.COMPOSER_VERSION }} --ansi --no-interaction --no-progress"

- name: "Remove git placeholder configuration with jq"
run: "echo $(cat box.json | jq 'del(.git)') > box.json"

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

- name: "Validate configuration for humbug/box"
run: ".phive/box validate box.json --ansi"

- name: "Compile composer-normalize.phar with humbug/box"
run: ".phive/box compile --ansi --config=box.json"

- name: "Show info about composer-normalize.phar with humbug/box"
run: ".phive/box info ${{ env.COMPOSER_NORMALIZE_PHAR }} --ansi"

- name: "Run composer-normalize.phar"
run: "${{ env.COMPOSER_NORMALIZE_PHAR }} --ansi"

- name: "Run composer-normalize.phar with argument and options"
run: "${{ env.COMPOSER_NORMALIZE_PHAR }} --dry-run --no-ansi composer.json"
run: "vendor/bin/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --dry-run --show-progress=dots --verbose"

dependency-analysis:
name: "Dependency Analysis"
Expand Down Expand Up @@ -330,7 +248,7 @@ jobs:
- name: "Install dependencies with phive"
uses: "ergebnis/.github/actions/phive/install@1.9.0"
with:
trust-gpg-keys: "0xC00543248C87FB13,0x033E5F8D801A2F8D,0x2DF45277AEF09A2F"
trust-gpg-keys: "0x033E5F8D801A2F8D"

- name: "Run maglnet/composer-require-checker"
run: ".phive/composer-require-checker check --ansi --config-file=$(pwd)/composer-require-checker.json --verbose"
Expand Down Expand Up @@ -434,9 +352,6 @@ jobs:
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.2"
with:
Expand Down Expand Up @@ -546,8 +461,8 @@ jobs:
with:
dependencies: "${{ matrix.dependencies }}"

- name: "Create cache directory for vimeo/psalm"
run: "mkdir -p .build/psalm/"
- name: "Run phpstan/phpstan"
run: "vendor/bin/phpstan --ansi --configuration=phpstan.neon --memory-limit=-1"

- name: "Run vimeo/psalm"
run: "vendor/bin/psalm --config=psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4"
Expand Down Expand Up @@ -612,7 +527,4 @@ jobs:
dependencies: "${{ matrix.dependencies }}"

- name: "Run unit tests with phpunit/phpunit"
run: "vendor/bin/phpunit --colors=always --configuration=test/phpunit.xml --testsuite=unit"

- name: "Run integration tests with phpunit/phpunit"
run: "vendor/bin/phpunit --colors=always --configuration=test/phpunit.xml --testsuite=integration"
run: "vendor/bin/phpunit --colors=always --configuration=test/Unit/phpunit.xml"
13 changes: 13 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,16 @@ jobs:
core.setFailed(error.message);
}
}
- name: "Post to twitter.com about release"
uses: "Eomm/why-don-t-you-tweet@v1.1.0"
env:
TWITTER_ACCESS_TOKEN: "${{ secrets.ERGEBNIS_TWITTER_ACCESS_TOKEN }}"
TWITTER_ACCESS_TOKEN_SECRET: "${{ secrets.ERGEBNIS_TWITTER_ACCESS_TOKEN_SECRET }}"
TWITTER_CONSUMER_API_KEY: "${{ secrets.ERGEBNIS_TWITTER_CONSUMER_API_KEY }}"
TWITTER_CONSUMER_API_SECRET: "${{ secrets.ERGEBNIS_TWITTER_CONSUMER_API_KEY_SECRET }}"
with:
tweet-message: |
🎵 Just released: ${{ github.event.repository.owner.login }}/${{ github.event.repository.name }}:${{ env.RELEASE_TAG }}.
${{ env.RELEASE_HTML_URL }}
5 changes: 1 addition & 4 deletions .github/workflows/renew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ jobs:
with:
dependencies: "${{ matrix.dependencies }}"

- name: "Create cache directory for friendsofphp/php-cs-fixer"
run: "mkdir -p .build/php-cs-fixer"

- name: "Cache cache directory for friendsofphp/php-cs-fixer"
uses: "actions/cache@v3.3.2"
with:
Expand All @@ -69,7 +66,7 @@ jobs:
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"
run: "vendor/bin/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --show-progress=dots --verbose"

- name: "Commit modified files"
uses: "stefanzweifel/git-auto-commit-action@v5.0.0"
Expand Down
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ backward-compatibility-analysis: vendor ## Runs a backward-compatibility analysi

.PHONY: code-coverage
code-coverage: vendor ## Collects coverage from running unit and integration tests with phpunit/phpunit
mkdir -p .build/phpunit
vendor/bin/phpunit --configuration=test/phpunit.xml --coverage-text

.PHONY: coding-standards
coding-standards: phive vendor ## Lints YAML files with yamllint, normalizes composer.json with ergebnis/composer-normalize, and fixes code style issues with friendsofphp/php-cs-fixer
yamllint -c .yamllint.yaml --strict .
.phive/composer-normalize
mkdir -p .build/php-cs-fixer/
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --verbose

.PHONY: dependency-analysis
Expand All @@ -29,7 +27,6 @@ help: ## Displays this list of targets with descriptions

.PHONY: mutation-tests
mutation-tests: vendor ## Runs mutation tests with infection/infection
mkdir -p .build/infection/
vendor/bin/infection --configuration=infection.json

.PHONY: phar
Expand All @@ -45,12 +42,10 @@ phar: phive vendor ## Builds a phar with humbug/box

.PHONY: phive
phive: .phive ## Installs dependencies with phive
mkdir -p .build/phive/
PHIVE_HOME=.build/phive phive install --trust-gpg-keys 0xC00543248C87FB13,0x033E5F8D801A2F8D,0x2DF45277AEF09A2F

.PHONY: refactoring
refactoring: vendor ## Runs automated refactoring with rector/rector
mkdir -p .build/rector/
vendor/bin/rector process --config=rector.php

.PHONY: schema
Expand All @@ -64,19 +59,16 @@ security-analysis: vendor ## Runs a security analysis with composer

.PHONY: static-code-analysis
static-code-analysis: vendor ## Runs a static code analysis with vimeo/psalm
mkdir -p .build/psalm/
vendor/bin/psalm --config=psalm.xml --clear-cache
vendor/bin/psalm --config=psalm.xml --show-info=false --stats --threads=4

.PHONY: static-code-analysis-baseline
static-code-analysis-baseline: vendor ## Generates a baseline for static code analysis with vimeo/psalm
mkdir -p .build/psalm/
vendor/bin/psalm --config=psalm.xml --clear-cache
vendor/bin/psalm --config=psalm.xml --set-baseline=psalm-baseline.xml

.PHONY: tests
tests: vendor ## Runs unit and integration tests with phpunit/phpunit
mkdir -p .build/phpunit/
vendor/bin/phpunit --configuration=test/phpunit.xml --testsuite=unit
vendor/bin/phpunit --configuration=test/phpunit.xml --testsuite=integration

Expand Down
6 changes: 3 additions & 3 deletions infection.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"logs": {
"text": ".build/infection/infection-log.txt"
},
"minCoveredMsi": 83,
"minMsi": 67,
"minCoveredMsi": 100,
"minMsi": 100,
"phpUnit": {
"configDir": "test"
"configDir": "test\/Unit"
},
"source": {
"directories": [
Expand Down
2 changes: 1 addition & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.17.0@c620f6e80d0abfca532b00bda366062aaedf6e5d">
<files psalm-version="5.18.0@b113f3ed0259fd6e212d87c3df80eec95a6abf19">
<file src="src/Command/NormalizeCommand.php">
<MixedAssignment>
<code>$composerFile</code>
Expand Down

0 comments on commit 054145c

Please sign in to comment.