Commit 8c7a0d66 authored by Abhishek's avatar Abhishek
Browse files

Update .gitlab-ci.yml file

parent 0fe31880
Pipeline #11970 failed with stages
in 52 seconds
# This GitLab CI/CD pipeline is designed to run the complete Moodle
# automation script in a single, manually triggered job.
image: docker:20.10.16 image: docker:20.10.16
services: services:
- name: docker:20.10.16-dind - name: docker:20.10.16-dind
stages: stages:
- full_test - plugin_install
- teacher_workflow
- student_workflow
variables: variables:
DOCKER_HOST: tcp://docker:2375 DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: "" DOCKER_TLS_CERTDIR: ""
EUSER: "appuser" EUSER: "appuser"
EGID: "137" EGID: "137"
MOODLE_WWWROOT: "http://docker:8080" # For the entrypoint installation
MOODLE_URL: "http://docker:8080" # For the test script's curl commands MOODLE_WWWROOT: "http://docker:8080"
# Add the admin credentials here so they are also written to the .env file MOODLE_URL: "http://docker:8080"
MOODLE_ADMIN_USER: "user" MOODLE_ADMIN_USER: "user"
MOODLE_ADMIN_PASS: "QAYwsx@12345" MOODLE_ADMIN_PASS: "QAYwsx@12345"
run_full_automation: RUNNER_REPO: "https://transfer.hft-stuttgart.de/gitlab/cota/examples/cota-runner-jdk21-junit5.git"
stage: full_test DTA_CONFIG_FILE: "teacher-dta-dir-test-runner-jdk21.txt"
when: manual DTA_STUDENT_SUBMISSION_FILE: "student-dir.txt"
before_script:
- apk add --no-cache curl bash jq bind-tools
- echo "Checking DNS resolution..."
- nslookup docker || getent hosts docker
- echo "Checking Docker client and daemon..."
- docker version
- until docker info > /dev/null 2>&1; do echo "Waiting for Docker daemon..."; sleep 3; done
# Explicitly create the named volume # 🧩 Stage 1: Install and activate plugin inside Moodle container
- docker volume create cota-infra_dta_tests_data install_plugin:
stage: plugin_install
# Fix permissions on the volume for appuser (UID 137)
- echo "Setting permissions on dta_tests_data volume..."
- docker run --rm -v cota-infra_dta_tests_data:/data alpine chown 137:137 /data
script: script:
# Create a .env file on the fly. Docker Compose will automatically read this - apk add --no-cache bash curl jq git
# file and pass the variables to the containers. - echo "Running plugin install script..."
- echo "Creating .env file for Docker Compose..." - bash ./script_1_install_plugin.sh
- echo "MOODLE_WWWROOT=${MOODLE_WWWROOT}" > .env artifacts:
- echo "MOODLE_ADMIN_USER=${MOODLE_ADMIN_USER}" >> .env paths:
- echo "MOODLE_ADMIN_PASS=${MOODLE_ADMIN_PASS}" >> .env - plugin_install.log
- echo "EUSER=${EUSER}" >> .env expire_in: 1 day
- echo "EGID=${EGID}" >> .env
# 🧩 Stage 2: Teacher workflow — creates course, assignment, and saves outputs
- echo "Starting Docker environment..." teacher_workflow:
- docker compose up -d stage: teacher_workflow
script:
# Loop until the Moodle installation is complete. - apk add --no-cache bash curl jq git
- echo "Waiting for Moodle first-time installation to complete..." - echo "Running teacher workflow..."
- | - bash ./script_2_teacher_workflow.sh
timeout=300 artifacts:
while ! docker exec moodle-web-official [ -f /var/www/html/config.php ]; do paths:
timeout=$((timeout - 5)) - .env # Contains course_id, assignment_id, etc.
if [ $timeout -le 0 ]; then expire_in: 1 day
echo "❌ ERROR: Moodle installation timed out after 5 minutes." needs:
docker logs moodle-web-official - job: install_plugin
exit 1 artifacts: true
fi
echo " -> Installation not yet complete, waiting 5 more seconds..." # 🧩 Stage 3: Student workflow — uses env values from Stage 2
sleep 5 student_workflow:
done stage: student_workflow
- echo "✅ Moodle installation complete (config.php found)." script:
- apk add --no-cache bash curl jq git
# Now that Moodle is stable, we can proceed with the rest of the script. - echo "Running student submission workflow..."
- chmod +x test-moodle.sh - bash ./script_3_student_workflow.sh
- echo "Executing the main automation script..." needs:
- ./test-moodle.sh - job: teacher_workflow
artifacts: true
after_script: when: manual # You can run it manually if needed
- echo "Tearing down Docker environment..."
- docker-compose down -v
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment