Skip to content

Commit

Permalink
Initial commits
Browse files Browse the repository at this point in the history
  • Loading branch information
tfirdaus committed Sep 16, 2024
1 parent e829637 commit 905b7c0
Show file tree
Hide file tree
Showing 91 changed files with 5,759 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/docker-existing-docker-compose
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
{
"name": "syntatis/codex",
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"../docker-compose.yml"
],
// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "wp",
// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/var/www/workspace",
// Set *default* container specific settings.json values on container create.
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash",
"args": [
"-l"
]
}
},
"terminal.integrated.defaultProfile.linux": "bash"
},
"extensions": [
"bmewburn.vscode-intelephense-client",
"editorconfig.editorconfig",
"felixfbecker.php-debug",
"getpsalm.psalm-vscode-plugin",
"github.vscode-pull-request-github",
"johnbillion.vscode-wordpress-hooks",
"neilbrayfield.php-docblocker",
"wongjn.php-sniffer",
"wordpresstoolbox.wordpress-toolbox",
"SanderRonde.phpstan-vscode",
"xdebug.php-debug"
]
}
}
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",
// Uncomment the next line to run commands after the container is created - for example installing curl.
// "postCreateCommand": "bin/container-init.sh"
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "www-data"
}
3 changes: 3 additions & 0 deletions .devcontainer/php/xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
zend_extension=xdebug
xdebug.mode=debug,coverage
xdebug.client_host=host.docker.internal
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.{json,neon,neon.dist,yml,md}]
indent_size = 2

[*.{yml,md}]
indent_style = space
24 changes: 24 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ====================================================================== #
# Environment variables to pass in the Docker container. #
# ====================================================================== #

## Website Variables
SITE_IMAGE=ghcr.io/syntatis/wp:php7.4-fpm
SITE_PORT=7004
SITE_HOST=localhost
SITE_TITLE=syntatis/codex
SITE_ADMIN_USER=admin
SITE_ADMIN_PASS=admin
SITE_ADMIN_EMAIL=admin@syntatis.net

## Database Variables
DB_IMAGE=mariadb:10.11.6

### Database Variables (Test)
DB_TEST_HOST=db_test
DB_TEST_PORT=3306
DB_TEST_PORT_PUBLISHED=8004
DB_TEST_NAME=wp_test
DB_TEST_USER=wp_test
DB_TEST_PASS=wp_test
DB_TEST_ROOT_PASS=root
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ]
}
19 changes: 19 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.devcontainer export-ignore
/.editorconfig export-ignore
/.env export-ignore
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/.vscode export-ignore
/CODE_OF_CONDUCT.md export-ignore
/codecov.yml export-ignore
/docker-compose.yml export-ignore
/docs export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
28 changes: 28 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"

- package-ecosystem: "composer"
versioning-strategy: increase
open-pull-requests-limit: 5
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]
groups:
composer-require:
dependency-type: "production"
update-types:
- "minor"
- "patch"
composer-require-dev:
dependency-type: "development"
update-types:
- "minor"
- "patch"
145 changes: 145 additions & 0 deletions .github/workflows/wp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: wp

on:
workflow_dispatch:
pull_request:
types: [opened, reopened, synchronize]
branches:
- main
paths:
- ".github/workflows/wp.yml"
- "**.php"
- "composer.json"
- "phpcs.xml.dist"
- "phpstan.neon.dist"
- "phpunit.xml.dist"
push:
branches:
- main
paths:
- ".github/workflows/wp.yml"
- "**.php"
- "composer.json"
- "phpcs.xml.dist"
- "phpstan.neon.dist"
- "phpunit.xml.dist"

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Setup Composer cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: php-7.4-composer-${{ hashFiles('**/composer.json') }}
restore-keys: php-7.4-composer-

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer:v2

- name: Install dependencies
run: composer install --prefer-dist

- name: Check PSR-4 mapping
run: composer dump-autoload --dev --optimize --strict-psr

- name: Lint codes
run: composer phpcs

test:
runs-on: ubuntu-latest
if: ${{ success() }}
needs: lint
env:
WP_DB_TEST_NAME: wp_test
WP_DB_TEST_PASS: wp_test
WP_DB_TEST_USER: wp_test
PHP_EXTENSIONS: mysqli

strategy:
fail-fast: true
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
wp: ['5.*', '6.*']

services:
database:
image: 'mariadb:10.11.5'
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ${{ env.WP_DB_TEST_NAME }}
MYSQL_USER: ${{ env.WP_DB_TEST_USER }}
MYSQL_PASSWORD: ${{ env.WP_DB_TEST_PASS }}
ports:
- 3306:3306
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Setup PHP extensions cache environment
id: php-ext-cache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.PHP_EXTENSIONS }}
key: php-${{ matrix.php }}-ext

- name: Setup PHP extensions cache
uses: actions/cache@v4
with:
path: ${{ steps.php-ext-cache.outputs.dir }}
key: ${{ steps.php-ext-cache.outputs.key }}
restore-keys: ${{ steps.php-ext-cache.outputs.key }}

- name: Setup Composer cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: php-${{ matrix.php }}-composer-

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.PHP_EXTENSIONS }}
tools: composer:v2

- name: Install dependencies
run: |
composer require "wp-phpunit/wp-phpunit:${{ matrix.wp }}" "roots/wordpress:${{ matrix.wp }}" --no-interaction --no-update --dev
composer install --prefer-dist
- name: Run test
continue-on-error: ${{ matrix.php == '8.4' }}
run: |
composer phpstan
vendor/bin/phpunit --coverage-clover coverage.xml
env:
WP_DB_TEST_HOST: 127.0.0.1:${{ job.services.database.ports['3306'] }}
WP_ENVIRONMENT_TYPE: development

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# OS generated files #
######################
.DS_Store
Thumbs.db

# Logs and databases #
######################
*.sql

# Compiled source #
###################
*.tar.gz
*.zip

# Graphics #
############
*.psd

# Dependency #
##########################
node_modules/
vendor/
composer.lock

# Tests #
#############
artifacts/
phpunit.xml
coverage.xml

# Temporary #
#############
tmp/

# WordPress #
###########
wp-cli.local.yml
wordpress/
14 changes: 14 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"recommendations": [
"bmewburn.vscode-intelephense-client",
"editorconfig.editorconfig",
"felixfbecker.php-debug",
"getpsalm.psalm-vscode-plugin",
"johnbillion.vscode-wordpress-hooks",
"ms-azuretools.vscode-docker",
"neilbrayfield.php-docblocker",
"wongjn.php-sniffer",
"wordpresstoolbox.wordpress-toolbox",
"sanderronde.phpstan-vscode"
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
// Auto format PHP using vscode format
"files.autoSave": "off",
"phpstan.enabled": false,
"phpSniffer.autoDetect": true,
"phpSniffer.run": "onSave",
"[php]": {
"editor.defaultFormatter": "wongjn.php-sniffer"
},
}
Loading

0 comments on commit 905b7c0

Please sign in to comment.