summaryrefslogtreecommitdiffstatshomepage
path: root/.github/workflows/coding-standards.yml
blob: 218142ffed06262158e1bff6210069c91d847d4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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 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@v1
        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