diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..7f452e9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,68 @@ +name: Tutor Open edX CI + +on: [push] + +jobs: + setup-tutor: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y python3 python3-pip curl + pip3 install tutor + + - name: Configure Tutor plugin + run: | + tutor config save + echo 'Patching Caddyfile...' + echo " + {$default_site_port} { + import proxy 'lms:8000' + } + " > $(tutor config printroot)/env/apps/caddy/Caddyfile + + echo 'Patching CMS production settings...' + echo "ALLOWED_HOSTS = ['*']" > $(tutor config printroot)/env/apps/openedx/settings/cms/production.py + + echo 'Patching LMS production settings...' + echo "ALLOWED_HOSTS = ['*']" > $(tutor config printroot)/env/apps/openedx/settings/lms/production.py + + - name: Launch Tutor + run: | + tutor config save + tutor local launch -I + + - name: Install eox-core and eox-tenant in LMS + run: | + # Install eox-core and eox-tenant in the LMS container + tutor local run lms pip install eox-core + tutor local run lms pip install eox-tenant + shell: bash + + - name: Check Open edX LMS heartbeat + run: | + until curl -sSf http://local.edly.io/heartbeat; do + echo "Waiting for LMS to be ready..." + sleep 5 + done + echo "LMS is up and running!" + + - name: Check Open edX eox-core eox-info + run: | + until curl -sSf http://local.edly.io/eox-core/eox-info; do + echo "Waiting for EOX CORE to be ready..." + sleep 5 + done + echo "EOX CORE is up and running!" + + - name: Check eox-tenant eox-info + run: | + until curl -sSf http://local.edly.io/eox-tenant/eox-info; do + echo "Waiting for EOX TENANT to be ready..." + sleep 5 + done + echo "EOX TENANT is up and running!" diff --git a/action.yml b/action.yml index f95e6fa..119e360 100644 --- a/action.yml +++ b/action.yml @@ -1,36 +1,45 @@ -name: Integration Test in Tutor -description: 'A Github action to test your plugin in Tutor (Open edX distribution)' -inputs: - app_name: - description: 'Application name to test. E.g., eox-tenant.' - required: true - tutor_version: - description: 'The tutor version matrix to use.' - required: true - shell_file_to_run: - description: 'The path of the shell file to run the integration tests.' - required: false - -runs: - using: 'composite' - steps: - - name: Prepare Tutor and Launch - run: | - pip install "tutor$INPUT_TUTOR_VERSION" - TUTOR_ROOT="$(pwd)" tutor --version - TUTOR_ROOT="$(pwd)" tutor config save - TUTOR_ROOT="$(pwd)" tutor mounts add lms,cms,lms-worker,cms-worker:$(pwd)/$INPUT_APP:/openedx/$INPUT_APP - chmod 777 . -R - TUTOR_ROOT="$(pwd)" tutor local launch -I - shell: bash - env: - INPUT_APP: ${{ inputs.app_name }} - INPUT_TUTOR_VERSION: ${{ inputs.tutor_version }} - - - name: Run integration tests in lms - if: ${{ inputs.shell_file_to_run }} - run: | - TUTOR_ROOT="$(pwd)" tutor local run lms bash $INPUT_SHELL_FILE - shell: bash - env: - INPUT_SHELL_FILE: /openedx/${{ inputs.app_name }}/${{ inputs.shell_file_to_run }} +name: Tutor Setup with Plugin Verification + +on: [push, pull_request] + +jobs: + setup-tutor: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python 3.11 + uses: actions/setup-python@v2 + with: + python-version: '3.11' + + - name: Install Tutor + run: | + python3 -m pip install --upgrade pip + python3 -m pip install tutor + + - name: Add extra LMS requirements + run: | + # Create a custom Tutor configuration to add extra pip requirements for the LMS + tutor config save --set LMS_EXTRA_PIP_REQUIREMENTS="eox-core\neox-tenant" + + - name: Rebuild the LMS image to include the extra requirements + run: | + tutor images build openedx + + - name: Start Tutor + run: | + tutor local launch -I + + - name: Wait for services to be up + run: | + sleep 60 # Adjust the sleep time as necessary for services to be fully ready + + - name: Check LMS logs + run: | + tutor local logs lms --tail=100 # Retrieve the last 100 lines of LMS logs + + - name: Check LMS heartbeat endpoint + run: | + curl -f http://localhost:8000/heartbeat