Skip to content

Commit e7160a7

Browse files
committed
Coding standards and code quality
1 parent dc34295 commit e7160a7

File tree

10 files changed

+310
-90
lines changed

10 files changed

+310
-90
lines changed

.github/workflows/code-quality.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Code Quality
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
trufflehog:
8+
uses: ./.github/workflows/truffle-hog.yml
9+
10+
virus-scan:
11+
uses: ./.github/workflows/virus-scan.yml
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Coding Standards
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
stylelint:
8+
uses: ./.github/workflows/stylelint.yml
9+
10+
eslint:
11+
uses: ./.github/workflows/eslint.yml
12+
13+
phpcs:
14+
uses: ./.github/workflows/phpcs.yml
15+
16+
phpstan:
17+
uses: ./.github/workflows/phpstan.yml

.github/workflows/eslint.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: JavaScript Coding Standards
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
eslint:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Install Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version-file: .nvmrc
21+
cache: "npm"
22+
23+
- name: Cache node modules
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.npm
27+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
28+
restore-keys: |
29+
${{ runner.os }}-node-
30+
31+
- name: Check Node version
32+
run: node -v
33+
34+
- name: Setup NPM
35+
run: npm install -g npm@latest
36+
37+
- name: Check NPM version
38+
run: npm -v
39+
40+
- name: Install dependencies
41+
run: npm install
42+
43+
- name: Run Lint JS
44+
run: npm run lint-js

.github/workflows/jest.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: JavaScript Unit Tests
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
jest:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Install Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version-file: .nvmrc
21+
cache: "npm"
22+
23+
- name: Cache node modules
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.npm
27+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
28+
restore-keys: |
29+
${{ runner.os }}-node-
30+
31+
- name: Check Node version
32+
run: node -v
33+
34+
- name: Setup NPM
35+
run: npm install -g npm@latest
36+
37+
- name: Check NPM version
38+
run: npm -v
39+
40+
- name: Install dependencies
41+
run: npm install
42+
43+
- name: Run Jest
44+
run: npm run test

.github/workflows/node.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.

.github/workflows/php.yml renamed to .github/workflows/phpcs.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
name: PHP Checks
1+
name: PHP Coding Standards
22

33
on:
4-
push:
5-
branches: ["trunk"]
6-
pull_request:
7-
branches: ["trunk"]
4+
workflow_call:
85

96
permissions:
107
contents: read
118

129
jobs:
13-
build:
10+
phpcs:
1411
runs-on: ubuntu-latest
1512

1613
steps:
17-
- uses: actions/checkout@v3
14+
- name: Checkout
15+
uses: actions/checkout@v4
1816

1917
- name: Setup PHP with composer v2
2018
uses: shivammathur/setup-php@v2
@@ -51,6 +49,3 @@ jobs:
5149

5250
- name: Run PHPCS
5351
run: composer lint
54-
55-
- name: Run PHPStan
56-
run: composer static

.github/workflows/phpstan.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: PHP Static Analysis
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
phpstan:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup PHP with composer v2
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: "8.3"
21+
tools: composer:v2
22+
23+
- name: Validate Root composer.json and composer.lock
24+
run: composer validate --strict
25+
26+
- name: Validate Plugin composer.json and composer.lock
27+
run: composer validate --strict --working-dir=mu-plugins/10up-plugin
28+
29+
- name: Validate Theme composer.json and composer.lock
30+
run: composer validate --strict --working-dir=themes/10up-theme
31+
32+
- name: Cache Composer packages
33+
id: composer-cache
34+
uses: actions/cache@v4
35+
with:
36+
path: vendor
37+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
38+
restore-keys: |
39+
${{ runner.os }}-php-
40+
41+
- name: Install Root dependencies
42+
run: composer install --prefer-dist --no-progress
43+
44+
- name: Install Plugin dependencies
45+
run: composer install --prefer-dist --no-progress --working-dir=mu-plugins/10up-plugin
46+
47+
- name: Install Theme dependencies
48+
run: composer install --prefer-dist --no-progress --working-dir=themes/10up-theme
49+
50+
- name: Run PHPStan
51+
run: composer static

.github/workflows/stylelint.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CSS Coding Standards
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
stylelint:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Install Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version-file: .nvmrc
21+
cache: "npm"
22+
23+
- name: Cache node modules
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.npm
27+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
28+
restore-keys: |
29+
${{ runner.os }}-node-
30+
31+
- name: Check Node version
32+
run: node -v
33+
34+
- name: Setup NPM
35+
run: npm install -g npm@latest
36+
37+
- name: Check NPM version
38+
run: npm -v
39+
40+
- name: Install dependencies
41+
run: npm install
42+
43+
- name: Run Lint Style
44+
run: npm run lint-style
45+

.github/workflows/truffle-hog.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Secret Scanning
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
trufflehog:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Trufflehog exclusions
20+
run: |
21+
if [ ! -f .trufflehog-exclude.txt ]; then
22+
echo "# Paths to exclude from TruffleHog scanning" > .trufflehog-exclude.txt
23+
echo "node_modules/" >> .trufflehog-exclude.txt
24+
echo "vendor/" >> .trufflehog-exclude.txt
25+
echo "dist/" >> .trufflehog-exclude.txt
26+
echo "build/" >> .trufflehog-exclude.txt
27+
fi
28+
29+
- name: Run Trufflehog on latest commits
30+
id: trufflehog
31+
uses: trufflesecurity/trufflehog@main
32+
continue-on-error: true
33+
with:
34+
path: ./
35+
extra_args: --results=verified,unknown --exclude-paths .trufflehog-exclude.txt
36+
37+
- name: Trufflehog Scan Failure
38+
if: steps.trufflehog.outcome == 'failure'
39+
run: exit 1

0 commit comments

Comments
 (0)