forked from A1mDev/hlstatsx-community-edition
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from startersclan/fix/ci-don-t-save-the-cache-…
…at-end-of-test-jobs Fix (ci): Don't save the cache at end of test jobs
- Loading branch information
Showing
11 changed files
with
193 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
COMPOSE_PROJECT_NAME=hlstatsx-community-edition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version: '2.2' | ||
services: | ||
test-container-networking: | ||
image: alpine:latest | ||
volumes: | ||
- ./:/test:ro | ||
networks: | ||
- default | ||
stop_signal: SIGKILL | ||
working_dir: /test | ||
entrypoint: | ||
- /bin/sh | ||
command: | ||
- -c | ||
- | | ||
sleep infinity | ||
test-host-networking: | ||
image: alpine:latest | ||
volumes: | ||
- ./:/test:ro | ||
network_mode: host | ||
stop_signal: SIGKILL | ||
working_dir: /test | ||
entrypoint: | ||
- /bin/sh | ||
command: | ||
- -c | ||
- | | ||
sleep infinity | ||
networks: | ||
default: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
docker exec -i $( docker compose ps -q awards) sh -c /awards.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
echo "[test-endpoints]" | ||
ENDPOINTS=" | ||
web.example.com 200 | ||
phpmyadmin.example.com 200 | ||
" | ||
command -v curl || apk add --no-cache curl | ||
echo "$ENDPOINTS" | awk NF | while read -r i j; do | ||
if curl --head -skL http://$i --resolve $i:80:127.0.0.1 --resolve $i:443:127.0.0.1 2>&1 | grep "^HTTP/2 $j " > /dev/null; then | ||
echo "PASS: $i" | ||
else | ||
echo "FAIL: $i" | ||
exit 1 | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
docker exec -i $( docker compose ps -q heatmaps) php /heatmaps/generate.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
echo | ||
echo "[test-ready] Waiting for stack to be ready" | ||
s=0 | ||
while true; do | ||
nc -vz -w 1 web 80 \ | ||
&& nc -vz -w 1 web 9000 \ | ||
&& nc -vz -w 1 db 3306 \ | ||
&& break || true | ||
s=$(( $s + 1 )) | ||
if [ "$s" -eq 600 ]; then | ||
exit 1 | ||
fi | ||
echo "Retrying in 3 seconds" | ||
sleep 3 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
echo "[test-routes]" | ||
URLS=" | ||
http://web/ 302 | ||
http://web/css/spinner.gif 200 | ||
http://web/hlstatsimg/ajax.gif 200 | ||
http://web/includes/ 401 | ||
http://web/pages/ 401 | ||
http://web/pages/.htaccess 401 | ||
http://web/styles/classic.css 200 | ||
http://web/updater/ 401 | ||
http://web/autocomplete.php 200 | ||
http://web/config.php 401 | ||
http://web/hlstats.php 200 | ||
http://web/index.php 302 | ||
http://web/ingame.php 200 | ||
http://web/show_graph.php 200 | ||
http://web/sig.php 200 | ||
http://web/status.php 200 | ||
http://web/trend_graph.php 200 | ||
" | ||
echo "$URLS" | awk NF | while read -r i j; do | ||
if wget -q -SO- "$i" 2>&1 | grep "HTTP/1.1 $j " > /dev/null; then | ||
echo "PASS: $i" | ||
else | ||
echo "FAIL: $i" | ||
exit 1 | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
TEST=${1:-} # Test environment | ||
UP=${2:-} # Whether to docker compose up and down the test stack | ||
CACHE=${3:-} # Whether to override with docker-compose.build.yml | ||
|
||
# Validation and normalization | ||
if ! echo "$TEST" | grep -E '^(dev|prod)$' > /dev/null; then | ||
echo "Specify TEST as the first argument. E.g. 'dev', 'prod'" | ||
exit 1 | ||
fi | ||
if [ -n "$CACHE" ]; then | ||
CACHE='-f docker-compose.build.yml' | ||
fi | ||
|
||
SCRIPT_DIR=$( cd "$( dirname "$0" )" && pwd ) | ||
ERR= | ||
setup_test() { | ||
cd "$SCRIPT_DIR" | ||
docker compose up -d | ||
if [ -n "$UP" ]; then | ||
setup | ||
fi | ||
run | ||
} | ||
cleanup_test() { | ||
ERR=$? | ||
if [ -n "$UP" ]; then | ||
cleanup | ||
fi | ||
docker compose stop | ||
if [ -z "$ERR" ] || [ "$ERR" = 0 ]; then | ||
echo "All tests succeeded" | ||
else | ||
echo "Some tests failed" | ||
echo "Exit code: $ERR" | ||
exit "$ERR" | ||
fi | ||
} | ||
trap cleanup_test INT TERM EXIT | ||
|
||
echo "Testing..." | ||
if [ "$TEST" = 'dev' ]; then | ||
setup() { | ||
if [ -n "$CACHE" ]; then | ||
CACHE='-f docker-compose.build.yml' | ||
fi | ||
(cd .. && docker compose -f docker-compose.yml $CACHE up --build -d) | ||
} | ||
run() { | ||
docker exec $( docker compose ps -q test-container-networking ) ./test-ready.sh | ||
docker exec $( docker compose ps -q test-container-networking ) ./test-routes.sh | ||
./test-awards.sh | ||
./test-heatmaps.sh | ||
} | ||
cleanup() { | ||
(cd .. && docker compose -f docker-compose.yml $CACHE stop) | ||
} | ||
fi | ||
if [ "$TEST" = 'prod' ]; then | ||
setup() { | ||
if [ -n "$CACHE" ]; then | ||
CACHE='-f docker-compose.example.build.yml' | ||
fi | ||
(cd .. && docker compose -f docker-compose.example.yml $CACHE up --build -d) | ||
} | ||
run() { | ||
docker exec $( docker compose ps -q test-container-networking ) ./test-ready.sh | ||
docker exec $( docker compose ps -q test-container-networking ) ./test-routes.sh | ||
./test-awards.sh | ||
./test-heatmaps.sh | ||
docker exec $( docker compose ps -q test-host-networking ) ./test-endpoints.sh | ||
} | ||
cleanup() { | ||
(cd .. && docker compose -f docker-compose.example.yml $CACHE stop) | ||
} | ||
fi | ||
setup_test |