-
Notifications
You must be signed in to change notification settings - Fork 6
Add archive check workflow #136
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
Open
AlexP11223
wants to merge
1
commit into
main
Choose a base branch
from
feature/PROD-172-check-archive
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,80 @@ | ||
| name: Check plugin package | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| ARTIFACT: | ||
| description: The name of the generated artifact, usually the output of the archive creation workflow. | ||
| required: true | ||
| type: string | ||
| PLUGIN_FOLDER_NAME: | ||
| description: The name of the plugin folder (falls back to the repository name). | ||
| default: '' | ||
| required: false | ||
| type: string | ||
| EXCLUDED_SNIFFS: | ||
| description: The comma-separated list of excluded sniffs. | ||
| default: 'WordPress.WP.AlternativeFunctions' | ||
| required: false | ||
| type: string | ||
| ADDITIONAL_WP_SNIFFS: | ||
| description: The comma-separated list of additional sniffs to run. | ||
| default: 'WordPress.WP.I18n' | ||
| required: false | ||
| type: string | ||
| COMPOSER_ARGS: | ||
| description: The arguments passed to Composer when installing dependencies. | ||
| default: '--no-dev --prefer-dist' | ||
| required: false | ||
| type: string | ||
| PHP_VERSION: | ||
| description: The PHP version to use. | ||
| default: '7.4' | ||
| required: false | ||
| type: string | ||
|
|
||
| jobs: | ||
| check_archive: | ||
| name: Check plugin package | ||
| timeout-minutes: 2 | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| PLUGIN_FOLDER_NAME: ${{ inputs.PLUGIN_FOLDER_NAME }} | ||
| steps: | ||
| - name: Download Artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: ${{ inputs.ARTIFACT }} | ||
|
|
||
| - name: Set up plugin folder name | ||
| id: plugin-folder-name | ||
| run: echo "plugin-folder-name=${PLUGIN_FOLDER_NAME:-${{ github.event.repository.name }}}" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Setup PHP with tools | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ inputs.PHP_VERSION }} | ||
| tools: parallel-lint | ||
|
|
||
| - name: Run Parallel Lint | ||
| run: parallel-lint . | ||
|
|
||
| - name: Checkout Plugin Check repo | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: WordPress/plugin-check | ||
| path: plugin-check | ||
| - name: Install Plugin Check deps | ||
| uses: ramsey/composer-install@v3 | ||
| with: | ||
| working-directory: plugin-check | ||
| composer-options: ${{ inputs.COMPOSER_ARGS }} | ||
| - name: Run Plugin Check main rules | ||
| run: | | ||
| if [[ -z ${{ inputs.EXCLUDED_SNIFFS }} ]]; then exclude=''; else exclude="--exclude=${{ inputs.EXCLUDED_SNIFFS }}"; fi | ||
| vendor/bin/phpcs --standard=phpcs-rulesets/plugin-review.xml "${exclude}" --extensions=php "../${{ steps.plugin-folder-name.outputs.plugin-folder-name }}" | ||
| working-directory: plugin-check | ||
| - name: Run Plugin Check additional rules | ||
| if: ${{ inputs.ADDITIONAL_WP_SNIFFS != '' }} | ||
| run: vendor/bin/phpcs --standard=Wordpress --sniffs=${{ inputs.ADDITIONAL_WP_SNIFFS }} --extensions=php "../${{ steps.plugin-folder-name.outputs.plugin-folder-name }}" | ||
| working-directory: plugin-check | ||
This file contains hidden or 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,40 @@ | ||
| # Check plugin archive | ||
|
|
||
| This workflow runs some checks on the plugin archive to make sure that everything is ok (especially important if processing the source code via php-scoper or Rector). | ||
|
|
||
| Usually it should be run after the [archive creation workflow](/docs/archive-creation.md). | ||
|
|
||
| It executes | ||
| - [Parallel Lint](https://github.com/php-parallel-lint/PHP-Parallel-Lint) to check the PHP syntax | ||
| - [Plugin Check](https://github.com/WordPress/plugin-check) PHP_CodeSniffer rules, as well as optionally other WordPress sniffs. | ||
|
|
||
|
|
||
| ## Simple usage example: | ||
|
|
||
| ```yml | ||
| name: Create and check release package | ||
| on: | ||
| workflow_dispatch: | ||
| jobs: | ||
| create_archive: | ||
| uses: inpsyde/reusable-workflows/.github/workflows/build-plugin-archive.yml@main | ||
| check_archive: | ||
| uses: inpsyde/reusable-workflows/.github/workflows/check-plugin-archive.yml@main | ||
| needs: create_archive | ||
| with: | ||
| ARTIFACT: ${{ needs.create_archive.outputs.artifact }} | ||
| PHP_VERSION: '7.4' | ||
| ``` | ||
|
|
||
| ## Configuration parameters | ||
|
|
||
| ### Inputs | ||
|
|
||
| | Name | Default | Description | | ||
| |------------------------|-----------------------------------------------|------------------------------------------------------------------------------------------------| | ||
| | `ARTIFACT` | | The name of the generated artifact, usually the output of the archive creation workflow. | | ||
| | `PLUGIN_FOLDER_NAME` | `''` | The name of the plugin folder (falls back to the repository name). | | ||
| | `EXCLUDED_SNIFFS` | `'WordPress.WP.AlternativeFunctions'` | The comma-separated list of excluded sniffs. | | ||
| | `ADDITIONAL_WP_SNIFFS` | `'WordPress.WP.I18n'` | The comma-separated list of additional sniffs to run. | | ||
| | `COMPOSER_ARGS` | `'--no-dev --prefer-dist'` | The arguments passed to Composer when installing dependencies. | | ||
| | `PHP_VERSION` | `'7.4'` | The PHP version to use. | |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a reusable workflow for this: https://github.com/inpsyde/reusable-workflows/blob/main/.github/workflows/lint-php.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I put it here because the workflow cannot run on the extracted artifact. Though the new unified build may solve that.