chore: Preview Unit Tests - Iteration 2 #158
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
| name: Code Quality | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'plugins/**.php' | |
| pull_request: | |
| paths: | |
| - 'plugins/**.php' | |
| jobs: | |
| run: | |
| runs-on: ubuntu-latest | |
| name: Check code quality | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Get changed plugin directory | |
| id: plugin | |
| run: | | |
| git fetch --prune --unshallow | |
| plugin=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '^plugins/' | head -1 | cut -d/ -f2) | |
| echo "slug=$plugin" >> $GITHUB_OUTPUT | |
| # We should at least have a phpcs.xml file to run code quality checks | |
| - name: Validate phpcs.xml | |
| run: | | |
| if [ ! -f "plugins/${{ steps.plugin.outputs.slug }}/phpcs.xml" ]; then | |
| echo "Exiting as no phpcs.xml file found for /${{ steps.plugin.outputs.slug }}" | |
| exit 1 | |
| fi | |
| - name: PHP Code Quality | |
| uses: ./.github/actions/code-quality | |
| with: | |
| working-directory: plugins/${{ steps.plugin.outputs.slug }} |