Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
borkweb committed Dec 18, 2024
1 parent 7901deb commit 4a47240
Show file tree
Hide file tree
Showing 28 changed files with 1,086 additions and 3 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

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

[*.md]
trim_trailing_whitespace = true

[*.{neon,neon.dist}]
indent_style = tab

[**.{jshintrc,json,scss-lint,yml}]
indent_style = space
indent_size = 2
57 changes: 57 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This file will be consumed by both the CI and the tests.
# Some environment variables might not apply to one but might apply to the other: modify with care.

# What version of WordPress we want to install and test against.
# This has to be compatible with the `wp core download` command, see https://developer.wordpress.org/cli/commands/core/download/.
WP_VERSION=latest

# This is where, in the context of the CI, we'll install and configure WordPress.
# See `.travis.yml` for more information.
WP_ROOT_FOLDER=/tmp/wordpress

# The WordPress installation will be served from the Docker container.
# See `dev/docker/ci-compose.yml` for more information.
WP_URL=http://localhost:8080
WP_DOMAIN=localhost:8080

# The credentials that will be used to access the site in acceptance tests
# in methods like `$I->loginAsAdmin();`.
WP_ADMIN_USERNAME=admin
WP_ADMIN_PASSWORD=password

WP_DB_PORT=4306

# The databse is served from the Docker `db` container.
# See `dev/docker/ci-compose.yml` for more information.
WP_TABLE_PREFIX=wp_
WP_DB_HOST=127.0.0.1:4306
WP_DB_NAME=wordpress
WP_DB_USER=root
WP_DB_PASSWORD=

# The test databse is served from the Docker `db` container.
# See `dev/docker/ci-compose.yml` for more information.
WP_TEST_DB_HOST=127.0.0.1:4306
WP_TEST_DB_NAME=test
WP_TEST_DB_USER=root
WP_TEST_DB_PASSWORD=

# We're using Selenium and Chrome for acceptance testing.
# In CI context we're starting a Docker container to handle that.
# See the `dev/docker/ci-compose.yml` file.
CHROMEDRIVER_HOST=localhost
CHROMEDRIVER_PORT=4444

# The URL of the WordPress installation from the point of view of the Chromedriver container.
# Why not just use `wordpress`? While Chrome will accept an `http://wordpress` address WordPress
# will not, we call the WordPress container with a seemingly looking legit URL and leverage the
# lines that, in the `wp-config.php` file, will make it so that WordPress will use as its home
# URL whatever URL we reach it with.
# See the `dev/docker/wp-config.php` template for more information.
WP_CHROMEDRIVER_URL="wp.test"

# To run the tests let's force the background-processing lib to run in synchronous (single PHP thread) mode.
TRIBE_NO_ASYNC=1

# We're using Docker to run the tests.
USING_CONTAINERS=1
57 changes: 57 additions & 0 deletions .env.testing.slic
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This file will be consumed by both the CI and the tests.
# Some environment variables might not apply to one but might apply to the other: modify with care.

# What version of WordPress we want to install and test against.
# This has to be compatible with the `wp core download` command, see https://developer.wordpress.org/cli/commands/core/download/.
WP_VERSION=latest

# This is where, in the context of the CI, we'll install and configure WordPress.
# See `.travis.yml` for more information.
WP_ROOT_FOLDER=/var/www/html

# The WordPress installation will be served from the Docker container.
# See `dev/docker/ci-compose.yml` for more information.
WP_URL=http://wordpress.test
WP_DOMAIN=wordpress.test

# The credentials that will be used to access the site in acceptance tests
# in methods like `$I->loginAsAdmin();`.
WP_ADMIN_USERNAME=admin
WP_ADMIN_PASSWORD=password

WP_DB_PORT=3306

# The databse is served from the Docker `db` container.
# See `dev/docker/ci-compose.yml` for more information.
WP_TABLE_PREFIX=wp_
WP_DB_HOST=db
WP_DB_NAME=test
WP_DB_USER=root
WP_DB_PASSWORD=password

# The test databse is served from the Docker `db` container.
# See `dev/docker/ci-compose.yml` for more information.
WP_TEST_DB_HOST=db
WP_TEST_DB_NAME=test
WP_TEST_DB_USER=root
WP_TEST_DB_PASSWORD=password

# We're using Selenium and Chrome for acceptance testing.
# In CI context we're starting a Docker container to handle that.
# See the `dev/docker/ci-compose.yml` file.
CHROMEDRIVER_HOST=chrome
CHROMEDRIVER_PORT=4444

# The URL of the WordPress installation from the point of view of the Chromedriver container.
# Why not just use `wordpress`? While Chrome will accept an `http://wordpress` address WordPress
# will not, we call the WordPress container with a seemingly looking legit URL and leverage the
# lines that, in the `wp-config.php` file, will make it so that WordPress will use as its home
# URL whatever URL we reach it with.
# See the `dev/docker/wp-config.php` template for more information.
WP_CHROMEDRIVER_URL=http://wordpress.test

# To run the tests let's force the background-processing lib to run in synchronous (single PHP thread) mode.
TRIBE_NO_ASYNC=1

# We're using Docker to run the tests.
USING_CONTAINERS=1
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* text
.* export-ignore
composer.lock text -diff
phpstan.* export-ignore
phpunit.* export-ignore
tests export-ignore
44 changes: 44 additions & 0 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PHP Compatibility
on:
pull_request:
push:
branches:
- main
paths:
- '**.php'
jobs:
php-compatibility:
name: PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ["7.4", "8.0", "8.1", "8.2"]

steps:
- uses: actions/checkout@v4

- name: Configure PHP environment
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: mbstring, intl
coverage: none

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- uses: ramsey/composer-install@v3
with:
dependency-versions: highest

- name: Run PHP Compatibility
run: composer compatibility:php-${{ matrix.php-version }}
24 changes: 24 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Coding Standards
on:
pull_request:
push:
branches:
- main
paths:
- '**.php'
jobs:
phpcs:
name: phpcs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure PHP environment
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
- uses: ramsey/composer-install@v3
with:
composer-options: "--ignore-platform-reqs --optimize-autoloader"
- name: Run PHPCS
run: ./vendor/bin/phpcs src
26 changes: 26 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PHPStan
on:
pull_request:
push:
branches:
- main
paths:
- '**.php'
jobs:
phpstsan:
name: phpstan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Configure PHP environment
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: mbstring, intl
coverage: none
- uses: ramsey/composer-install@v2
with:
composer-options: "--ignore-platform-reqs --optimize-autoloader"
- name: Run PHPStan static analysis
run: composer test:analysis
79 changes: 79 additions & 0 deletions .github/workflows/tests-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: 'Tests'
on:
pull_request:
push:
branches:
- main
paths:
- '**.php'
jobs:
test:
strategy:
matrix:
suite:
- unit
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
fetch-depth: 1000
submodules: recursive
# ------------------------------------------------------------------------------
# Checkout slic
# ------------------------------------------------------------------------------
- name: Checkout slic
uses: actions/checkout@v2
with:
repository: stellarwp/slic
ref: main
path: slic
fetch-depth: 1
# ------------------------------------------------------------------------------
# Prepare our composer cache directory
# ------------------------------------------------------------------------------
- name: Get Composer Cache Directory
id: get-composer-cache-dir
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
id: composer-cache
with:
path: ${{ steps.get-composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
# ------------------------------------------------------------------------------
# Initialize slic
# ------------------------------------------------------------------------------
- name: Set up slic env vars
run: |
echo "SLIC_BIN=${GITHUB_WORKSPACE}/slic/slic" >> $GITHUB_ENV
echo "SLIC_WP_DIR=${GITHUB_WORKSPACE}/slic/_wordpress" >> $GITHUB_ENV
echo "SLIC_WORDPRESS_DOCKERFILE=Dockerfile.base" >> $GITHUB_ENV
- name: Set run context for slic
run: echo "SLIC=1" >> $GITHUB_ENV && echo "CI=1" >> $GITHUB_ENV
- name: Start ssh-agent
run: |
mkdir -p "${HOME}/.ssh";
ssh-agent -a /tmp/ssh_agent.sock;
- name: Export SSH_AUTH_SOCK env var
run: echo "SSH_AUTH_SOCK=/tmp/ssh_agent.sock" >> $GITHUB_ENV
- name: Set up slic for CI
run: |
cd ${GITHUB_WORKSPACE}/..
${SLIC_BIN} here
${SLIC_BIN} interactive off
${SLIC_BIN} build-prompt off
${SLIC_BIN} build-subdir off
${SLIC_BIN} xdebug off
${SLIC_BIN} debug on
${SLIC_BIN} info
${SLIC_BIN} config
${SLIC_BIN} wp core update --version=6.4 --force
- name: Set up StellarWP Memoize
run: |
${SLIC_BIN} use memoize
${SLIC_BIN} composer install
- name: Run suites
run: ${SLIC_BIN} run ${{ matrix.suite }} --ext DotReporter
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
composer.lock
files/
repo/
vendor/
tests/_support/_generated
bin/*.phar

# Dev tools
.buildpath
*.iml
.project
.idea/
.vscode/

# Third party dependencies
vendor/

# Tests
codeception.yml
tests/_output/*
tests/*.suite.yml
!tests/_data/dump.sql
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 StellarWP
Copyright (c) 2023 StellarWP

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 4a47240

Please sign in to comment.