Skip to content

Commit

Permalink
:xuild(docker-compose.yml, bin/stack) update img ns
Browse files Browse the repository at this point in the history
  • Loading branch information
lucatume committed Jun 22, 2023
1 parent 78ab13a commit 9b67607
Show file tree
Hide file tree
Showing 22 changed files with 52,394 additions and 1,839 deletions.
68 changes: 56 additions & 12 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,44 @@ jobs:
context: containers/php
file: containers/php/Dockerfile-PHP-5.6
push: false
tags: wp-browser-wordpress:php5.6-apache
tags: lucatume/wp-browser-v3-build:php5.6-apache
cache-from: type=gha,scope=5.6
cache-to: type=gha,mode=max,scope=5.6
build-args: |
PHP_VERSION=5.6
TARGET=wordpress
USER_UID=33
USER_GID=33
USER_NAME=www-data
- name: Build Codeception image
uses: docker/build-push-action@v4
with:
context: containers/php
file: containers/php/Dockerfile-PHP-5.6
push: false
tags: wp-browser-wordpress:php5.6-codeception
tags: lucatume/wp-browser-v3-build:php5.6-codeception
cache-from: type=gha,scope=5.6
cache-to: type=gha,mode=max,scope=5.6
build-args: |
PHP_VERSION=5.6
TARGET=codeception
USER_UID=33
USER_GID=33
USER_NAME=www-data
- name: Build stack
run: bin/stack -p5.6 build
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: var/cache/composer
key: ${{ runner.os }}-${{ hashFiles('**/composer.json') }}-${{ matrix.codeception_version }}
- name: Place Composer files
run: |
rm -f composer.json composer.lock
cp config/composer/composer-5.6-codeception-${{ matrix.codeception_version }}.json composer.json
cp config/composer/composer-5.6-codeception-${{ matrix.codeception_version }}.lock composer.lock
- name: Install dependencies
run: bin/stack -p5.6 -c${{ matrix.codeception_version }} composer_update
run: bin/stack -p5.6 -c${{ matrix.codeception_version }} composer_install
- name: Test
run: bin/stack -p5.6 test
test_codeception_lt_4_php_74:
Expand All @@ -62,33 +73,44 @@ jobs:
context: containers/php
file: containers/php/Dockerfile
push: false
tags: wp-browser-wordpress:php7.4-apache
tags: lucatume/wp-browser-v3-build:php7.4-apache
cache-from: type=gha,scope=7.4
cache-to: type=gha,mode=max,scope=7.4
build-args: |
PHP_VERSION=7.4
TARGET=wordpress
USER_UID=33
USER_GID=33
USER_NAME=www-data
- name: Build Codeception image
uses: docker/build-push-action@v4
with:
context: containers/php
file: containers/php/Dockerfile
push: false
tags: wp-browser-wordpress:php7.4-codeception
tags: lucatume/wp-browser-v3-build:php7.4-codeception
cache-from: type=gha,scope=7.4
cache-to: type=gha,mode=max,scope=7.4
build-args: |
PHP_VERSION=7.4
TARGET=codeception
USER_UID=33
USER_GID=33
USER_NAME=www-data
- name: Build stack
run: bin/stack -p7.4 build
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: var/cache/composer
key: ${{ runner.os }}-${{ hashFiles('**/composer.json') }}-${{ matrix.codeception_version }}
- name: Place Composer files
run: |
rm -f composer.json composer.lock
cp config/composer/composer-7.4-codeception-${{ matrix.codeception_version }}.json composer.json
cp config/composer/composer-7.4-codeception-${{ matrix.codeception_version }}.lock composer.lock
- name: Install dependencies
run: bin/stack -p7.4 -c${{ matrix.codeception_version }} composer_update
run: bin/stack -p7.4 -c${{ matrix.codeception_version }} composer_install
- name: Test
run: bin/stack -p7.4 test
test_codeception_4_php_56:
Expand All @@ -104,33 +126,44 @@ jobs:
context: containers/php
file: containers/php/Dockerfile-PHP-5.6
push: false
tags: wp-browser-wordpress:php5.6-apache
tags: lucatume/wp-browser-v3-build:php5.6-apache
cache-from: type=gha,scope=5.6
cache-to: type=gha,mode=max,scope=5.6
build-args: |
PHP_VERSION=5.6
TARGET=wordpress
USER_UID=33
USER_GID=33
USER_NAME=www-data
- name: Build Codeception image
uses: docker/build-push-action@v4
with:
context: containers/php
file: containers/php/Dockerfile-PHP-5.6
push: false
tags: wp-browser-wordpress:php5.6-codeception
tags: lucatume/wp-browser-v3-build:php5.6-codeception
cache-from: type=gha,scope=5.6
cache-to: type=gha,mode=max,scope=5.6
build-args: |
PHP_VERSION=5.6
TARGET=codeception
USER_UID=33
USER_GID=33
USER_NAME=www-data
- name: Build
run: bin/stack -p5.6 build
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: var/cache/composer
key: ${{ runner.os }}-${{ hashFiles('**/composer.codecept-4.json') }}-${{ matrix.codeception_version }}
- name: Place Composer files
run: |
rm -f composer.json composer.lock
cp config/composer/composer-5.6-codeception-4.json composer.json
cp config/composer/composer-5.6-codeception-4.lock composer.lock
- name: Install dependencies
run: bin/stack -p5.6 -c4 composer_update
run: bin/stack -p5.6 -c4 composer_install
- name: Test
run: bin/stack -p5.6 test
test_codeception_4:
Expand All @@ -149,32 +182,43 @@ jobs:
context: containers/php
file: containers/php/Dockerfile
push: false
tags: wp-browser-wordpress:php${{ matrix.php_version }}-apache
tags: lucatume/wp-browser-v3-build:php${{ matrix.php_version }}-apache
cache-from: type=gha,scope=${{ matrix.php_version }}
cache-to: type=gha,mode=max,scope=${{ matrix.php_version }}
build-args: |
PHP_VERSION=${{ matrix.php_version }}
TARGET=wordpress
USER_UID=33
USER_GID=33
USER_NAME=www-data
- name: Build Codeception image
uses: docker/build-push-action@v4
with:
context: containers/php
file: containers/php/Dockerfile
push: false
tags: wp-browser-wordpress:php${{ matrix.php_version }}-codeception
tags: lucatume/wp-browser-v3-build:php${{ matrix.php_version }}-codeception
cache-from: type=gha,scope=${{ matrix.php_version }}
cache-to: type=gha,mode=max,scope=${{ matrix.php_version }}
build-args: |
PHP_VERSION=${{ matrix.php_version }}
TARGET=codeception
USER_UID=33
USER_GID=33
USER_NAME=www-data
- name: Build
run: bin/stack -p${{ matrix.php_version }} build
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: var/cache/composer
key: ${{ runner.os }}-${{ hashFiles('**/composer.codecept-4.json') }}-${{ matrix.codeception_version }}
- name: Place Composer files
run: |
rm -f composer.json composer.lock
cp config/composer/composer-${{ matrix.php_version }}-codeception-4.json composer.json
cp config/composer/composer-${{ matrix.php_version }}-codeception-4.lock composer.lock
- name: Install dependencies
run: bin/stack -p${{ matrix.php_version }} -c4 composer_update
run: bin/stack -p${{ matrix.php_version }} -c4 composer_install
- name: Test
run: bin/stack -p${{ matrix.php_version }} test
63 changes: 60 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,66 @@ build_images:
bin/stack -p8.0 build_images
bin/stack -p8.1 build_images

build_56_lock_files:
[ -d config/composer ] || mkdir config/composer
cp composer.json config/composer.json.bak

bin/stack -p5.6 -c2 composer_update
mv composer.json config/composer/composer-5.6-codeception-2.json
mv composer.lock config/composer/composer-5.6-codeception-2.lock
cp config/composer/composer.json.bak composer.json

bin/stack -p5.6 -c3 composer_update
mv composer.json config/composer/composer-5.6-codeception-3.json
mv composer.lock config/composer/composer-5.6-codeception-3.lock
cp config/composer/composer.json.bak composer.json

bin/stack -p5.6 -c4 composer_update
mv composer.json config/composer/composer-5.6-codeception-4.json
mv composer.lock config/composer/composer-5.6-codeception-4.lock

mv config/composer/composer.json.bak composer.json

build_74_lock_files:
[ -d config/composer ] || mkdir config/composer
cp composer.json config/composer/composer.json.bak

bin/stack -p7.4 -d -c2 composer_update
mv composer.json config/composer/composer-7.4-codeception-2.json
mv composer.lock config/composer/composer-7.4-codeception-2.lock
cp config/composer/composer.json.bak composer.json

bin/stack -p7.4 -d -c3 composer_update
mv composer.json config/composer/composer-7.4-codeception-3.json
mv composer.lock config/composer/composer-7.4-codeception-3.lock
cp config/composer/composer.json.bak composer.json

bin/stack -p7.4 -d -c4 composer_update
mv composer.json config/composer/composer-7.4-codeception-4.json
mv composer.lock config/composer/composer-7.4-codeception-4.lock

mv config/composer/composer.json.bak composer.json

build_80_lock_files:
[ -d config/composer ] || mkdir config/composer
cp composer.json config/composer/composer.json.bak

bin/stack -p8.0 -d -c4 composer_update
mv composer.json config/composer/composer-8.0-codeception-4.json
mv composer.lock config/composer/composer-8.0-codeception-4.lock

mv config/composer/composer.json.bak composer.json

build_81_lock_files:
[ -d config/composer ] || mkdir config/composer
cp composer.json config/composer/composer.json.bak

bin/stack -p8.1 -d -c4 composer_update
mv composer.json config/composer/composer-8.1-codeception-4.json
mv composer.lock config/composer/composer-8.1-codeception-4.lock

mv config/composer/composer.json.bak composer.json

lint:
docker run --rm \
--volume "$(PWD):$(PWD):ro" \
Expand Down Expand Up @@ -63,9 +123,6 @@ phpstan:
--workdir "$(PWD)" \
lucatume/wpstan:0.12.42 analyze \
-l max
phpstan:
docker run --rm --volume "$(PWD):$(PWD):ro" --workdir "$(PWD)" lucatume/wpstan:0.12.42 analyze -l max
.PHONY: phpstan

static_analysis: lint phpcs phpstan
.PHONE: static_analysis
Expand Down
40 changes: 18 additions & 22 deletions bin/stack
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function run_wp_cli_command() {
--network "wpbrowser_php_${PHP_VERSION}" \
-w /var/www/html \
-u "${USER_UID}:${USER_GID}" \
"wp-browser-v3-wordpress:php${PHP_VERSION}-apache" \
"lucatume/wp-browser-v3-build:php${PHP_VERSION}-apache" \
wp --allow-root --url=http://wordpress.test --path=/var/www/html "$@"
}

Expand All @@ -168,7 +168,7 @@ function ensure_wordpress_configured() {
--network "wpbrowser_php_${PHP_VERSION}" \
-w /var/www/html \
-u "${USER_UID}:${USER_GID}" \
"wp-browser-v3-wordpress:php${PHP_VERSION}-apache" \
"lucatume/wp-browser-v3-build:php${PHP_VERSION}-apache" \
bash -c "wp --allow-root core config --dbname=wordpress --dbuser=root --dbpass=password --dbhost=database --dbprefix=wp_ --extra-php <<PHP
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
Expand Down Expand Up @@ -226,6 +226,7 @@ function build_images() {
if [ "${PHP_VERSION}" = "5.6" ]; then
export DOCKERFILE_SUFFIX="-PHP-5.6"
fi

docker compose build wordpress || exit 1
docker compose build codecept || exit 1
}
Expand Down Expand Up @@ -256,8 +257,8 @@ function clean() {
for version in "${SUPPORTED_PHP_VERSIONS[@]}"; do
PHP_VERSION=$version docker compose down -v
PHP_VERSION=$version docker compose rm -f
docker rmi "wp-browser-v3-wordpress:php${version}-apache"
docker rmi "wp-browser-v3-wordpress:php${version}-codeception"
docker rmi "lucatume/wp-browser-v3-build:php${version}-apache"
docker rmi "lucatume/wp-browser-v3-build:php${version}-codeception"
done

rm -rf var/wordpress
Expand All @@ -276,16 +277,16 @@ function config() {
}

function composer_run() {
docker compose exec \
docker compose run --rm \
-u "$(id -u):$(id -g)" \
-w "$(pwd)" \
codecept \
bash -c "composer $*" || exit 1
--no-deps \
--entrypoint=bash \
codecept -c "composer $*" || exit 1
}

function composer_update() {
rm -rf vendor composer.lock || exit 1
xdebug_off

if [ "${CODECEPTION_VERSION}" != "4" ]; then
composer_run remove \
Expand All @@ -298,30 +299,25 @@ function composer_update() {
codeception/util-universalframework
fi

if [ "${CODECEPTION_VERSION}" = "3" ]; then
composer_run remove codeception/lib-asserts
fi

docker compose exec \
-u "$(id -u):$(id -g)" \
-w "$(pwd)" \
codecept \
bash -c "composer update -o -a -n -W" &&
composer_run require codeception/codeception:^"${CODECEPTION_VERSION}" -W -n

if [ "${CODECEPTION_VERSION}" = "4" ]; then
composer_run require \
codeception/lib-asserts:^1.0 \
composer_run require -W -n \
codeception/codeception:^"${CODECEPTION_VERSION}" \
codeception/module-asserts:^1.0 \
codeception/module-phpbrowser:^1.0 \
codeception/module-webdriver:^1.0 \
codeception/module-db:^1.0 \
codeception/module-filesystem:^1.0 \
codeception/module-cli:^1.0 \
codeception/util-universalframework:^1.0
codeception/util-universalframework:^1.0 -W -n --prefer-lowest
else
composer_run require -W -n codeception/codeception:^"${CODECEPTION_VERSION}" --prefer-lowest
fi
}

function composer_install(){
composer_run install --no-interaction --no-progress --no-suggest --no-scripts --no-autoloader || exit 1
}

function run_tests() {
ensure_test_databases
xdebug_off
Expand Down
Loading

0 comments on commit 9b67607

Please sign in to comment.