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 Feb 7, 2022
1 parent 7ff9dae commit 8c561d7
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 114 deletions.
50 changes: 32 additions & 18 deletions .github/workflows/integrate.yaml
Expand Up @@ -8,9 +8,6 @@ on: # yamllint disable-line rule:truthy
branches:
- "main"

env:
PHP_EXTENSIONS: "mbstring"

jobs:
code-coverage:
name: "Code Coverage"
Expand All @@ -29,13 +26,16 @@ jobs:
- name: "Checkout"
uses: "actions/checkout@v2.4.0"

- name: "Install PHP with extensions"
- name: "Set up PHP"
uses: "shivammathur/setup-php@2.16.0"
with:
coverage: "xdebug"
extensions: "${{ env.PHP_EXTENSIONS }}"
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: "Set up problem matchers for phpunit/phpunit"
run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\""

Expand All @@ -55,7 +55,9 @@ jobs:
dependencies: "${{ matrix.dependencies }}"

- name: "Collect code coverage with Xdebug and phpunit/phpunit"
run: "vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-clover=.build/phpunit/logs/clover.xml"
env:
XDEBUG_MODE: "coverage"
run: "vendor/bin/phpunit --colors=always --configuration=test/Unit/phpunit.xml --coverage-clover=.build/phpunit/logs/clover.xml"

- name: "Send code coverage report to Codecov.io"
env:
Expand Down Expand Up @@ -86,15 +88,18 @@ jobs:
file_or_dir: "."
strict: true

- name: "Install PHP with extensions"
- name: "Set up PHP"
uses: "shivammathur/setup-php@2.16.0"
with:
coverage: "none"
extensions: "${{ env.PHP_EXTENSIONS }}"
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 --strict"
run: "composer validate --ansi --strict"

- name: "Determine composer cache directory"
uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.3.2"
Expand All @@ -112,7 +117,7 @@ jobs:
dependencies: "${{ matrix.dependencies }}"

- name: "Run ergebnis/composer-normalize"
run: "composer normalize --dry-run"
run: "composer normalize --ansi --dry-run"

- name: "Create cache directory for friendsofphp/php-cs-fixer"
run: "mkdir -p .build/php-cs-fixer"
Expand Down Expand Up @@ -144,13 +149,16 @@ jobs:
- name: "Checkout"
uses: "actions/checkout@v2.4.0"

- name: "Install PHP with extensions"
- name: "Set up PHP"
uses: "shivammathur/setup-php@2.16.0"
with:
coverage: "none"
extensions: "${{ env.PHP_EXTENSIONS }}"
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: "Determine composer cache directory"
uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.3.2"

Expand Down Expand Up @@ -186,13 +194,16 @@ jobs:
- name: "Checkout"
uses: "actions/checkout@v2.4.0"

- name: "Install PHP with extensions"
- name: "Set up PHP"
uses: "shivammathur/setup-php@2.16.0"
with:
coverage: "none"
extensions: "${{ env.PHP_EXTENSIONS }}"
extensions: "none, ctype, curl, dom, json, mbstring, pcntl, phar, posix, 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.3.2"

Expand All @@ -212,7 +223,7 @@ jobs:
run: "mkdir -p .build/psalm"

- name: "Run vimeo/psalm"
run: "vendor/bin/psalm --config=psalm.xml --diff --shepherd --show-info=false --stats --threads=4"
run: "vendor/bin/psalm --config=psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4"

tests:
name: "Tests"
Expand All @@ -235,13 +246,16 @@ jobs:
- name: "Checkout"
uses: "actions/checkout@v2.4.0"

- name: "Install PHP with extensions"
- name: "Set up PHP"
uses: "shivammathur/setup-php@2.16.0"
with:
coverage: "none"
extensions: "${{ env.PHP_EXTENSIONS }}"
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: "Set up problem matchers for phpunit/phpunit"
run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\""

Expand All @@ -261,4 +275,4 @@ jobs:
dependencies: "${{ matrix.dependencies }}"

- name: "Run unit tests with phpunit/phpunit"
run: "vendor/bin/phpunit --configuration=test/Unit/phpunit.xml"
run: "vendor/bin/phpunit --colors=always --configuration=test/Unit/phpunit.xml"
58 changes: 6 additions & 52 deletions .github/workflows/merge.yaml
Expand Up @@ -25,69 +25,23 @@ jobs:
steps:
- name: "Request review from @ergebnis-bot"
uses: "actions/github-script@v5"
uses: "ergebnis/.github/actions/github/pull-request/request-review@1.3.2"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
const reviewers = [
"ergebnis-bot",
]
await github.rest.pulls.requestReviewers({
owner: repository.owner,
repo: repository.repo,
pull_number: pullRequest.number,
reviewers: reviewers,
})
reviewer: "ergebnis-bot"

- name: "Assign @ergebnis-bot"
uses: "actions/github-script@v5"
uses: "ergebnis/.github/actions/github/pull-request/add-assignee@1.3.2"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
const assignees = [
"ergebnis-bot",
]
await github.rest.issues.addAssignees({
owner: repository.owner,
repo: repository.repo,
assignees: assignees,
issue_number: pullRequest.number
})
assignee: "ergebnis-bot"

- name: "Approve pull request"
uses: "actions/github-script@v5"
uses: "ergebnis/.github/actions/github/pull-request/approve@1.3.2"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
await github.rest.pulls.createReview({
event: "APPROVE",
owner: repository.owner,
repo: repository.repo,
pull_number: pullRequest.number,
})

- name: "Merge pull request"
uses: "actions/github-script@v5"
uses: "ergebnis/.github/actions/github/pull-request/merge@1.3.2"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
await github.rest.pulls.merge({
merge_method: "merge",
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
})
13 changes: 2 additions & 11 deletions .github/workflows/release.yaml
Expand Up @@ -14,16 +14,7 @@ jobs:
runs-on: "ubuntu-latest"

steps:
- name: "Determine tag"
id: "determine-tag"
run: "echo \"::set-output name=tag::${GITHUB_REF#refs/tags/}\""

- name: "Create release"
uses: "actions/create-release@v1.1.4"
env:
GITHUB_TOKEN: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
uses: "ergebnis/.github/actions/github/release/create@1.3.2"
with:
draft: false
prerelease: false
release_name: "${{ steps.determine-tag.outputs.tag }}"
tag_name: "${{ steps.determine-tag.outputs.tag }}"
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
12 changes: 6 additions & 6 deletions .github/workflows/renew.yaml
Expand Up @@ -6,9 +6,6 @@ on: # yamllint disable-line rule:truthy
schedule:
- cron: "0 0 1 1 *"

env:
PHP_EXTENSIONS: "mbstring"

jobs:
license:
name: "License"
Expand All @@ -29,15 +26,18 @@ jobs:
with:
token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"

- name: "Install PHP with extensions"
- name: "Set up PHP"
uses: "shivammathur/setup-php@2.16.0"
with:
coverage: "none"
extensions: "${{ env.PHP_EXTENSIONS }}"
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 --strict"
run: "composer validate --ansi --strict"

- name: "Determine composer cache directory"
uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.3.2"
Expand Down
27 changes: 1 addition & 26 deletions .github/workflows/triage.yaml
Expand Up @@ -15,31 +15,6 @@ jobs:

steps:
- name: "Add labels based on branch name"
uses: "actions/github-script@v5"
uses: "ergebnis/.github/actions/github/pull-request/add-label-based-on-branch-name@1.3.2"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const branchPrefixLabels = {
feature: "enhancement",
fix: "bug",
}
const pullRequest = context.payload.pull_request
const repository = context.repo
const branchName = pullRequest.head.ref
const matches = branchName.match(new RegExp('^([^/]+)\/'));
if (matches instanceof Array && branchPrefixLabels.hasOwnProperty(matches[1])) {
const label = branchPrefixLabels[matches[1]]
github.rest.issues.addLabels({
issue_number: pullRequest.number,
labels: [
label
],
owner: repository.owner,
repo: repository.repo,
});
}
Binary file modified .phive/composer-require-checker
Binary file not shown.
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="^2.1.0" installed="2.1.0" location="./.phive/composer-require-checker" copy="true"/>
<phar name="composer-require-checker" version="^3.8.0" installed="3.8.0" location="./.phive/composer-require-checker" copy="true"/>
</phive>

0 comments on commit 8c561d7

Please sign in to comment.