Skip to content

Commit 29f6bea

Browse files
authored
Merge pull request #14 from samlitowitz/issue-13
Add testing to ensure commited Dockerfiles are up to date and a cursory test for xdebug being loaded properly
2 parents 9972c22 + 81252f0 commit 29f6bea

File tree

6 files changed

+125
-1
lines changed

6 files changed

+125
-1
lines changed

.github/workflows/pipes.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Pipes
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
paths:
8+
- 'bin/**'
9+
- 'build/**'
10+
- 'scripts/**'
11+
- 'src/**'
12+
types:
13+
- labeled
14+
- unlabeled
15+
- opened
16+
- synchronize
17+
push:
18+
branches:
19+
- master
20+
paths:
21+
- 'bin/**'
22+
- 'build/**'
23+
- 'scripts/**'
24+
- 'src/**'
25+
workflow_dispatch:
26+
27+
jobs:
28+
build_and_verify:
29+
name: Build and Verify
30+
if: |
31+
github.event_name == 'push'
32+
|| github.event_name == 'workflow_dispatch'
33+
|| (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci'))
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Verify builds are correct
38+
run: |
39+
make clean
40+
make generate
41+
./scripts/git-has-changes.sh
42+
- name: Build and verify CLI docker images
43+
run: |
44+
./scripts/build-and-verify-cli-images.sh mobtitude/php-xdebug

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
/.idea
1+
.*
2+
3+
!.gitignore
4+
5+
!.github/

bin/build-all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ if [ "${#build_failed[@]}" -gt 0 ]; then
6060
for img in "${build_failed[@]}"; do
6161
echo "${text_red}* ${img}${text_normal}"
6262
done
63+
exit 1
6364
fi
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Script builds all Dockerfiles defined in build directory
5+
# Prints summary after all images have been built (successfully or not)
6+
#
7+
8+
image_name="$1"
9+
10+
# Checks if image name was provided by user
11+
if [ -z "${image_name}" ]; then
12+
echo "Usage: $0 [docker_image_name]" >&2
13+
exit -1
14+
fi
15+
16+
# Change current path to project root
17+
script_path=$(dirname "$0")
18+
cd "${script_path}/../" || exit -1
19+
20+
# Text formatting
21+
text_bold=$(tput bold)
22+
text_red=$(tput setaf 1)
23+
text_normal=$(tput sgr0)
24+
25+
# Loop through all available directories in ./build
26+
for i in ./build/*/; do
27+
version=$(basename "$i");
28+
image="${image_name}:${version}"
29+
30+
if [ "$version" == "${version%"cli"*}" ]; then
31+
continue
32+
fi
33+
34+
echo "${text_bold}* Building ${image} ${text_normal}"
35+
36+
# Builds image and check for return code
37+
if ! docker build --pull -t "${image}" "./build/${version}"; then
38+
echo "${text_bold}${text_red}* ERROR when building ${image} ${text_normal}"
39+
exit 1
40+
fi
41+
42+
echo "${text_bold}* Testing ${image} ${text_normal}"
43+
44+
docker run \
45+
--volume ./scripts/test-xdebug-install.php:/app/test-xdebug-install.php \
46+
--workdir /app \
47+
--entrypoint php \
48+
"${image}" test-xdebug-install.php
49+
done
50+

scripts/git-has-changes.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ -n $(git status --porcelain --untracked-files=no) ]]; then
4+
exit 1
5+
fi

scripts/test-xdebug-install.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
function checkExtensionLoaded() {
4+
if (!extension_loaded('xdebug')) {
5+
exit(1);
6+
}
7+
}
8+
9+
function checkXdebugIsDebuggerActive() {
10+
if (!function_exists('xdebug_is_debugger_active')) {
11+
exit(1);
12+
}
13+
$result = xdebug_is_debugger_active();
14+
if (!is_bool($result)) {
15+
exit(1);
16+
}
17+
}
18+
19+
checkExtensionLoaded();
20+
checkXdebugIsDebuggerActive();

0 commit comments

Comments
 (0)