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 24, 2022
1 parent 1f6fb03 commit eb94abd
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 144 deletions.

This file was deleted.

22 changes: 0 additions & 22 deletions .github/actions/composer/composer/install/action.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/actions/composer/composer/install/run.sh

This file was deleted.

56 changes: 35 additions & 21 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
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 @@ -33,14 +30,17 @@ jobs:
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\""

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

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2.1.7"
Expand All @@ -50,11 +50,13 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

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

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

- name: "Send code coverage report to Codecov.io"
Expand Down Expand Up @@ -90,14 +92,17 @@ jobs:
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: "./.github/actions/composer/composer/determine-cache-directory"
uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.2.1"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2.1.7"
Expand All @@ -107,12 +112,12 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Install ${{ matrix.dependencies }} dependencies with composer"
uses: "./.github/actions/composer/composer/install"
uses: "ergebnis/.github/actions/composer/install@1.2.1"
with:
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 @@ -148,11 +153,14 @@ jobs:
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: "./.github/actions/composer/composer/determine-cache-directory"
uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.2.1"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2.1.7"
Expand All @@ -162,7 +170,7 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

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

Expand Down Expand Up @@ -190,11 +198,14 @@ jobs:
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: "./.github/actions/composer/composer/determine-cache-directory"
uses: "ergebnis/.github/actions/composer/determine-cache-directory@1.2.1"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2.1.7"
Expand All @@ -204,15 +215,15 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

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

- name: "Create cache directory for vimeo/psalm"
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 @@ -239,14 +250,17 @@ jobs:
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\""

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

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2.1.7"
Expand All @@ -256,7 +270,7 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

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

Expand Down
80 changes: 46 additions & 34 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,65 +29,77 @@ jobs:
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
const pullRequest = context.payload.workflow_run.pull_requests[0];
const reviewers = [
"ergebnis-bot",
]
];
await github.rest.pulls.requestReviewers({
owner: repository.owner,
repo: repository.repo,
pull_number: pullRequest.number,
reviewers: reviewers,
})
try {
await github.rest.pulls.requestReviewers({
owner: context.repo.owner,
pull_number: pullRequest.number,
repo: context.repo.repo,
reviewers: reviewers,
});
} catch (error) {
core.setFailed(error.message);
}
- name: "Assign @ergebnis-bot"
uses: "actions/github-script@v5"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
const pullRequest = context.payload.workflow_run.pull_requests[0];
const assignees = [
"ergebnis-bot",
]
];
await github.rest.issues.addAssignees({
owner: repository.owner,
repo: repository.repo,
assignees: assignees,
issue_number: pullRequest.number
})
try {
await github.rest.issues.addAssignees({
assignees: assignees,
issue_number: pullRequest.number
owner: context.repo.owner,
repo: context.repo.repo,
});
} catch (error) {
core.setFailed(error.message);
}
- name: "Approve pull request"
uses: "actions/github-script@v5"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
const pullRequest = context.payload.workflow_run.pull_requests[0];
await github.rest.pulls.createReview({
event: "APPROVE",
owner: repository.owner,
repo: repository.repo,
pull_number: pullRequest.number,
})
try {
await github.rest.pulls.createReview({
event: "APPROVE",
owner: context.repo.owner,
pull_number: pullRequest.number,
repo: context.repo.repo,
});
} catch (error) {
core.setFailed(error.message);
}
- name: "Merge pull request"
uses: "actions/github-script@v5"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
const pullRequest = context.payload.workflow_run.pull_requests[0];
await github.rest.pulls.merge({
merge_method: "merge",
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
})
try {
await github.rest.pulls.merge({
merge_method: "merge",
owner: context.repo.owner,
pull_number: pullRequest.number,
repo: context.repo.repo,
});
} catch (error) {
core.setFailed(error.message);
}
26 changes: 17 additions & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@ jobs:

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

- name: "Create release"
uses: "actions/create-release@v1.1.4"
env:
GITHUB_TOKEN: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
uses: "actions/github-script@v5"
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 }}"
script: |
try {
await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
});
} catch (error) {
core.setFailed(error.message);
}
Loading

0 comments on commit eb94abd

Please sign in to comment.