4 Commits

Author SHA1 Message Date
flowgunso
92485ca8f0 Move UID/GID into an env file 2024-06-07 15:32:47 +02:00
flowgunso
451f003533 Debug the CI approval variable 2024-06-07 15:29:47 +02:00
flowgunso
18b78a981f Specify target, move envvars to file, improve mocking 2024-06-07 15:29:44 +02:00
flowgunso
8e01d6758e Replace subprocess.run with subprocess.check_call to raise exceptions on errors 2024-06-07 15:27:30 +02:00
7 changed files with 70 additions and 42 deletions

View File

@@ -18,6 +18,12 @@ include:
- template: Jobs/Code-Quality.gitlab-ci.yml
- template: Jobs/SAST.latest.gitlab-ci.yml
test:
stage: build
script: export
rules:
- if: $CI_MERGE_REQUEST_ID
build:
stage: build
before_script:

View File

@@ -1,20 +1,23 @@
TARGET?=unstable
TARGET?=oldstable # or stable, unstable
mock:
docker compose -f tests/mock/compose.yaml up -d
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml up --remove-orphans -d
unmock:
docker compose -f tests/mock/compose.yaml down
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml down
client:
docker compose -f tests/mock/compose.yaml rm -fs client
docker compose -f tests/mock/compose.yaml up -d client
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml rm -fs client
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml up --remove-orphans -d client
shell:
docker compose -f tests/mock/compose.yaml exec client bash
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml run --rm client bash
logs:
docker compose -f tests/mock/compose.yaml logs -f client
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml logs -f client
ps:
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml ps
build:
TARGET=${TARGET} CI_COMMIT_TAG=${CI_COMMIT_TAG} bash scripts/build-images.sh

View File

@@ -15,7 +15,10 @@ RUN apt-get update && \
oathtool \
ca-certificates \
gnupg \
sudo && \
sudo \
# procps \
iputils-ping \
&& \
apt-get clean && apt-get autoclean && \
rm -rf \
/var/log/fsck/*.log \

View File

@@ -133,14 +133,17 @@ class Client:
if not self.ini.exists():
logger.info("Seafile .ini file not found, running `seaf-cli init`")
#self.ini.parent.parent.mkdir(parents=True, exist_ok=True)
subprocess.run(self.binary + ["init", "-d", str(self.seafile)])
subprocess.check_call(self.binary + ["init", "-d", str(self.seafile)])
while not self.ini.exists():
logging.debug("Waiting for the .ini file to be created...")
time.sleep(1)
# Start the Seafile client.
logger.info("Starting `seaf-cli`.")
subprocess.run(self.binary + ["start"])
try:
subprocess.check_call(self.binary + ["start"])
except Exception as e:
raise e
while not self.socket.exists():
logger.debug("Waiting for the Seafile client socket to be created.")
time.sleep(1)
@@ -150,11 +153,11 @@ class Client:
def configure(self):
command = self.binary + ["config"]
if self.skip_ssl_cert:
subprocess.run(command +["-k", "disable_verify_certificate", "-v", self.skip_ssl_cert])
subprocess.check_call(command +["-k", "disable_verify_certificate", "-v", self.skip_ssl_cert])
if self.download_limit:
subprocess.run(command +["-k", "download_limit", "-v", self.download_limit])
subprocess.check_call(command +["-k", "download_limit", "-v", self.download_limit])
if self.upload_limit:
subprocess.run(command +["-k", "upload_limit", "-v", self.upload_limit])
subprocess.check_call(command +["-k", "upload_limit", "-v", self.upload_limit])
def synchronize(self):
core = self.binary + ["sync", "-u", self.username, "-p", self.password, "-s", self.url]
@@ -178,18 +181,18 @@ class Client:
command += ["-d", str(target)]
if self.mfa_secret:
totp = subprocess.run(
totp = subprocess.check_call(
f"oathtool --base32 --totp {self.mfa_secret}",
text=True,
capture_stdout=True).stdout
command += ["-a", totp]
logging.debug(f"Running {' '.join(command)}")
subprocess.run(command)
subprocess.check_call(command)
def follow(self):
logging.debug(f"Running `tail -v -f {self.log}`")
subprocess.run(["tail", "-v", "-f", self.log])
subprocess.check_call(["tail", "-v", "-f", self.log])
def healthcheck(self):

View File

@@ -1,49 +1,35 @@
name: seafile-client-${TARGET}
services:
mariadb:
image: mariadb:10.11
environment:
- MYSQL_ROOT_PASSWORD=password # Requested, set the root's password of MySQL service.
- MYSQL_LOG_CONSOLE=true
- MARIADB_AUTO_UPGRADE=1
env_file: env
volumes:
- database:/var/lib/mysql # Requested, specifies the path to MySQL data persistent store.
memcached:
image: memcached:1.6.18
container_name: seafile-memcached
entrypoint: memcached -m 256
seafile:
image: seafileltd/seafile-mc:latest
hostname: seafile-${TARGET}
ports:
- "80:80"
- "80"
volumes:
- seafile:/shared # Requested, specifies the path to Seafile data persistent store.
environment:
- DB_HOST=mariadb
- DB_ROOT_PASSWD=password # Requested, the value should be root's password of MySQL service.
- TIME_ZONE=Etc/UTC # Optional, default is UTC. Should be uncomment and set to your local time zone.
- SEAFILE_ADMIN_EMAIL=seafile@localhost # Specifies Seafile admin user, default is 'me@example.com'.
- SEAFILE_ADMIN_PASSWORD=password # Specifies Seafile admin password, default is 'asecret'.
- SEAFILE_SERVER_LETSENCRYPT=false # Whether to use https or not.
env_file: env
depends_on:
- mariadb
- memcached
client:
image: seafile-client:unstable
volumes:
#- library:/library
- data:/seafile
# user: "1000:1000"
environment:
SEAF_SERVER_URL: "http://seafile"
SEAF_USERNAME: "seafile@localhost"
SEAF_PASSWORD: "password"
SEAF_LIBRARY_UUID: "1b7d4e92-6753-4c4a-85b0-42566eab42c8"
DEBUG: 1
UID: 1000
GID: 100
# image: flowgunso/seafile-client:9.0.5
image: seafile-client:${TARGET}
# volumes:
# - library:/library
# - data:/seafile
env_file: env
depends_on:
- seafile

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
until curl --output /dev/null --silent --head --fail http://seafile-${TARGET}; do
printf '.'
sleep 5
done

21
tests/mock/env Normal file
View File

@@ -0,0 +1,21 @@
# Database
MYSQL_ROOT_PASSWORD=password # Requested, set the root's password of MySQL service.
MYSQL_LOG_CONSOLE=true
MARIADB_AUTO_UPGRADE=1
# Seafile
DB_HOST=mariadb
DB_ROOT_PASSWD=password # Requested, the value should be root's password of MySQL service.
TIME_ZONE=Etc/UTC # Optional, default is UTC. Should be uncomment and set to your local time zone.
SEAFILE_ADMIN_EMAIL=seafile@localhost # Specifies Seafile admin user, default is 'me@example.com'.
SEAFILE_ADMIN_PASSWORD=password # Specifies Seafile admin password, default is 'asecret'.
SEAFILE_SERVER_LETSENCRYPT=false # Whether to use https or not.
# Client
SEAF_SERVER_URL="http://seafile-${TARGET}"
SEAF_USERNAME="seafile@localhost"
SEAF_PASSWORD="password"
DEBUG=1
UID=1000
GID=100
# SEAF_LIBRARY_UUID="" # Use this for custom library ID