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
services:
- name: docker:20.10.16-dind
stages:
- full_test
- plugin_install
- teacher_workflow
- student_workflow
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
EUSER: "appuser"
EGID: "137"
MOODLE_WWWROOT: "http://docker:8080" # For the entrypoint installation
MOODLE_URL: "http://docker:8080" # For the test script's curl commands
# Add the admin credentials here so they are also written to the .env file
MOODLE_WWWROOT: "http://docker:8080"
MOODLE_URL: "http://docker:8080"
MOODLE_ADMIN_USER: "user"
MOODLE_ADMIN_PASS: "QAYwsx@12345"
run_full_automation:
stage: full_test
when: manual
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
RUNNER_REPO: "https://transfer.hft-stuttgart.de/gitlab/cota/examples/cota-runner-jdk21-junit5.git"
DTA_CONFIG_FILE: "teacher-dta-dir-test-runner-jdk21.txt"
DTA_STUDENT_SUBMISSION_FILE: "student-dir.txt"
# Explicitly create the named volume
- docker volume create cota-infra_dta_tests_data
# 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
# 🧩 Stage 1: Install and activate plugin inside Moodle container
install_plugin:
stage: plugin_install
script:
# Create a .env file on the fly. Docker Compose will automatically read this
# file and pass the variables to the containers.
- echo "Creating .env file for Docker Compose..."
- echo "MOODLE_WWWROOT=${MOODLE_WWWROOT}" > .env
- echo "MOODLE_ADMIN_USER=${MOODLE_ADMIN_USER}" >> .env
- echo "MOODLE_ADMIN_PASS=${MOODLE_ADMIN_PASS}" >> .env
- echo "EUSER=${EUSER}" >> .env
- echo "EGID=${EGID}" >> .env
- echo "Starting Docker environment..."
- docker compose up -d
# Loop until the Moodle installation is complete.
- echo "Waiting for Moodle first-time installation to complete..."
- |
timeout=300
while ! docker exec moodle-web-official [ -f /var/www/html/config.php ]; do
timeout=$((timeout - 5))
if [ $timeout -le 0 ]; then
echo "❌ ERROR: Moodle installation timed out after 5 minutes."
docker logs moodle-web-official
exit 1
fi
echo " -> Installation not yet complete, waiting 5 more seconds..."
sleep 5
done
- echo "✅ Moodle installation complete (config.php found)."
# Now that Moodle is stable, we can proceed with the rest of the script.
- chmod +x test-moodle.sh
- echo "Executing the main automation script..."
- ./test-moodle.sh
after_script:
- echo "Tearing down Docker environment..."
- docker-compose down -v
- apk add --no-cache bash curl jq git
- echo "Running plugin install script..."
- bash ./script_1_install_plugin.sh
artifacts:
paths:
- plugin_install.log
expire_in: 1 day
# 🧩 Stage 2: Teacher workflow — creates course, assignment, and saves outputs
teacher_workflow:
stage: teacher_workflow
script:
- apk add --no-cache bash curl jq git
- echo "Running teacher workflow..."
- bash ./script_2_teacher_workflow.sh
artifacts:
paths:
- .env # Contains course_id, assignment_id, etc.
expire_in: 1 day
needs:
- job: install_plugin
artifacts: true
# 🧩 Stage 3: Student workflow — uses env values from Stage 2
student_workflow:
stage: student_workflow
script:
- apk add --no-cache bash curl jq git
- echo "Running student submission workflow..."
- bash ./script_3_student_workflow.sh
needs:
- job: teacher_workflow
artifacts: true
when: manual # You can run it manually if needed
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