name: Coding Standards on: push: branches: - master # JSHint was introduced in WordPress 3.8. # PHPCS checking was introduced in WordPress 5.1. - '3.[89]' - '[4-9].[0-9]' tags: - '3.[89]*' - '[4-9].[0-9]*' pull_request: jobs: # Runs PHP coding standards checks. # # Violations are reported inline with annotations. # # Performs the following steps: # - Checks out the repository. # - Sets up PHP. # - Logs debug information. # - Installs Composer dependencies (use cache if possible). # - Make Composer packages available globally. # - Logs PHP_CodeSniffer debug information. # - Runs PHPCS on the full codebase with warnings suppressed. # - Runs PHPCS on the `tests` directory without warnings suppressed. # - todo: Configure Slack notifications for failing scans. phpcs: name: PHP coding standards runs-on: ubuntu-latest if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} steps: - name: Checkout repository uses: actions/checkout@v2 - name: Set up PHP uses: shivammathur/setup-php@v2 with: php-version: '7.4' coverage: none tools: composer, cs2pr - name: Log debug information run: | php --version composer --version - name: Install Composer dependencies uses: ramsey/composer-install@v1 with: composer-options: "--no-progress --no-ansi --no-interaction" - name: Make Composer packages available globally run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH - name: Log PHPCS debug information run: phpcs -i - name: Run PHPCS on all Core files run: phpcs -q -n --report=checkstyle | cs2pr - name: Check test suite files for warnings run: phpcs tests -q --report=checkstyle | cs2pr # Runs the JavaScript coding standards checks. # # JSHint violations are not currently reported inline with annotations. # # Performs the following steps: # - Checks out the repository. # - Logs debug information about the runner container. # - Installs NodeJS 14. # - Sets up caching for NPM. # - Logs updated debug information. # _ Installs NPM dependencies using install-changed to hash the `package.json` file. # - Run the WordPress JSHint checks. # - todo: Configure Slack notifications for failing tests. jshint: name: JavaScript coding standards runs-on: ubuntu-latest if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} steps: - name: Checkout repository uses: actions/checkout@v2 - name: Log debug information run: | npm --version node --version git --version svn --version - name: Install NodeJS uses: actions/setup-node@v2 with: node-version: 14 - name: Cache NodeJS modules uses: actions/cache@v2 env: cache-name: cache-node-modules with: # npm cache files are stored in `~/.npm` on Linux/macOS path: ~/.npm key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm- - name: Log debug information run: | npm --version node --version - name: Install Dependencies run: npx install-changed --install-command="npm ci" - name: Run JSHint run: npm run grunt jshint