From 4ef9fe590cb6dcc9277322acd63a58c5923af512 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Mon, 6 May 2024 15:54:42 +0200 Subject: [PATCH 1/4] Set gitpod permission to install plugins --- .gitpod.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitpod.yml b/.gitpod.yml index 45014466..ccbfd47f 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -30,6 +30,9 @@ tasks: # Open Moodle site in browser. gp ports await 8000 && gp preview $(gp url 8000) + # Change permissions to allow installation of plugins. + bin/moodle-docker-compose exec webserver bash -c 'chmod -R 777 .' + command: | # Update the patch to the latest version. cd moodle From ccfd87fbd2e66898b7fb0e841612e703e846c7fb Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Mon, 6 May 2024 15:55:55 +0200 Subject: [PATCH 2/4] Initialise gitpod with data when DATAFILE is given --- .gitpod.yml | 6 ++++++ .gitpod/setup-env.sh | 6 ++++++ README.md | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitpod.yml b/.gitpod.yml index ccbfd47f..41837089 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -33,6 +33,12 @@ tasks: # Change permissions to allow installation of plugins. bin/moodle-docker-compose exec webserver bash -c 'chmod -R 777 .' + # Add some data if the file exists. + if [ -r "moodle/admin/tool/generator/tests/fixtures/gitpod-basic-scenario.feature" ]; + then + bin/moodle-docker-compose exec webserver php admin/tool/generator/cli/runtestscenario.php --feature=./../tests/fixtures/gitpod-basic-scenario.feature + fi + command: | # Update the patch to the latest version. cd moodle diff --git a/.gitpod/setup-env.sh b/.gitpod/setup-env.sh index b2048953..96e2a1c5 100755 --- a/.gitpod/setup-env.sh +++ b/.gitpod/setup-env.sh @@ -10,3 +10,9 @@ fi # Clone Moodle repository. cd "${GITPOD_REPO_ROOT}" && git clone --branch "${MOODLE_BRANCH}" --single-branch "${MOODLE_REPOSITORY}" moodle + +# Download the data file (if given). It will be used to generate some data. +if [ -n "$DATAFILE" ]; +then + wget -O moodle/admin/tool/generator/tests/fixtures/gitpod-basic-scenario.feature "${DATAFILE}" +fi diff --git a/README.md b/README.md index 02228ffd..ef491757 100644 --- a/README.md +++ b/README.md @@ -341,8 +341,9 @@ The Moodle Gitpod template supports the following environment variables: * `MOODLE_REPOSITORY`. The Moodle repository to be cloned. The value should be URL encoded. If left undefined, the default repository `https://github.com/moodle/moodle.git` is used. * `MOODLE_BRANCH`. The Moodle branch to be cloned. If left undefined, the default branch `main` is employed. +* `DATAFILE`. When specified, this feature URL initializes the Moodle site with essential data. The value should be URL encoded. The content of this file adheres to the [Behat generators format](https://moodledev.io/general/development/tools/generator#create-a-testing-scenario-using-behat-generators) for creating testing scenarios. -For a practical demonstration, launch a Gitpod workspace with the 'main' branch patch for [MDL-79912](https://tracker.moodle.org/browse/MDL-79912). Simply open the following URL in your web browser (note that MOODLE_REPOSITORY should be URL encoded). The password for the admin user is **test**: +For a practical demonstration, launch a Gitpod workspace with the 'main' branch patch for [MDL-79912](https://tracker.moodle.org/browse/MDL-79912). Simply open the following URL in your web browser (note that MOODLE_REPOSITORY should be URL encoded). The password for the **admin** user is **test**: ``` https://gitpod.io/#MOODLE_REPOSITORY=https%3A%2F%2Fgithub.com%2Fsarjona%2Fmoodle.git,MOODLE_BRANCH=MDL-79912-main/https://github.com/moodlehq/moodle-docker From 84522b248b335bc81ff66549485f26accfc1bf9d Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Mon, 6 May 2024 16:57:06 +0200 Subject: [PATCH 3/4] Add adminer to gitpod --- .gitpod/setup-env.sh | 16 ++++++++++++++++ README.md | 1 + 2 files changed, 17 insertions(+) diff --git a/.gitpod/setup-env.sh b/.gitpod/setup-env.sh index 96e2a1c5..4b344f6b 100755 --- a/.gitpod/setup-env.sh +++ b/.gitpod/setup-env.sh @@ -16,3 +16,19 @@ if [ -n "$DATAFILE" ]; then wget -O moodle/admin/tool/generator/tests/fixtures/gitpod-basic-scenario.feature "${DATAFILE}" fi + +# Install adminer. +if [ -n "$INSTALLADMINER" ]; +then +cat << EOF > local.yml +services: + + adminer: + image: adminer:latest + restart: always + ports: + - 8080:8080 + depends_on: + - "db" +EOF +fi diff --git a/README.md b/README.md index ef491757..730f4d4a 100644 --- a/README.md +++ b/README.md @@ -342,6 +342,7 @@ The Moodle Gitpod template supports the following environment variables: * `MOODLE_REPOSITORY`. The Moodle repository to be cloned. The value should be URL encoded. If left undefined, the default repository `https://github.com/moodle/moodle.git` is used. * `MOODLE_BRANCH`. The Moodle branch to be cloned. If left undefined, the default branch `main` is employed. * `DATAFILE`. When specified, this feature URL initializes the Moodle site with essential data. The value should be URL encoded. The content of this file adheres to the [Behat generators format](https://moodledev.io/general/development/tools/generator#create-a-testing-scenario-using-behat-generators) for creating testing scenarios. +* `INSTALLADMINER`. Add this variable, set to any value, to install [adminer](https://www.adminer.org/). For a practical demonstration, launch a Gitpod workspace with the 'main' branch patch for [MDL-79912](https://tracker.moodle.org/browse/MDL-79912). Simply open the following URL in your web browser (note that MOODLE_REPOSITORY should be URL encoded). The password for the **admin** user is **test**: From 20dad07db9db07ccdc082c2de786e902db644ee0 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Mon, 6 May 2024 17:16:58 +0200 Subject: [PATCH 4/4] Add parameter to speed gitpod clone --- .gitpod/setup-env.sh | 9 ++++++++- README.md | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitpod/setup-env.sh b/.gitpod/setup-env.sh index 4b344f6b..37a3b906 100755 --- a/.gitpod/setup-env.sh +++ b/.gitpod/setup-env.sh @@ -8,8 +8,15 @@ then export MOODLE_BRANCH=main fi +if [ -z "$CLONEALL" ]; +then + FASTCLONE='--depth 1' +else + FASTCLONE="" +fi + # Clone Moodle repository. -cd "${GITPOD_REPO_ROOT}" && git clone --branch "${MOODLE_BRANCH}" --single-branch "${MOODLE_REPOSITORY}" moodle +cd "${GITPOD_REPO_ROOT}" && git clone ${FASTCLONE} --branch "${MOODLE_BRANCH}" --single-branch "${MOODLE_REPOSITORY}" moodle # Download the data file (if given). It will be used to generate some data. if [ -n "$DATAFILE" ]; diff --git a/README.md b/README.md index 730f4d4a..295f7ece 100644 --- a/README.md +++ b/README.md @@ -343,6 +343,7 @@ The Moodle Gitpod template supports the following environment variables: * `MOODLE_BRANCH`. The Moodle branch to be cloned. If left undefined, the default branch `main` is employed. * `DATAFILE`. When specified, this feature URL initializes the Moodle site with essential data. The value should be URL encoded. The content of this file adheres to the [Behat generators format](https://moodledev.io/general/development/tools/generator#create-a-testing-scenario-using-behat-generators) for creating testing scenarios. * `INSTALLADMINER`. Add this variable, set to any value, to install [adminer](https://www.adminer.org/). +* `CLONEALL`. If not set, a shallow clone is created, truncating the history to reduce the clone size. Set to `1` for a full clone. For a practical demonstration, launch a Gitpod workspace with the 'main' branch patch for [MDL-79912](https://tracker.moodle.org/browse/MDL-79912). Simply open the following URL in your web browser (note that MOODLE_REPOSITORY should be URL encoded). The password for the **admin** user is **test**: