-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
name: Web Installer Testing | ||
description: Automated testing of the Moodle web installation | ||
inputs: | ||
php: | ||
description: 'PHP Version to test' | ||
required: true | ||
default: 8.3 | ||
|
||
# | ||
# It's triggered manually (workflow_dispatch) and helps to ensure that the web installation process works as | ||
# expected and helps to detect any issues early. | ||
# | ||
# The workflow sets up a PostgreSQL database, PHP, clone moodle-webinstall repository and run the install Behat test. | ||
# It also takes a screenshot of the Moodle installation page and uploads it as an artifact so it can be verified in | ||
# case of failures. | ||
# | ||
# For more information about the web install testing, see https://github.com/moodlehq/moodle-webinstaller-test | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setting up DB PostgreSQL | ||
uses: m4nu56/postgresql-action@v1 | ||
with: | ||
postgresql version: 13 | ||
postgresql db: test | ||
postgresql user: test | ||
postgresql password: test | ||
|
||
- name: Wait for PostgreSQL to be ready | ||
shell: bash | ||
run: | | ||
for i in {1..30}; do | ||
if pg_isready -h localhost -p 5432 -U test; then | ||
echo "PostgreSQL is ready" | ||
break | ||
else | ||
echo "Waiting for PostgreSQL to be ready..." | ||
sleep 2 | ||
fi | ||
done | ||
- name: Setting up PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ inputs.php }} | ||
ini-values: max_input_vars=5000 | ||
coverage: none | ||
|
||
- name: Configuring git vars | ||
uses: rlespinasse/github-slug-action@v4 | ||
|
||
- name: Checking out code from ${{ env.GITHUB_REF_SLUG }} | ||
uses: actions/checkout@v4 | ||
with: | ||
path: moodle | ||
|
||
- name: Clone Plugin repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: moodlehq/moodle-webinstaller-test | ||
ref: main | ||
path: webinstall | ||
|
||
- name: Install Plugin Composer Dependencies | ||
shell: bash | ||
run: composer install | ||
working-directory: webinstall | ||
|
||
- name: Start PHP built-in server | ||
shell: bash | ||
run: | | ||
nohup php -S localhost:8080 -t . > server.log 2>&1 & | ||
echo "Waiting for PHP built-in server to be ready..." | ||
for i in {1..5}; do | ||
if nc -z localhost 8080; then | ||
echo "PHP built-in server is ready" | ||
break | ||
else | ||
echo "Waiting for PHP built-in server to be ready..." | ||
sleep 2 | ||
fi | ||
done | ||
working-directory: moodle | ||
|
||
- name: Install Puppeteer | ||
shell: bash | ||
run: npm install puppeteer | ||
working-directory: webinstall | ||
|
||
- name: Take screenshot of Moodle installation page | ||
shell: bash | ||
run: node screenshot.js ${{ inputs.php }} | ||
working-directory: webinstall | ||
|
||
- name: Run Behat tests | ||
shell: bash | ||
run: vendor/bin/behat tests/behat/install.feature | ||
working-directory: webinstall | ||
env: | ||
MOODLE_SITE_URL: http://localhost:8080/moodle | ||
DB_TYPE: pgsql | ||
DB_HOST: localhost | ||
DB_NAME: test | ||
DB_USER: test | ||
DB_PASS: test | ||
|
||
- name: Print PHP built-in server logs | ||
shell: bash | ||
if: ${{ !cancelled() }} | ||
run: cat server.log | ||
working-directory: moodle | ||
|
||
- name: Upload screenshot | ||
if: ${{ !cancelled() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: screenshot-${{ inputs.php }} | ||
path: webinstall/moodle${{ inputs.php }}.png |