Skip to content

Commit

Permalink
feat: add shopware bash script tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janosmiko committed Nov 25, 2024
1 parent 44dbe57 commit e0d48d8
Show file tree
Hide file tree
Showing 62 changed files with 123 additions and 47 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/main-docker-image-php-fpm-magento2-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
curl -s https://bashunit.typeddevs.com/install.sh | bash -s -- /usr/local/bin
- name: "Test"
run: 'find images/php-fpm/magento2-web/ -name "*_test.sh" -type f -print0 | xargs -0 -t bashunit'
run: 'find images/_php-fpm-common/magento2-web/ -name "*_test.sh" -type f -print0 | xargs -0 -t bashunit'

build:
name: "Build php-fpm/magento2-web"
needs: [ test ]
runs-on: ubuntu-latest
needs: [ test ]
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
strategy:
matrix:
Expand Down Expand Up @@ -115,6 +115,8 @@ jobs:
if: ${{ matrix.DEFAULT_IMAGE == 'true' }}
with:
context: images/php-fpm/magento2-web/context
build-contexts: |
scripts=images/_php-fpm-common/magento2-web
file: images/php-fpm/magento2-web/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
Expand All @@ -130,6 +132,8 @@ jobs:
if: ${{ matrix.DEFAULT_IMAGE != 'true' }}
with:
context: images/php-fpm/magento2-web/context
build-contexts: |
scripts=images/_php-fpm-common/magento2-web
file: images/php-fpm/magento2-web/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
curl -s https://bashunit.typeddevs.com/install.sh | bash -s -- /usr/local/bin
- name: "Test"
run: 'find images/php-fpm-rootless/magento2-web/ -name "*_test.sh" -type f -print0 | xargs -0 -t bashunit'
run: 'find images/_php-fpm-common/magento2-web/ -name "*_test.sh" -type f -print0 | xargs -0 -t bashunit'

build:
name: "Build php-fpm-rootless/magento2-web"
needs: [ test ]
runs-on: ubuntu-latest
needs: [ test ]
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
strategy:
matrix:
Expand Down Expand Up @@ -115,6 +115,8 @@ jobs:
if: ${{ matrix.DEFAULT_IMAGE == 'true' }}
with:
context: images/php-fpm-rootless/magento2-web/context
build-contexts: |
scripts=images/_php-fpm-common/magento2-web
file: images/php-fpm-rootless/magento2-web/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
Expand All @@ -130,6 +132,8 @@ jobs:
if: ${{ matrix.DEFAULT_IMAGE != 'true' }}
with:
context: images/php-fpm-rootless/magento2-web/context
build-contexts: |
scripts=images/_php-fpm-common/magento2-web
file: images/php-fpm-rootless/magento2-web/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
curl -s https://bashunit.typeddevs.com/install.sh | bash -s -- /usr/local/bin
- name: "Test"
run: 'find images/php-fpm-rootless/shopware-web/ -name "*_test.sh" -type f -print0 | xargs -0 -t bashunit'
run: 'find images/_php-fpm-common/shopware-web/ -name "*_test.sh" -type f -print0 | xargs -0 -t bashunit'

build:
name: "Build php-fpm-rootless/shopware-web"
needs: [ test ]
runs-on: ubuntu-latest
needs: [ test ]
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
strategy:
matrix:
Expand Down Expand Up @@ -115,6 +115,8 @@ jobs:
if: ${{ matrix.DEFAULT_IMAGE == 'true' }}
with:
context: images/php-fpm-rootless/shopware-web/context
build-contexts: |
scripts=images/_php-fpm-common/shopware-web
file: images/php-fpm-rootless/shopware-web/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
Expand All @@ -130,6 +132,8 @@ jobs:
if: ${{ matrix.DEFAULT_IMAGE != 'true' }}
with:
context: images/php-fpm-rootless/shopware-web/context
build-contexts: |
scripts=images/_php-fpm-common/shopware-web
file: images/php-fpm-rootless/shopware-web/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
curl -s https://bashunit.typeddevs.com/install.sh | bash -s -- /usr/local/bin
- name: "Test"
run: 'find images/php-fpm-rootless/wordpress-web/ -name "*_test.sh" -type f -print0 | xargs -0 -t bashunit'
run: 'find images/_php-fpm-common/wordpress-web/ -name "*_test.sh" -type f -print0 | xargs -0 -t bashunit'

build:
name: "Build php-fpm-rootless/wordpress-web"
Expand Down Expand Up @@ -115,6 +115,8 @@ jobs:
if: ${{ matrix.DEFAULT_IMAGE == 'true' }}
with:
context: images/php-fpm-rootless/wordpress-web/context
build-contexts: |
scripts=images/_php-fpm-common/wordpress-web
file: images/php-fpm-rootless/wordpress-web/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
Expand All @@ -130,6 +132,8 @@ jobs:
if: ${{ matrix.DEFAULT_IMAGE != 'true' }}
with:
context: images/php-fpm-rootless/wordpress-web/context
build-contexts: |
scripts=images/_php-fpm-common/wordpress-web
file: images/php-fpm-rootless/wordpress-web/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/main-docker-image-php-fpm-shopware-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:

build:
name: "Build php-fpm/shopware-web"
needs: [ test ]
runs-on: ubuntu-latest
needs: [ test ]
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
strategy:
matrix:
Expand Down Expand Up @@ -115,6 +115,8 @@ jobs:
if: ${{ matrix.DEFAULT_IMAGE == 'true' }}
with:
context: images/php-fpm/shopware-web/context
build-contexts: |
scripts=images/_php-fpm-common/shopware-web
file: images/php-fpm/shopware-web/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
Expand All @@ -130,6 +132,8 @@ jobs:
if: ${{ matrix.DEFAULT_IMAGE != 'true' }}
with:
context: images/php-fpm/shopware-web/context
build-contexts: |
scripts=images/_php-fpm-common/shopware-web
file: images/php-fpm/shopware-web/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/main-docker-image-php-fpm-wordpress-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
curl -s https://bashunit.typeddevs.com/install.sh | bash -s -- /usr/local/bin
- name: "Test"
run: 'find images/php-fpm/wordpress-web/ -name "*_test.sh" -type f -print0 | xargs -0 -t bashunit'
run: 'find images/_php-fpm-common/wordpress-web/ -name "*_test.sh" -type f -print0 | xargs -0 -t bashunit'

build:
name: "Build php-fpm/wordpress-web"
needs: [ test ]
runs-on: ubuntu-latest
needs: [ test ]
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
strategy:
matrix:
Expand Down Expand Up @@ -115,6 +115,8 @@ jobs:
if: ${{ matrix.DEFAULT_IMAGE == 'true' }}
with:
context: images/php-fpm/wordpress-web/context
build-contexts: |
scripts=images/_php-fpm-common/wordpress-web
file: images/php-fpm/wordpress-web/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
Expand All @@ -130,6 +132,8 @@ jobs:
if: ${{ matrix.DEFAULT_IMAGE != 'true' }}
with:
context: images/php-fpm/wordpress-web/context
build-contexts: |
scripts=images/_php-fpm-common/wordpress-web
file: images/php-fpm/wordpress-web/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
Expand Down
10 changes: 10 additions & 0 deletions images/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,18 @@ gomplate -f images/php-fpm-rootless/base/tpl.Dockerfile -o - \
-f - \
-t rewardenv/php-fpm:${PHP_VERSION} \
--build-arg PHP_VERSION \
--build-context scripts=images/_php-fpm-scripts/context/
--progress plain \
images/php-fpm-rootless/base/context

gomplate -f images/php-fpm-rootless/shopware-web/tpl.Dockerfile -o - \
| docker build \
-f - \
-t rewardenv/php-fpm:${PHP_VERSION}-shopware-web \
--build-arg PHP_VERSION \
--build-context scripts=images/_php-fpm-common/shopware-web \
--progress plain \
images/php-fpm-rootless/shopware-web/context
```

## SSHD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,25 @@ function test_app_path() {
}

function test_version_gt() {
assert_true "$(version_gt '2.4.4' '2.3.99')"
assert_false "$(version_gt '2.3.99' '2.4.4')"
assert_false "$(version_gt '2.4.4' '2.4.4')"
assert_true "$(version_gt '2.4' '2.3.99')"
assert_false "$(version_gt '2.3.99' '2.4')"
assert_false "$(version_gt '2.4' '2.4')"
assert_exit_code 0 "$(version_gt '2.4.4' '2.3.99')"
assert_exit_code 1 "$(version_gt '2.3.99' '2.4.4')"
assert_exit_code 1 "$(version_gt '2.4.4' '2.4.4')"
assert_exit_code 0 "$(version_gt '2.4' '2.3.99')"
assert_exit_code 1 "$(version_gt '2.3.99' '2.4')"
assert_exit_code 1 "$(version_gt '2.4' '2.4')"
assert_exit_code 0 "$(version_gt 'v2.4.4' '2.3.99')"
assert_exit_code 1 "$(version_gt '2.3.99' 'v2.4.4')"
assert_exit_code 1 "$(version_gt 'v2.4.4' 'v2.4.4')"
assert_exit_code 0 "$(version_gt '2.4' 'v2.3.99')"
assert_exit_code 1 "$(version_gt 'v2.3.99' '2.4')"
assert_exit_code 1 "$(version_gt 'v2.4' '2.4')"

if version_gt '2.3.99' '2.4.0'; then
fail
fi
if ! version_gt '2.4.0' 'v2.3.99.99'; then
fail
fi
}

function test_run_hooks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,25 @@ function test_app_path() {
}

function test_version_gt() {
assert_true "$(version_gt '2.4.4' '2.3.99')"
assert_false "$(version_gt '2.3.99' '2.4.4')"
assert_false "$(version_gt '2.4.4' '2.4.4')"
assert_true "$(version_gt '2.4' '2.3.99')"
assert_false "$(version_gt '2.3.99' '2.4')"
assert_false "$(version_gt '2.4' '2.4')"
assert_exit_code 0 "$(version_gt '2.4.4' '2.3.99')"
assert_exit_code 1 "$(version_gt '2.3.99' '2.4.4')"
assert_exit_code 1 "$(version_gt '2.4.4' '2.4.4')"
assert_exit_code 0 "$(version_gt '2.4' '2.3.99')"
assert_exit_code 1 "$(version_gt '2.3.99' '2.4')"
assert_exit_code 1 "$(version_gt '2.4' '2.4')"
assert_exit_code 0 "$(version_gt 'v2.4.4' '2.3.99')"
assert_exit_code 1 "$(version_gt '2.3.99' 'v2.4.4')"
assert_exit_code 1 "$(version_gt 'v2.4.4' 'v2.4.4')"
assert_exit_code 0 "$(version_gt '2.4' 'v2.3.99')"
assert_exit_code 1 "$(version_gt 'v2.3.99' '2.4')"
assert_exit_code 1 "$(version_gt 'v2.4' '2.4')"

if version_gt '2.3.99' '2.4.0'; then
fail
fi
if ! version_gt '2.4.0' 'v2.3.99.99'; then
fail
fi
}

function test_run_hooks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,25 @@ function test_app_path() {
}

function test_version_gt() {
assert_true "$(version_gt '2.4.4' '2.3.99')"
assert_false "$(version_gt '2.3.99' '2.4.4')"
assert_false "$(version_gt '2.4.4' '2.4.4')"
assert_true "$(version_gt '2.4' '2.3.99')"
assert_false "$(version_gt '2.3.99' '2.4')"
assert_false "$(version_gt '2.4' '2.4')"
assert_exit_code 0 "$(version_gt '2.4.4' '2.3.99')"
assert_exit_code 1 "$(version_gt '2.3.99' '2.4.4')"
assert_exit_code 1 "$(version_gt '2.4.4' '2.4.4')"
assert_exit_code 0 "$(version_gt '2.4' '2.3.99')"
assert_exit_code 1 "$(version_gt '2.3.99' '2.4')"
assert_exit_code 1 "$(version_gt '2.4' '2.4')"
assert_exit_code 0 "$(version_gt 'v2.4.4' '2.3.99')"
assert_exit_code 1 "$(version_gt '2.3.99' 'v2.4.4')"
assert_exit_code 1 "$(version_gt 'v2.4.4' 'v2.4.4')"
assert_exit_code 0 "$(version_gt '2.4' 'v2.3.99')"
assert_exit_code 1 "$(version_gt 'v2.3.99' '2.4')"
assert_exit_code 1 "$(version_gt 'v2.4' '2.4')"

if version_gt '2.3.99' '2.4.0'; then
fail
fi
if ! version_gt '2.4.0' 'v2.3.99.99'; then
fail
fi
}

function test_run_hooks() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

version_gt() { test "$(printf "%s\n" "$@" | sort -V | head -n 1)" != "$1"; }
version_gt() { test "$(printf '%s\n' "${@#v}" | sort -V | head -n 1)" != "${1#v}"; }

shopt -s expand_aliases
if [ -f "${HOME}/.bash_alias" ]; then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

version_gt() { test "$(printf "%s\n" "$@" | sort -V | head -n 1)" != "$1"; }
version_gt() { test "$(printf '%s\n' "${@#v}" | sort -V | head -n 1)" != "${1#v}"; }

shopt -s expand_aliases
if [ -f "${HOME}/.bash_alias" ]; then
Expand Down
4 changes: 2 additions & 2 deletions images/php-fpm-rootless/magento2-web/tpl.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1
# syntax=docker/dockerfile:1.7-labs
{{- $BASE_IMAGE_NAME := getenv "BASE_IMAGE_NAME" "ubuntu" }}
{{- $BASE_IMAGE_TAG := getenv "BASE_IMAGE_TAG" "jammy" }}
ARG IMAGE_NAME="rewardenv/php-fpm"
Expand Down Expand Up @@ -32,7 +32,7 @@ ENV XDEBUG_CONNECT_BACK_HOST '""'
ENV WWWDATA_PASSWORD ""

COPY rootfs/. /
COPY ../../php-fpm/magento2-web/context/rootfs/usr/local/bin/ /home/www-data/.local/bin/
COPY --from=scripts --exclude=*_test.sh --chown=www-data:www-data --chmod=755 /bin/ /home/www-data/.local/bin/
COPY --from=rewardenv/supervisord /usr/local/bin/supervisord /usr/bin/

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

version_gt() { test "$(printf "%s\n" "$@" | sort -V | head -n 1)" != "$1"; }
version_gt() { test "$(printf '%s\n' "${@#v}" | sort -V | head -n 1)" != "${1#v}"; }

shopt -s expand_aliases
if [ -f "${HOME}/.bash_alias" ]; then
Expand Down
4 changes: 2 additions & 2 deletions images/php-fpm-rootless/shopware-web/tpl.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1
# syntax=docker/dockerfile:1.7-labs
{{- $BASE_IMAGE_NAME := getenv "BASE_IMAGE_NAME" "ubuntu" }}
{{- $BASE_IMAGE_TAG := getenv "BASE_IMAGE_TAG" "jammy" }}
ARG IMAGE_NAME="rewardenv/php-fpm"
Expand Down Expand Up @@ -32,7 +32,7 @@ ENV XDEBUG_CONNECT_BACK_HOST '""'
ENV WWWDATA_PASSWORD ""

COPY rootfs/. /
COPY ../../php-fpm/shopware-web/context/rootfs/usr/local/bin/ /home/www-data/.local/bin/
COPY --from=scripts --exclude=*_test.sh --chown=www-data:www-data --chmod=755 /bin/ /home/www-data/.local/bin/
COPY --from=rewardenv/supervisord /usr/local/bin/supervisord /usr/bin/

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

version_gt() { test "$(printf "%s\n" "$@" | sort -V | head -n 1)" != "$1"; }
version_gt() { test "$(printf '%s\n' "${@#v}" | sort -V | head -n 1)" != "${1#v}"; }

shopt -s expand_aliases
if [ -f "${HOME}/.bash_alias" ]; then
Expand Down
4 changes: 2 additions & 2 deletions images/php-fpm-rootless/wordpress-web/tpl.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1
# syntax=docker/dockerfile:1.7-labs
{{- $BASE_IMAGE_NAME := getenv "BASE_IMAGE_NAME" "ubuntu" }}
{{- $BASE_IMAGE_TAG := getenv "BASE_IMAGE_TAG" "jammy" }}
ARG IMAGE_NAME="rewardenv/php-fpm"
Expand Down Expand Up @@ -32,7 +32,7 @@ ENV XDEBUG_CONNECT_BACK_HOST '""'
ENV WWWDATA_PASSWORD ""

COPY rootfs/. /
COPY ../../php-fpm/wordpress-web/context/rootfs/usr/local/bin/ /home/www-data/.local/bin/
COPY --from=scripts --exclude=*_test.sh --chown=www-data:www-data --chmod=755 /bin/ /home/www-data/.local/bin/
COPY --from=rewardenv/supervisord /usr/local/bin/supervisord /usr/bin/

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Expand Down
2 changes: 1 addition & 1 deletion images/php-fpm-rootless/xdebug2/tpl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN <<-EOF
php${PHP_VERSION}-dev \
php-pear \
make
eval 'version_gt() { test "$(printf "%s\n" "$@" | sort -V | head -n 1)" != "$1"; }'
eval 'version_gt() { test "$(printf '%s\n' "${@#v}" | sort -V | head -n 1)" != "${1#v}"; }'
if version_gt "${PHP_VERSION}" "6.99.99"; \
then if version_gt "${PHP_VERSION}" "7.0.99"; \
then pecl install -f xdebug-2.9.8; \
Expand Down
Loading

0 comments on commit e0d48d8

Please sign in to comment.