Skip to content

Commit

Permalink
Change to composite workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Jul 22, 2024
1 parent 1918afc commit 29a1f45
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 110 deletions.
112 changes: 6 additions & 106 deletions .github/workflows/web-installer-test.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
name: Web Installation Testing

# This workflow is designed to automate the testing of Moodle's web installation.
#
# 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 this repository and run
# the installation 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
name: Web Installer Testing

on:
workflow_dispatch:
Expand All @@ -22,104 +12,14 @@ on:
required: true

jobs:
behat:
InstallationTest:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
php: [ 8.1, 8.3 ]

env:
MOODLE_SITE_URL: http://localhost:8080/moodle
DB_TYPE: pgsql
DB_HOST: localhost
DB_NAME: test
DB_USER: test
DB_PASS: test

os: [ubuntu-latest]
php: [8.1, 8.3]
steps:
- name: Print repository and branch
run: |
echo "Repository: ${{ github.event.inputs.repository }}"
echo "Branch: ${{ github.event.inputs.branch }}"
- 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
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: ${{ matrix.php }}
ini-values: max_input_vars=5000
coverage: none

- name: Clone moodle site repository and branch
run: git clone -b ${{ github.event.inputs.branch }} ${{ github.event.inputs.repository }} moodle

- name: Clone Plugin repository
uses: actions/checkout@v4
with:
repository: lameze/moodle-webinstall
ref: main
path: webinstall

- name: Install Plugin Composer Dependencies
run: composer install
working-directory: webinstall

- name: Start PHP built-in server
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
run: npm install puppeteer
working-directory: webinstall

- name: Take screenshot of Moodle installation page
run: node screenshot.js ${{ matrix.php }}
working-directory: webinstall

- name: Run Behat tests
run: vendor/bin/behat tests/behat/install.feature
working-directory: webinstall

- name: Print PHP built-in server logs
if: ${{ !cancelled() }}
run: cat server.log
working-directory: moodle

- name: Upload screenshot
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
- uses: moodlehq/moodle-webinstaller-test@main
with:
name: screenshot-${{ matrix.php }}
path: webinstall/moodle${{ matrix.php }}.png
php: ${{ matrix.php }}
14 changes: 10 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ inputs:
runs:
using: "composite"
steps:
- name: Print repository and branch
shell: bash
run: |
echo "Repository: ${{ github.event.inputs.repository }}"
echo "Branch: ${{ github.event.inputs.branch }}"
- name: Setting up DB PostgreSQL
uses: m4nu56/postgresql-action@v1
with:
Expand Down Expand Up @@ -50,10 +56,10 @@ runs:
- 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 moodle site repository and branch
run: |
git clone -b ${{ github.event.inputs.branch }} ${{ github.event.inputs.repository }} moodle
shell: bash

- name: Clone Plugin repository
uses: actions/checkout@v4
Expand Down

0 comments on commit 29a1f45

Please sign in to comment.