Skip to content

Commit 8213749

Browse files
Moved workflow test to a tests directory
1 parent 0ad9d5a commit 8213749

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

.github/workflows/publish-7.4-apache.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Publish 7.4 Apache Image
2-
on:
2+
on:
33
push:
44
branches:
55
- main
6-
repository_dispatch:
6+
repository_dispatch:
77
types: [build_7.4_apache]
88
jobs:
99
build:
@@ -15,7 +15,7 @@ jobs:
1515
run: ./publish-image.sh
1616
working-directory: ./php7.4/apache/
1717
- name: Test 7.4 WordPress Image
18-
run: ./workflow-test.sh
18+
run: cd tests && ./workflow-test.sh
1919
shell: bash
2020
- uses: docker/login-action@v1
2121
with:

.github/workflows/publish-8.0-apache.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Publish 8.0 Apache Image
2-
on:
2+
on:
33
push:
44
branches:
55
- main
6-
repository_dispatch:
6+
repository_dispatch:
77
types: [build_8.0_apache]
88
jobs:
99
build:
@@ -15,7 +15,7 @@ jobs:
1515
run: ./publish-image.sh
1616
working-directory: ./php8.0/apache/
1717
- name: Test 8.0 WordPress Image
18-
run: ./workflow-test.sh
18+
run: cd tests && ./workflow-test.sh
1919
shell: bash
2020
- uses: docker/login-action@v1
2121
with:

workflow-test.sh renamed to tests/workflow-test.sh

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ function fail {
1313
exit 1
1414
}
1515

16-
1716
function try_curl {
1817
local n=1
1918
local max=5
@@ -81,18 +80,30 @@ function ensure_vanilla {
8180
docker exec -t $container /bin/bash -c 'php -l /var/www/html/index.php; retcode=$?; if [[ $retcode -ne 0 ]]; then echo "Either one of PHP or Wordpress is scrambled when not expected. Expected Vanilla PHP was not able to successfully parse Expected Vanilla /var/www/html/index.php and exited with code $retcode"; exit 1; fi;'
8281
}
8382

84-
function await_transform_finish {
85-
echo "Waiting for $1 to finish"
83+
function await_scramble_finish {
84+
echo "Waiting for Scrambling to finish"
8685
{
8786
while [[ "$(docker exec $container /bin/bash -c 'ps aux |grep scramble.sh | grep -v grep |wc -l')" != "0" ]]; do
88-
#echo "Waiting for scrambling to finish... $(docker exec $container /bin/bash -c 'ps aux |grep scramble.sh | grep -v grep |wc -l')"
8987
sleep 1
9088
done
9189

9290
sleep 1
9391
} 2> /dev/null
9492

95-
echo "$1 finished."
93+
echo "Scrambling finished."
94+
}
95+
96+
function await_reset_finish {
97+
echo "Waiting for Reset to finish"
98+
{
99+
while [[ "$(docker exec $container /bin/bash -c 'ps aux |grep reset.sh | grep -v grep |wc -l')" != "0" ]]; do
100+
sleep 1
101+
done
102+
103+
sleep 1
104+
} 2> /dev/null
105+
106+
echo "Reset finished."
96107
}
97108

98109
function scramble {
@@ -106,11 +117,11 @@ function scramble {
106117
docker exec -t $container /bin/bash -c 'echo "2 " | nc localhost 2323'
107118
fi
108119

109-
await_transform_finish "Scrambling"
120+
await_scramble_finish
110121

111122
# Ensure works and is Polyscrpted
112-
try_curl
113123
ensure_scrambled
124+
try_curl
114125
}
115126

116127

@@ -120,15 +131,15 @@ echo "testing wordpress started in Polyscripted mode"
120131
MODE=polyscripted
121132
start &
122133
sleep 20
123-
await_transform_finish "Scrambling"
134+
await_scramble_finish
124135
echo "Testing container started"
125136
if [[ ! "$( docker container inspect -f '{{.State.Running}}' $container )" == "true" ]]; then
126137
fail "WordPess container failed to start -- check polyscripting errors."
127138
fi
128139

129140
# Ensure works and is Polyscrpted
130-
try_curl
131141
ensure_scrambled
142+
try_curl
132143

133144
# Live-scramble through dispatcher multiple times and ensure works and is polyscripted
134145
repeated_scramble
@@ -138,9 +149,9 @@ printf "\n\n\n\n\n"
138149
echo "---------------------------------------------------------------------------------------------------"
139150
echo "Unscrambling wordpress scrambled repeatedly..."
140151
docker exec -t $container /bin/bash -c 'echo "3 " | nc localhost 2323'
141-
await_transform_finish "Unscrambling"
142-
try_curl
152+
await_reset_finish
143153
ensure_vanilla
154+
try_curl
144155

145156
if [[ ! "$( docker container inspect -f '{{.State.Running}}' $container )" == "true" ]]; then
146157
fail "WordPess container failed -- check polyscripting errors."
@@ -160,8 +171,8 @@ if [ "$( docker container inspect -f '{{.State.Running}}' $container )" == "fals
160171
fi
161172

162173
# Ensure works
163-
try_curl
164174
ensure_vanilla
175+
try_curl
165176

166177
# Live-scramble through dispatcher multiple times and ensure works and is polyscripted
167178
repeated_scramble
@@ -171,9 +182,9 @@ printf "\n\n\n\n\n"
171182
echo "---------------------------------------------------------------------------------------------------"
172183
echo "Unscrambling wordpress scrambled repeatedly..."
173184
docker exec -t $container /bin/bash -c 'echo "3 " | nc localhost 2323'
174-
await_transform_finish "Unscrambling"
175-
try_curl
185+
await_reset_finish
176186
ensure_vanilla
187+
try_curl
177188

178189
docker rm -f mysql-host
179190
docker rm -f $container

0 commit comments

Comments
 (0)