Skip to content

Commit

Permalink
ci/cd - fix the mess
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian committed Nov 1, 2024
1 parent 8f2b01c commit af9d670
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions tests/core/country/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ services:
build: .
environment:
PYTHONUNBUFFERED: "1"
COUNTRY: "GB"
COUNTRY: "FR"
BLACKLIST_COUNTRY: ""
WHITELIST_COUNTRY: ""
extra_hosts:
- "www.example.com:2.0.0.2"
- "www.example.com:213.186.33.4"
networks:
bw-gb-network:
ipv4_address: 2.0.0.3
ipv4_address: 213.186.33.5

tests-us:
build: .
Expand Down
4 changes: 2 additions & 2 deletions tests/core/country/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
bw-us-network:
ipv4_address: 8.0.0.2
bw-gb-network:
ipv4_address: 2.0.0.2
ipv4_address: 213.186.33.4

bw-scheduler:
image: bunkerity/bunkerweb-scheduler:1.5.11
Expand Down Expand Up @@ -75,6 +75,6 @@ networks:
ipam:
driver: default
config:
- subnet: 2.0.0.0/8
- subnet: 213.0.0.0/8
bw-docker:
name: bw-docker
2 changes: 1 addition & 1 deletion tests/core/country/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
status_code = get(
"http://www.example.com",
headers={"Host": "www.example.com"}
| ({"X-Forwarded-For": "146.70.179.51" if country == "GB" else "8.0.0.3"} if getenv("TEST_TYPE", "docker") == "linux" else {}),
| ({"X-Forwarded-For": "213.186.33.5" if country == "FR" else "8.0.0.3"} if getenv("TEST_TYPE", "docker") == "linux" else {}),
).status_code

if status_code == 403:
Expand Down
26 changes: 13 additions & 13 deletions tests/core/country/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ cleanup_stack () {
if [[ $end -eq 1 || $exit_code = 1 ]] || [[ $end -eq 0 && $exit_code = 0 ]] && [ $manual = 0 ] ; then
if [ "$integration" == "docker" ] ; then
find . -type f -name 'docker-compose.*' -exec sed -i 's@BLACKLIST_COUNTRY: "US"@BLACKLIST_COUNTRY: ""@' {} \;
find . -type f -name 'docker-compose.*' -exec sed -i 's@WHITELIST_COUNTRY: "GB"@WHITELIST_COUNTRY: ""@' {} \;
find . -type f -name 'docker-compose.*' -exec sed -i 's@WHITELIST_COUNTRY: "FR"@WHITELIST_COUNTRY: ""@' {} \;
else
sudo sed -i 's@BLACKLIST_COUNTRY=.*$@BLACKLIST_COUNTRY=@' /etc/bunkerweb/variables.env
sudo sed -i 's@WHITELIST_COUNTRY=.*$@WHITELIST_COUNTRY=@' /etc/bunkerweb/variables.env
Expand Down Expand Up @@ -95,12 +95,12 @@ do
echo "🌍 Running tests when whitelisting England ..."
if [ "$integration" == "docker" ] ; then
find . -type f -name 'docker-compose.*' -exec sed -i 's@BLACKLIST_COUNTRY: "US"@BLACKLIST_COUNTRY: ""@' {} \;
find . -type f -name 'docker-compose.*' -exec sed -i 's@WHITELIST_COUNTRY: ""@WHITELIST_COUNTRY: "GB"@' {} \;
find . -type f -name 'docker-compose.*' -exec sed -i 's@WHITELIST_COUNTRY: ""@WHITELIST_COUNTRY: "FR"@' {} \;
else
sudo sed -i 's@BLACKLIST_COUNTRY=.*$@BLACKLIST_COUNTRY=@' /etc/bunkerweb/variables.env
sudo sed -i 's@WHITELIST_COUNTRY=.*$@WHITELIST_COUNTRY=GB@' /etc/bunkerweb/variables.env
sudo sed -i 's@WHITELIST_COUNTRY=.*$@WHITELIST_COUNTRY=FR@' /etc/bunkerweb/variables.env
unset BLACKLIST_COUNTRY
export WHITELIST_COUNTRY="GB"
export WHITELIST_COUNTRY="FR"
fi
fi

Expand Down Expand Up @@ -198,17 +198,17 @@ do

# Start tests

echo "🌍 Starting the GB country"
echo "🌍 Starting the FR country"
if [ "$integration" == "docker" ] ; then
docker compose -f docker-compose.test.yml up tests-gb --abort-on-container-exit --exit-code-from tests-gb
docker compose -f docker-compose.test.yml up tests-FR --abort-on-container-exit --exit-code-from tests-FR
else
export COUNTRY="GB"
export COUNTRY="FR"
python3 main.py
fi

# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌍 Test \"$test\" failed for the GB country ❌"
echo "🌍 Test \"$test\" failed for the FR country ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."
if [ "$integration" == "docker" ] ; then
docker compose logs bw bw-scheduler
Expand All @@ -223,20 +223,20 @@ do
fi
exit 1
else
echo "🌍 Test \"$test\" succeeded for the GB country ✅"
echo "🌍 Test \"$test\" succeeded for the FR country ✅"
fi

echo "🌍 Starting the GB country"
echo "🌍 Starting the FR country"
if [ "$integration" == "docker" ] ; then
docker compose -f docker-compose.test.yml up tests-us --abort-on-container-exit --exit-code-from tests-us
else
export COUNTRY="GB"
export COUNTRY="FR"
python3 main.py
fi

# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌍 Test \"$test\" failed for the GB country ❌"
echo "🌍 Test \"$test\" failed for the FR country ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."
if [ "$integration" == "docker" ] ; then
docker compose logs bw bw-scheduler
Expand All @@ -251,7 +251,7 @@ do
fi
exit 1
else
echo "🌍 Test \"$test\" succeeded for the GB country ✅"
echo "🌍 Test \"$test\" succeeded for the FR country ✅"
fi

manual=1
Expand Down
2 changes: 1 addition & 1 deletion tests/core/db/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ do
fi
fi
elif [ "$test" = "upgrade" ] ; then
older_version="$(curl -i https://github.com/bunkerity/bunkerweb/tags | grep -Po 'v[0-9]+\.[0-9]+\.[0-9]+' | uniq | sed -n 1p | cut -c 2-)"
older_version="$(curl -i https://github.com/bunkerity/bunkerweb/tags | grep -v "1\.6\.0" | grep -Po 'v[0-9]+\.[0-9]+\.[0-9]+' | uniq | sed -n 1p | cut -c 2-)"
echo "💾 Running tests when upgrading from $older_version (older) to latest version ..."
find . -type f -name 'docker-compose.*' -exec sed -i 's@DATABASE_URI: ".*"$@DATABASE_URI: "sqlite:////var/lib/bunkerweb/db.sqlite3"@' {} \;
sed -i 's@bunkerity/bunkerweb:.*$@bunkerity/bunkerweb:'"$older_version"'@' docker-compose.yml
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.13.0-alpine@sha256:c38ead8bcf521573dad837d7ecfdebbc87792202e89953ba8b2b83a9c5a520b6
FROM python:3.12.7-alpine@sha256:f498302457ec11162f872199b92239c34e1fbcdbc391ff37a4959e820224aa98

# Install firefox and geckodriver
RUN apk add --no-cache --virtual .build-deps curl grep zip wget && \
Expand Down

0 comments on commit af9d670

Please sign in to comment.