Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GHA support to moodle-docker #159

Merged
merged 1 commit into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 183 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
name: moodle-docker CI

on: [push, pull_request]

jobs:
PHPUnit:
runs-on: ubuntu-18.04

strategy:
fail-fast: false
matrix:
include:
# PostgreSQL (highest, lowest php supported)
- { branch: master, php: "8.0", database: pgsql, suite: phpunit-full } # Full run only for mater.
- { branch: master, php: "7.3", database: pgsql, suite: phpunit-full }
- { branch: MOODLE_311_STABLE, php: "8.0", database: pgsql, suite: phpunit } # Other branches, quicker run.
- { branch: MOODLE_311_STABLE, php: "7.3", database: pgsql, suite: phpunit }
- { branch: MOODLE_310_STABLE, php: "7.4", database: pgsql, suite: phpunit }
- { branch: MOODLE_310_STABLE, php: "7.2", database: pgsql, suite: phpunit }
- { branch: MOODLE_39_STABLE, php: "7.4", database: pgsql, suite: phpunit }
- { branch: MOODLE_39_STABLE, php: "7.2", database: pgsql, suite: phpunit }
# MariaDB (lowest php supported)
- { branch: master, php: "7.3", database: mariadb, suite: phpunit }
- { branch: MOODLE_311_STABLE, php: "7.3", database: mariadb, suite: phpunit }
- { branch: MOODLE_310_STABLE, php: "7.2", database: mariadb, suite: phpunit }
- { branch: MOODLE_39_STABLE, php: "7.2", database: mariadb, suite: phpunit }
# Other databases (highest php supported)
- { branch: master, php: "8.0", database: mssql, suite: phpunit }
- { branch: MOODLE_311_STABLE, php: "8.0", database: mssql, suite: phpunit }
- { branch: MOODLE_310_STABLE, php: "7.4", database: mssql, suite: phpunit }
- { branch: MOODLE_39_STABLE, php: "7.4", database: mssql, suite: phpunit }
- { branch: master, php: "8.0", database: mysql, suite: phpunit }
- { branch: MOODLE_311_STABLE, php: "8.0", database: mysql, suite: phpunit }
- { branch: MOODLE_310_STABLE, php: "7.4", database: mysql, suite: phpunit }
- { branch: MOODLE_39_STABLE, php: "7.4", database: mysql, suite: phpunit }
- { branch: master, php: "8.0", database: oracle, suite: phpunit }
- { branch: MOODLE_311_STABLE, php: "8.0", database: oracle, suite: phpunit }
- { branch: MOODLE_310_STABLE, php: "7.4", database: oracle, suite: phpunit }
- { branch: MOODLE_39_STABLE, php: "7.4", database: oracle, suite: phpunit }

steps:
- name: Checking out moodle-docker
uses: actions/checkout@v2

- name: Checking out moodle
uses: actions/checkout@v2
with:
repository: moodle/moodle
path: moodle
ref: ${{ matrix.branch }}

- name: Prepare moodle-docker environment
run: |
cp config.docker-template.php moodle/config.php
export MOODLE_DOCKER_DB="${{ matrix.database }}"
export MOODLE_DOCKER_PHP_VERSION="${{ matrix.php }}"
export SUITE="${{ matrix.suite }}"
tests/phpunit-setup.sh

- name: Run moodle-docker tests
run: |
export MOODLE_DOCKER_DB="${{ matrix.database }}"
export SUITE="${{ matrix.suite }}"
tests/phpunit-test.sh

- name: Stop moodle-docker
run: |
export MOODLE_DOCKER_DB="${{ matrix.database }}"
export SUITE="${{ matrix.suite }}"
tests/phpunit-teardown.sh

Behat:
runs-on: ubuntu-18.04

strategy:
fail-fast: false
matrix:
include:
# PostgreSQL (highest, lowest php supported)
- { branch: master, php: "8.0", database: pgsql, browser: chrome, suite: behat }
- { branch: master, php: "7.3", database: pgsql, browser: firefox, suite: behat }
- { branch: MOODLE_311_STABLE, php: "8.0", database: pgsql, browser: chrome, suite: behat }
- { branch: MOODLE_311_STABLE, php: "7.3", database: pgsql, browser: firefox, suite: behat }
- { branch: MOODLE_310_STABLE, php: "7.4", database: pgsql, browser: chrome, suite: behat }
- { branch: MOODLE_310_STABLE, php: "7.2", database: pgsql, browser: firefox, suite: behat }
- { branch: MOODLE_39_STABLE, php: "7.4", database: pgsql, browser: chrome, suite: behat }
- { branch: MOODLE_39_STABLE, php: "7.2", database: pgsql, browser: firefox, suite: behat }
# MariaDB (lowest php supported)
- { branch: master, php: "7.3", database: mariadb, browser: chrome, suite: behat }
- { branch: MOODLE_311_STABLE, php: "7.3", database: mariadb, browser: firefox, suite: behat }
- { branch: MOODLE_310_STABLE, php: "7.2", database: mariadb, browser: chrome, suite: behat }
- { branch: MOODLE_39_STABLE, php: "7.2", database: mariadb, browser: firefox, suite: behat }
# Other databases (highest php supported")
- { branch: master, php: "8.0", database: mssql, browser: chrome, suite: behat }
- { branch: MOODLE_311_STABLE, php: "8.0", database: mssql, browser: firefox, suite: behat }
- { branch: MOODLE_310_STABLE, php: "7.4", database: mssql, browser: chrome, suite: behat }
- { branch: MOODLE_39_STABLE, php: "7.4", database: mssql, browser: firefox, suite: behat }
- { branch: master, php: "8.0", database: mysql, browser: chrome, suite: behat }
- { branch: MOODLE_311_STABLE, php: "8.0", database: mysql, browser: firefox, suite: behat }
- { branch: MOODLE_310_STABLE, php: "7.4", database: mysql, browser: chrome, suite: behat }
- { branch: MOODLE_39_STABLE, php: "7.4", database: mysql, browser: firefox, suite: behat }
- { branch: master, php: "8.0", database: oracle, browser: chrome, suite: behat }
- { branch: MOODLE_311_STABLE, php: "8.0", database: oracle, browser: firefox, suite: behat }
- { branch: MOODLE_310_STABLE, php: "7.4", database: oracle, browser: chrome, suite: behat }
- { branch: MOODLE_39_STABLE, php: "7.4", database: oracle, browser: firefox, suite: behat }

steps:
- name: Checking out moodle-docker
uses: actions/checkout@v2

- name: Checking out moodle
uses: actions/checkout@v2
with:
repository: moodle/moodle
path: moodle
ref: ${{ matrix.branch }}

- name: Prepare moodle-docker environment
run: |
cp config.docker-template.php moodle/config.php
export MOODLE_DOCKER_DB="${{ matrix.database }}"
export MOODLE_DOCKER_PHP_VERSION="${{ matrix.php }}"
export SUITE="${{ matrix.suite }}"
export MOODLE_DOCKER_BROWSER="${{ matrix.browser }}"
tests/behat-setup.sh

- name: Run moodle-docker tests
run: |
export MOODLE_DOCKER_DB="${{ matrix.database }}"
export SUITE="${{ matrix.suite }}"
tests/behat-test.sh

- name: Stop moodle-docker
run: |
export MOODLE_DOCKER_DB="${{ matrix.database }}"
export SUITE="${{ matrix.suite }}"
tests/behat-teardown.sh

App:
runs-on: ubuntu-18.04

strategy:
fail-fast: false
matrix:
include:
# PostgreSQL (highest, lowest php supported)
- { branch: master, php: "8.0", database: pgsql, suite: app-development, app-version: "3.9.0"}
- { branch: master, php: "7.3", database: pgsql, suite: app-development, app-version: "3.9.0"}
- { branch: master, php: "8.0", database: pgsql, suite: app, app-version: "3.9.0"}
- { branch: master, php: "7.3", database: pgsql, suite: app, app-version: "3.9.0"}

steps:
- name: Checking out moodle-docker
uses: actions/checkout@v2

- name: Checking out moodle
uses: actions/checkout@v2
with:
repository: moodle/moodle
path: moodle
ref: ${{ matrix.branch }}

- name: Prepare moodle-docker environment
run: |
cp config.docker-template.php moodle/config.php
export MOODLE_DOCKER_DB="${{ matrix.database }}"
export MOODLE_DOCKER_PHP_VERSION="${{ matrix.php }}"
export SUITE="${{ matrix.suite }}"
export MOODLE_DOCKER_APP_VERSION="${{ matrix.app-version }}"
tests/app-setup.sh

- name: Run moodle-docker tests
run: |
export MOODLE_DOCKER_DB="${{ matrix.database }}"
export SUITE="${{ matrix.suite }}"
tests/app-test.sh

- name: Stop moodle-docker
run: |
export MOODLE_DOCKER_DB="${{ matrix.database }}"
export SUITE="${{ matrix.suite }}"
export MOODLE_DOCKER_APP_VERSION="${{ matrix.app-version }}"
tests/app-teardown.sh
2 changes: 1 addition & 1 deletion bin/moodle-docker-wait-for-db
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ then
sleep 15
done
else
sleep 5
sleep 10
fi
37 changes: 37 additions & 0 deletions tests/app-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -e
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"

export MOODLE_DOCKER_WWWROOT="${basedir}/moodle"
export MOODLE_DOCKER_BROWSER="chrome"

if [ "$SUITE" = "app-development" ];
then
export MOODLE_DOCKER_APP_PATH="${basedir}/app"
git clone --branch "v$MOODLE_DOCKER_APP_VERSION" --depth 1 git://github.com/moodlehq/moodleapp $basedir/app
git clone --branch "v$MOODLE_DOCKER_APP_VERSION" --depth 1 git://github.com/moodlehq/moodle-local_moodlemobileapp $basedir/moodle/local/moodlemobileapp

docker run --volume $basedir/app:/app --workdir /app node:11 npm run setup
docker run --volume $basedir/app:/app --workdir /app node:11 npm ci

initcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/behat/cli/init.php"
elif [ "$SUITE" = "app" ];
then
git clone --branch "v$MOODLE_DOCKER_APP_VERSION" --depth 1 git://github.com/moodlehq/moodle-local_moodlemobileapp $basedir/moodle/local/moodlemobileapp

initcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/behat/cli/init.php"
else
echo "Error, unknown suite '$SUITE'"
exit 1
fi

echo "Pulling docker images"
$basedir/bin/moodle-docker-compose pull
echo "Starting up container"
$basedir/bin/moodle-docker-compose up -d
echo "Waiting for DB to come up"
$basedir/bin/moodle-docker-wait-for-db
echo "Waiting for Moodle app to come up"
$basedir/bin/moodle-docker-wait-for-app
echo "Running: $initcmd"
$basedir/$initcmd
20 changes: 20 additions & 0 deletions tests/app-teardown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -e
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"

export MOODLE_DOCKER_WWWROOT="${basedir}/moodle"
export MOODLE_DOCKER_BROWSER="chrome"

if [ "$SUITE" = "app-development" ];
then
export MOODLE_DOCKER_APP_PATH="${basedir}/app"
elif [ "$SUITE" = "app" ];
then
echo
else
echo "Error, unknown suite '$SUITE'"
exit 1
fi

echo "Stopping down container"
$basedir/bin/moodle-docker-compose down
17 changes: 17 additions & 0 deletions tests/app-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -e

basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"

export MOODLE_DOCKER_WWWROOT="${basedir}/moodle"

if [ "$SUITE" = "app" ] || [ "$SUITE" = "app-development" ];
then
testcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/behat/cli/run.php --tags=@app&&@mod_login"
else
echo "Error, unknown suite '$SUITE'"
exit 1
fi

echo "Running: $testcmd"
$basedir/$testcmd
22 changes: 22 additions & 0 deletions tests/behat-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"

export MOODLE_DOCKER_WWWROOT="${basedir}/moodle"

if [ "$SUITE" = "behat" ];
then
initcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/behat/cli/init.php"
else
echo "Error, unknown suite '$SUITE'"
exit 1
fi

echo "Pulling docker images"
$basedir/bin/moodle-docker-compose pull
echo "Starting up container"
$basedir/bin/moodle-docker-compose up -d
echo "Waiting for DB to come up"
$basedir/bin/moodle-docker-wait-for-db
echo "Running: $initcmd"
$basedir/$initcmd
16 changes: 16 additions & 0 deletions tests/behat-teardown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"

export MOODLE_DOCKER_WWWROOT="${basedir}/moodle"

if [ "$SUITE" = "behat" ];
then
echo
else
echo "Error, unknown suite '$SUITE'"
exit 1
fi

echo "Stopping down container"
$basedir/bin/moodle-docker-compose down
17 changes: 17 additions & 0 deletions tests/behat-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -e

basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"

export MOODLE_DOCKER_WWWROOT="${basedir}/moodle"

if [ "$SUITE" = "behat" ];
then
testcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/behat/cli/run.php --tags=@auth_manual"
else
echo "Error, unknown suite '$SUITE'"
exit 1
fi

echo "Running: $testcmd"
$basedir/$testcmd
26 changes: 26 additions & 0 deletions tests/phpunit-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -e
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"

export MOODLE_DOCKER_WWWROOT="${basedir}/moodle"

if [ "$SUITE" = "phpunit" ];
then
initcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/phpunit/cli/init.php"
elif [ "$SUITE" = "phpunit-full" ];
then
export MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES=true
initcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/phpunit/cli/init.php"
else
echo "Error, unknown suite '$SUITE'"
exit 1
fi

echo "Pulling docker images"
$basedir/bin/moodle-docker-compose pull
echo "Starting up container"
$basedir/bin/moodle-docker-compose up -d
echo "Waiting for DB to come up"
$basedir/bin/moodle-docker-wait-for-db
echo "Running: $initcmd"
$basedir/$initcmd
19 changes: 19 additions & 0 deletions tests/phpunit-teardown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -e
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"

export MOODLE_DOCKER_WWWROOT="${basedir}/moodle"

if [ "$SUITE" = "phpunit" ];
then
echo
elif [ "$SUITE" = "phpunit-full" ];
then
export MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES=true
else
echo "Error, unknown suite '$SUITE'"
exit 1
fi

echo "Stopping down container"
$basedir/bin/moodle-docker-compose down
20 changes: 20 additions & 0 deletions tests/phpunit-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -e

basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"

export MOODLE_DOCKER_WWWROOT="${basedir}/moodle"

if [ "$SUITE" = "phpunit" ];
then
testcmd="bin/moodle-docker-compose exec -T webserver vendor/bin/phpunit --filter core_dml_testcase"
elif [ "$SUITE" = "phpunit-full" ];
then
testcmd="bin/moodle-docker-compose exec -T webserver vendor/bin/phpunit --verbose"
else
echo "Error, unknown suite '$SUITE'"
exit 1
fi

echo "Running: $testcmd"
$basedir/$testcmd