From 1ef383e6f5f13a6aa962a8e83e33ff47961dd924 Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Mon, 5 May 2025 02:28:00 +0200 Subject: [PATCH] Add workflow for testing API client --- .github/workflows/test.yml | 38 ++++++++++++++++++++++++++++++ docker-compose.yml | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 docker-compose.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0b2ea2f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,38 @@ + +name: Docker Compose Action + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4.2.2 + + - name: Run docker compose + uses: hoverkraft-tech/compose-action@v2.0.1 + with: + compose-file: "./docker-compose.yml" + + - name: Wait for service to be ready + run: | + echo "Waiting for service at http://localhost:8080/ocs/v2.php/apps/serverinfo/api/v1/info to return 401..." + max_attempts=60 + attempt=0 + until curl -o /dev/null -s -w "%{http_code}\n" http://localhost:8080/ocs/v2.php/apps/serverinfo/api/v1/info | grep -q "401"; do + attempt=$((attempt + 1)) + if [ $attempt -ge $max_attempts ]; then + echo "Service did not become ready in time." + exit 1 + fi + echo "Attempt $attempt/$max_attempts: Service not ready, sleeping for 5 seconds..." + sleep 5 + done + echo "Service is ready (returned 401)." + + # Add subsequent steps here, e.g., running tests + # - name: Run tests + # run: | + # echo "Running tests..." + # # Your test commands here diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..14c3c0a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,47 @@ +services: + # Note: MariaDB is external service. You can find more information about the configuration here: + # https://hub.docker.com/_/mariadb + db: + # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server + image: mariadb:lts + restart: always + command: --transaction-isolation=READ-COMMITTED + volumes: + - db:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD=password + - MYSQL_PASSWORD=password + - MYSQL_DATABASE=nextcloud + - MYSQL_USER=nextcloud + + # Note: Redis is an external service. You can find more information about the configuration here: + # https://hub.docker.com/_/redis + redis: + image: redis:alpine + restart: always + + app: + image: nextcloud + #user: www-data:www-data + restart: always + post_start: + - command: chown -R www-data:www-data /var/www/html && while ! nc -z db 3306; do sleep 1; echo sleeping; done + #user: root + ports: + - 8080:80 + depends_on: + - redis + - db + volumes: + - nextcloud:/var/www/html + environment: + - NEXTCLOUD_ADMIN_USER=admin + - NEXTCLOUD_ADMIN_PASSWORD=admin + - MYSQL_PASSWORD=password + - MYSQL_DATABASE=nextcloud + - MYSQL_USER=nextcloud + - MYSQL_HOST=db + +volumes: + nextcloud: + db: