2422: Build wheels only if we have to. r=mergify[bot] a=nextgens

## What type of PR?

enhancement

## What does this PR do?

This massively speeds the CI up; We don't need to install a compiler and rebuild when we have wheels available... with this admin builds 4 times faster.

### Related issue(s)
- #1830


Co-authored-by: Florent Daigniere <nextgens@freenetproject.org>
Co-authored-by: Dimitri Huisman <diman@huisman.xyz>
master
bors[bot] 2 years ago committed by GitHub
commit b962319ba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -37,10 +37,11 @@ WORKDIR /app
COPY requirements-prod.txt requirements.txt COPY requirements-prod.txt requirements.txt
RUN set -eu \ RUN set -eu \
&& apk add --no-cache libressl curl postgresql-libs mariadb-connector-c \ && apk add --no-cache libressl curl postgresql-libs mariadb-connector-c \
&& apk add --no-cache --virtual build-dep libressl-dev libffi-dev python3-dev build-base postgresql-dev mariadb-connector-c-dev cargo \ && pip install --no-cache-dir --extra-index-url=https://www.piwheels.org/simple -r requirements.txt --only-binary=:all: --no-binary=Flask-bootstrap,PyYAML,SQLAlchemy \
|| ( apk add --no-cache --virtual build-dep libressl-dev libffi-dev python3-dev build-base postgresql-dev mariadb-connector-c-dev cargo \
&& pip install --upgrade pip \ && pip install --upgrade pip \
&& pip install -r requirements.txt \ && pip install -r requirements.txt \
&& apk del --no-cache build-dep && apk del --no-cache build-dep )
COPY --from=assets static ./mailu/static COPY --from=assets static ./mailu/static
COPY mailu ./mailu COPY mailu ./mailu

@ -5,7 +5,7 @@ bcrypt==3.2.0
blinker==1.4 blinker==1.4
CacheControl==0.12.9 CacheControl==0.12.9
certifi==2021.10.8 certifi==2021.10.8
cffi==1.15.0 # cffi==1.15.0
chardet==4.0.0 chardet==4.0.0
click==8.0.3 click==8.0.3
colorama==0.4.4 colorama==0.4.4
@ -43,13 +43,15 @@ MarkupSafe==2.0.1
marshmallow==3.14.0 marshmallow==3.14.0
marshmallow-sqlalchemy==0.26.1 marshmallow-sqlalchemy==0.26.1
msgpack==1.0.2 msgpack==1.0.2
mysqlclient==2.0.3 # mysqlclient==2.0.3
mysql-connector-python==8.0.25
ordered-set==4.0.2 ordered-set==4.0.2
# packaging==20.9 # packaging==20.9
passlib==1.7.4 passlib==1.7.4
# pep517==0.10.0 # pep517==0.10.0
progress==1.6 progress==1.6
psycopg2==2.9.1 #psycopg2==2.9.1
psycopg2-binary==2.9.3
pycparser==2.20 pycparser==2.20
Pygments==2.10.0 Pygments==2.10.0
pyOpenSSL==21.0.0 pyOpenSSL==21.0.0

@ -19,7 +19,7 @@ PyOpenSSL
Pygments Pygments
dnspython dnspython
tenacity tenacity
mysqlclient mysql-connector-python
idna idna
srslib srslib
marshmallow marshmallow

@ -22,9 +22,9 @@ RUN apk add --no-cache --virtual .build-deps gcc musl-dev python3-dev \
# Image specific layers under this line # Image specific layers under this line
# Building pycares from source requires py3-wheel and libffi-dev packages # Building pycares from source requires py3-wheel and libffi-dev packages
RUN apk add --no-cache --virtual .build-deps gcc musl-dev python3-dev py3-wheel libffi-dev \ RUN pip install --no-cache-dir --extra-index-url=https://www.piwheels.org/simple --only-binary=:all: postfix-mta-sts-resolver==1.0.1 || (apk add --no-cache --virtual .build-deps gcc musl-dev python3-dev py3-wheel libffi-dev \
&& pip3 install --no-binary :all: postfix-mta-sts-resolver==1.0.1 \ && pip3 install postfix-mta-sts-resolver==1.0.1 \
&& apk del .build-deps && apk del .build-deps )
RUN apk add --no-cache postfix postfix-pcre cyrus-sasl-login rsyslog logrotate RUN apk add --no-cache postfix postfix-pcre cyrus-sasl-login rsyslog logrotate
@ -37,4 +37,4 @@ VOLUME ["/queue"]
CMD /start.py CMD /start.py
HEALTHCHECK --start-period=350s CMD echo QUIT|nc localhost 25|grep "220 .* ESMTP Postfix" HEALTHCHECK --start-period=350s CMD echo QUIT|nc localhost 25|grep "220 .* ESMTP Postfix"
RUN echo $VERSION >> /version RUN echo $VERSION >> /version

@ -1,9 +1,12 @@
import sys import sys
import os import os
import time import time
import datetime
from xmlrpc.client import DateTime
import docker import docker
from colorama import Fore, Style from colorama import Fore, Style
import subprocess import subprocess
import calendar
# Declare variables for service name and sleep time # Declare variables for service name and sleep time
test_name=sys.argv[1] test_name=sys.argv[1]
@ -22,12 +25,7 @@ def stop(exit_code):
print(subprocess.check_output("docker-compose -f " + compose_file + " down", shell=True).decode()) print(subprocess.check_output("docker-compose -f " + compose_file + " down", shell=True).decode())
sys.exit(exit_code) sys.exit(exit_code)
# Sleep for a defined amount of time def health_checks(deadline):
def sleep():
print(Fore.LIGHTMAGENTA_EX + "Sleeping for " + str(timeout) + "m" + Style.RESET_ALL)
time.sleep(timeout*60)
def health_checks():
exit_code = 0 exit_code = 0
#Iterating trough all containers dictionary #Iterating trough all containers dictionary
for container in client.containers(all=True): for container in client.containers(all=True):
@ -58,7 +56,9 @@ def health_checks():
#Adding the generated dictionary to a list #Adding the generated dictionary to a list
containers.append(containers_dict) containers.append(containers_dict)
if exit_code != 0: if exit_code == 0:
return True
elif exit_code != 0 and deadline < datetime.datetime.now().timestamp():
stop(exit_code) stop(exit_code)
def print_logs(): def print_logs():
@ -86,14 +86,20 @@ def hooks():
# Start up containers # Start up containers
sys.stdout.flush() sys.stdout.flush()
deadline=datetime.datetime.now()+datetime.timedelta(minutes=timeout)
deadline=calendar.timegm(deadline.timetuple())
print(subprocess.check_output("docker-compose -f " + compose_file + " up -d", shell=True).decode()) print(subprocess.check_output("docker-compose -f " + compose_file + " up -d", shell=True).decode())
print() print()
sleep() print(Fore.LIGHTMAGENTA_EX + "Sleeping for 10s" + Style.RESET_ALL)
time.sleep(10)
print() print()
sys.stdout.flush() sys.stdout.flush()
print(subprocess.check_output("docker ps -a", shell=True).decode()) print(subprocess.check_output("docker ps -a", shell=True).decode())
print() print()
health_checks() while not health_checks(deadline):
print(Fore.LIGHTMAGENTA_EX + "Sleeping for 10s" + Style.RESET_ALL)
sys.stdout.flush()
time.sleep(10)
print() print()
hooks() hooks()
print() print()

Loading…
Cancel
Save