-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update workflows to make them reusable
- Loading branch information
1 parent
8f4bbc9
commit 05c2c15
Showing
6 changed files
with
129 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: 'PHP Compatibility' | ||
jobs: | ||
phpcs-compatibility: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Run PHPCS inspection | ||
uses: rtCamp/action-phpcs-code-review@v3 | ||
env: | ||
GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }} | ||
PHPCS_STANDARD_FILE_NAME: .phpcs.compat.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: 'PHP CodeSniffer' | ||
jobs: | ||
phpcs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 0 | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Prepare our cache directories | ||
# ------------------------------------------------------------------------------ | ||
- name: Get Composer Cache Directory | ||
id: get-composer-cache-dir | ||
run: | | ||
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache@v2 | ||
id: composer-cache | ||
with: | ||
path: ${{ steps.get-composer-cache-dir.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: 7.4 | ||
- uses: "ramsey/composer-install@v2" | ||
|
||
- name: "Give permissions" | ||
run: | | ||
sudo chown -R root:root $GITHUB_WORKSPACE | ||
# ------------------------------------------------------------------------------ | ||
# Get changed files | ||
# ------------------------------------------------------------------------------ | ||
- name: Get list of changed files | ||
id: files | ||
run: | | ||
echo "CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep '\.php$' | tr '\n' ' ')" >> $GITHUB_ENV | ||
# ------------------------------------------------------------------------------ | ||
# PHPCS | ||
# ------------------------------------------------------------------------------ | ||
- uses: reviewdog/action-setup@v1 | ||
with: | ||
reviewdog_version: latest # Optional. [latest,nightly,v.X.Y.Z] | ||
- name: Run reviewdog | ||
env: | ||
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GH_BOT_TOKEN }} | ||
run: | | ||
vendor/bin/phpcs --report=json ${CHANGED_FILES} | jq -r ' .files | to_entries[] | .key as $path | .value.messages[] as $msg | "\($path):\($msg.line):\($msg.column):`\($msg.source)`<br>\($msg.message)" ' | reviewdog -efm="%f:%l:%c:%m" -name="phpcs" -filter-mode="added" -fail-on-error=true -reporter=github-pr-review |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: 'PHP Static Analysis' | ||
jobs: | ||
phpstan: | ||
strategy: | ||
matrix: | ||
phpVersion: [ | ||
"7.4", | ||
"8.0", | ||
"8.1", | ||
"8.2", | ||
"8.3" | ||
] | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
# ------------------------------------------------------------------------------ | ||
# Checkout the repository | ||
# ------------------------------------------------------------------------------ | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
# ------------------------------------------------------------------------------ | ||
# Get the changed files in a space separated list. | ||
# ------------------------------------------------------------------------------ | ||
- name: Get all changed files and use a space separator in the output | ||
id: changed-files | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
separator: " " | ||
# ------------------------------------------------------------------------------ | ||
# Set up PHP and run phpstan | ||
# ------------------------------------------------------------------------------ | ||
- name: Configure PHP environment to run phpstan | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.phpVersion }} | ||
# ------------------------------------------------------------------------------ | ||
# Override composer php version | ||
# ------------------------------------------------------------------------------ | ||
- name: Set php version ${{ matrix.phpVersion }} in composer | ||
run: composer config platform.php ${{ matrix.phpVersion }} | ||
# ------------------------------------------------------------------------------ | ||
# Install dependencies - ignoring php requirements | ||
# ------------------------------------------------------------------------------ | ||
- name: Install dependencies | ||
run: composer i --ignore-platform-req=php+ | ||
# ------------------------------------------------------------------------------ | ||
# Run phpstan | ||
# ------------------------------------------------------------------------------ | ||
- name: Run phpstan | ||
run: ./vendor/bin/phpstan analyse --error-format=table -c phpstan.neon ${{ steps.changed-files.outputs.all_changed_files }} |