Skip to content

Commit 4ed9e58

Browse files
committed
Add everything for the plugin
0 parents  commit 4ed9e58

26 files changed

+26977
-0
lines changed

.github/workflows/quality-php.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: PHP Quality Checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
checks:
11+
name: Codesniffer
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout project
16+
uses: actions/checkout@v4
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: 8.0
22+
23+
- name: Validate composer file
24+
run: composer validate
25+
26+
- name: Install composer dependencies
27+
run: composer install -o
28+
29+
- name: Run codesniffer
30+
run: composer cs

.github/workflows/quality-static.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Javascript Quality Checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
checks:
11+
name: Lint JS
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout project
16+
uses: actions/checkout@v4
17+
18+
- name: Setup NodeJS
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20.11.*'
22+
23+
- name: Install npm dependencies
24+
run: npm install
25+
26+
- name: Run wp-script lint:js on src folder
27+
run: npm run lint:js src
28+
29+
- name: Run wp-script lint:css on src folder
30+
run: npm run lint:css src

.github/workflows/tests-e2e.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
2+
3+
name: E2E Tests
4+
5+
on: # yamllint disable-line rule:truthy
6+
workflow_dispatch:
7+
pull_request:
8+
paths:
9+
- 'src/**'
10+
- 'includes/**'
11+
- 'tests/**'
12+
- 'composer.json'
13+
- '.github/workflows/tests.yml'
14+
push:
15+
paths:
16+
- 'src/**'
17+
- 'includes/**'
18+
- 'tests/**'
19+
- 'composer.json'
20+
branches:
21+
- "main"
22+
- "develop"
23+
24+
jobs:
25+
test-js:
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
php_version: [ '8.0', '8.1', '8.2', '8.3' ]
30+
core: [ '6.3','6.4', '6.5', '6.6' ]
31+
name: E2E - WP ${{ matrix.core }} php@${{ matrix.php_version }}
32+
runs-on: ubuntu-22.04
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Set up PHP
38+
uses: shivammathur/setup-php@v2
39+
with:
40+
php-version: ${{ matrix.php_version }}
41+
ini-file: development
42+
coverage: none
43+
44+
- name: Get Composer Cache Directory
45+
id: composer-cache
46+
run: |
47+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
48+
- uses: actions/cache@v3
49+
with:
50+
path: ${{ steps.composer-cache.outputs.dir }}
51+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
52+
restore-keys: |
53+
${{ runner.os }}-composer-
54+
55+
- name: Override PHP version in composer.json
56+
run: composer config platform.php ${{ matrix.php_version }}
57+
58+
- name: Composer install
59+
run: composer install -o
60+
61+
- name: Setup Node
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: '20.11.*'
65+
cache: npm
66+
67+
- name: Install Node JS
68+
run: npm ci
69+
70+
- name: Install Playwright Browsers
71+
run: npx playwright install --with-deps
72+
73+
- name: Launch environment
74+
run: WP_ENV_PHP_VERSION=${{ matrix.php_version }} WP_ENV_CORE=WordPress/WordPress#${{ matrix.core }} npm run env:start-ci
75+
76+
- name: Updates dependencies for tests
77+
run: npm run env run tests-wordpress composer update -- -W --working-dir=/var/www/html/wp-content/plugins/wc-bretagne-2024/
78+
79+
- name: Compile CSS/JS
80+
run: npm run build
81+
82+
- name: Tests E2E
83+
env:
84+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
85+
run: npm run test:e2e
86+
87+
- name: Archive debug artifacts (screenshots, traces)
88+
uses: actions/upload-artifact@v4
89+
if: always()
90+
with:
91+
name: failures-artifacts-WP@${{ matrix.core }}-PHP@${{ matrix.php_version }}
92+
path: artifacts/test-results
93+
if-no-files-found: ignore

.github/workflows/tests-php.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
2+
3+
name: PHP Tests
4+
5+
on: # yamllint disable-line rule:truthy
6+
workflow_dispatch:
7+
pull_request:
8+
paths:
9+
- 'src/**'
10+
- 'includes/**'
11+
- 'tests/**'
12+
- 'composer.json'
13+
- '.github/workflows/tests.yml'
14+
push:
15+
paths:
16+
- 'includes/**'
17+
- 'tests/**'
18+
- 'composer.json'
19+
branches:
20+
- "main"
21+
- "develop"
22+
23+
jobs:
24+
test-php:
25+
strategy:
26+
matrix:
27+
php_version: [ '8.0', '8.1', '8.2', '8.3' ]
28+
core: [ '6.3','6.4', '6.5', '6.6' ]
29+
name: UNIT - WP ${{ matrix.core }} php@${{ matrix.php_version }}
30+
runs-on: ubuntu-22.04
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Set up PHP
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: ${{ matrix.php_version }}
39+
ini-file: development
40+
coverage: none
41+
42+
- name: Get Composer Cache Directory
43+
id: composer-cache
44+
run: |
45+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
46+
- uses: actions/cache@v3
47+
with:
48+
path: ${{ steps.composer-cache.outputs.dir }}
49+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
50+
restore-keys: |
51+
${{ runner.os }}-composer-
52+
53+
- name: Override PHP version in composer.json
54+
run: composer config platform.php ${{ matrix.php_version }}
55+
56+
- name: Composer install
57+
run: composer install -o
58+
59+
- name: Setup Node
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: '20.11.*'
63+
cache: npm
64+
65+
- name: Install JS dependencies
66+
run: npm ci
67+
68+
- name: Launch environment
69+
run: WP_ENV_PHP_VERSION=${{ matrix.php_version }} WP_ENV_CORE=WordPress/WordPress#${{ matrix.core }} npm run env:start-ci
70+
71+
- name: Updates dependencies for tests
72+
run: npm run env run tests-wordpress composer update -- -W --working-dir=/var/www/html/wp-content/plugins/wc-bretagne-2024/
73+
74+
- name: Update Yoast dependencies
75+
run: npm run env run tests-wordpress composer update -- --dev yoast/phpunit-polyfills -W --working-dir=/var/www/html/wp-content/plugins/wc-bretagne-2024/
76+
77+
- name: Compile CSS/JS
78+
run: npm run build
79+
80+
- name: Test PHP
81+
run: npm run test:php

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Build assets
2+
/build
3+
4+
# Logs
5+
*.log
6+
7+
# Dotenv
8+
.env
9+
!.env.example
10+
!tests/.env
11+
12+
# Composer
13+
/vendor
14+
15+
# Release
16+
/bin/release/
17+
18+
# Release zip
19+
/wc-bretagne-2024.zip
20+
21+
# Tests
22+
/coverage/
23+
/artifacts/
24+
test-coverage-html/
25+
.phpunit.result.cache
26+
tests/playwright/artifacts/
27+
28+
#Local
29+
.idea/
30+
31+
# Remove node
32+
node_modules

.wp-env.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/WordPress/gutenberg/trunk/schemas/json/wp-env.json",
3+
"phpVersion": "8.0",
4+
"plugins": [
5+
"."
6+
],
7+
"mappings": {
8+
"wp-cli.yml": "./tests/bin/wp-cli.yml",
9+
".htaccess": "./tests/bin/.htaccess"
10+
}
11+
}

composer.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "wc-bretagne-2024/demo",
3+
"description": "WC Bretagne",
4+
"minimum-stability": "stable",
5+
"license": "proprietary",
6+
"authors": [
7+
{
8+
"name": "njuen",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"config": {
13+
"optimize-autoloader": true,
14+
"preferred-install": "dist",
15+
"sort-packages": true,
16+
"allow-plugins": {
17+
"composer/installers": true,
18+
"dealerdirect/phpcodesniffer-composer-installer": true,
19+
"phpro/grumphp-shim": true,
20+
"roots/wordpress-core-installer": true
21+
}
22+
},
23+
"prefer-stable": true,
24+
"require": {
25+
"php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0",
26+
"ext-json": "*"
27+
},
28+
"autoload": {},
29+
"require-dev": {
30+
"wp-phpunit/wp-phpunit": "^6.4",
31+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
32+
"php-parallel-lint/php-parallel-lint": "^1.3",
33+
"phpcompatibility/php-compatibility": "^9.3",
34+
"phpcompatibility/phpcompatibility-wp": "^2.1",
35+
"roave/security-advisories": "dev-latest",
36+
"wp-coding-standards/wpcs": "^3.0",
37+
"yoast/phpunit-polyfills": "^1.0"
38+
},
39+
"scripts": {
40+
"cs": "./vendor/bin/phpcs",
41+
"cbf": "./vendor/bin/phpcbf",
42+
"lint": [
43+
"bin/php-lint",
44+
"@cs"
45+
]
46+
},
47+
"scripts-descriptions": {
48+
"cs": "Run PHP CodeSniffer on plugin codebase using our ruleset.",
49+
"cbf": "Run PHP Code Beautifier and Fixer on plugin codebase using our ruleset.",
50+
"lint": "Run all lint tasks."
51+
}
52+
}

0 commit comments

Comments
 (0)