ci/cd Fix a few things with test core linux + finish antibot linux core tests

This commit is contained in:
Théophile Diot 2023-09-19 14:52:06 +02:00
parent fdae4549ce
commit 094d5d5dfe
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06
2 changed files with 25 additions and 15 deletions

View file

@ -26,9 +26,9 @@ jobs:
run: |
sudo apt purge -y firefox
sudo apt update
sudo apt install --no-install-recommends -y nodejs tar wget curl grep libappindicator3-1 libasound2 libdbus-glib-1-2 libxtst6 libxt6
wget -O firefox-setup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64"
tar xjf firefox-setup.tar.bz2 -C /opt/
sudo apt install --no-install-recommends -y nodejs tar bzip2 wget curl grep libx11-xcb1 libappindicator3-1 libasound2 libdbus-glib-1-2 libxtst6 libxt6
wget -O firefox-setup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64"
tar -xjf firefox-setup.tar.bz2 -C /opt/
sudo ln -s /opt/firefox/firefox /usr/bin/firefox
sudo chmod 755 /opt/firefox
sudo chmod 755 /opt/firefox/firefox
@ -40,9 +40,9 @@ jobs:
timeout_minutes: 20
command: |
GECKODRIVER_VERSION=`curl -i https://github.com/mozilla/geckodriver/releases/latest | grep -Po 'v[0-9]+\.[0-9]+\.[0-9]+'` && \
wget -O geckodriver.tar.gz -w 5 https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz && \
sudo tar -C /usr/local/bin -xzvf geckodriver.tar.gz && \
sudo chmod +x /usr/local/bin/geckodriver && \
wget -O geckodriver.tar.gz -w 5 https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz
sudo tar -xzf geckodriver.tar.gz -C /usr/local/bin
sudo chmod +x /usr/local/bin/geckodriver
rm -f geckodriver.tar.gz
- name: Login to ghcr
uses: docker/login-action@v3
@ -71,15 +71,14 @@ jobs:
run: sudo apt install -fy /tmp/bunkerweb.deb
- name: Edit configuration files
run: |
echo "www.example.com 127.0.0.1" | sudo tee -a /etc/hosts
sudo rm -f /etc/bunkerweb/variables.env
sudo touch /etc/bunkerweb/variables.env
echo "SERVER_NAME=www.example.com" | sudo tee -a /etc/bunkerweb/variables.env
echo "127.0.0.1 www.example.com" | sudo tee -a /etc/hosts
echo "SERVER_NAME=www.example.com" | sudo tee /etc/bunkerweb/variables.env
echo "HTTP_PORT=80" | sudo tee -a /etc/bunkerweb/variables.env
echo "HTTPS_PORT=443" | sudo tee -a /etc/bunkerweb/variables.env
echo 'DNS_RESOLVERS=9.9.9.9 8.8.8.8 8.8.4.4' | sudo tee -a /etc/bunkerweb/variables.env
echo "USE_BUNKERNET=no" | sudo tee -a /etc/bunkerweb/variables.env
echo "USE_BLACKLIST=no" | sudo tee -a /etc/bunkerweb/variables.env
echo "LOG_LEVEL=info" | sudo tee -a /etc/bunkerweb/variables.env
sudo chown nginx:nginx /etc/bunkerweb/variables.env
sudo chmod 777 /etc/bunkerweb/variables.env
- name: Run tests

View file

@ -26,7 +26,9 @@ if [ "$integration" = "docker" ] ; then
fi
else
systemctl stop bunkerweb
{ echo "USE_ANTIBOT=no"; echo "ANTIBOT_URI=/challenge"; } >> /etc/bunkerweb/variables.env
echo "USE_ANTIBOT=no" | tee -a /etc/bunkerweb/variables.env
echo "ANTIBOT_URI=/challenge" | tee -a /etc/bunkerweb/variables.env
touch /var/www/html/index.html
fi
manual=0
@ -36,10 +38,10 @@ 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@USE_ANTIBOT: ".*"$@USE_ANTIBOT: "no"@' {} \;
find . -type f -name 'docker-compose.*' -exec sed -i 's@ANTIBOT_URI: ".*"@ANTIBOT_URI: "/challenge"@' {} \;
find . -type f -name 'docker-compose.*' -exec sed -i 's@ANTIBOT_URI: ".*"$@ANTIBOT_URI: "/challenge"@' {} \;
else
sed -i 's@USE_ANTIBOT=.*$@USE_ANTIBOT=no@' /etc/bunkerweb/variables.env
sed -i 's@ANTIBOT_URI=.*@ANTIBOT_URI=/challenge@' /etc/bunkerweb/variables.env
sed -i 's@ANTIBOT_URI=.*$@ANTIBOT_URI=/challenge@' /etc/bunkerweb/variables.env
unset USE_ANTIBOT
unset ANTIBOT_URI
fi
@ -54,6 +56,7 @@ cleanup_stack () {
docker compose down -v --remove-orphans
else
systemctl stop bunkerweb
truncate -s 0 /var/log/bunkerweb/error.log
fi
if [ $? -ne 0 ] ; then
@ -74,9 +77,9 @@ do
elif [ "$test" = "endpoint" ] ; then
echo "🤖 Running tests where antibot is on a different endpoint ..."
if [ "$integration" == "docker" ] ; then
find . -type f -name 'docker-compose.*' -exec sed -i 's@ANTIBOT_URI: ".*"@ANTIBOT_URI: "/custom"@' {} \;
find . -type f -name 'docker-compose.*' -exec sed -i 's@ANTIBOT_URI: ".*"$@ANTIBOT_URI: "/custom"@' {} \;
else
sed -i 's@ANTIBOT_URI=.*@ANTIBOT_URI=/custom@' /etc/bunkerweb/variables.env
sed -i 's@ANTIBOT_URI=.*$@ANTIBOT_URI=/custom@' /etc/bunkerweb/variables.env
export ANTIBOT_URI="/custom"
fi
elif [ "$test" != "deactivated" ] ; then
@ -150,6 +153,10 @@ do
done
if [ $i -ge 120 ] ; then
journalctl -u bunkerweb --no-pager
echo "🛡️ Showing BunkerWeb error logs ..."
cat /var/log/bunkerweb/error.log
echo "🛡️ Showing BunkerWeb access logs ..."
cat /var/log/bunkerweb/access.log
echo "🤖 Linux stack is not healthy ❌"
exit 1
fi
@ -170,8 +177,12 @@ do
docker compose logs bw bw-scheduler
else
journalctl -u bunkerweb --no-pager
echo "🛡️ Showing BunkerWeb error logs ..."
cat /var/log/bunkerweb/error.log
echo "🛡️ Showing BunkerWeb access logs ..."
cat /var/log/bunkerweb/access.log
echo "🛡️ Showing Geckodriver logs ..."
cat geckodriver.log
fi
exit 1
else