2022-06-29 10:58:06 +00:00
|
|
|
name: Acceptance tests (Behat)
|
2022-05-12 11:09:58 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
2022-06-29 10:58:06 +00:00
|
|
|
behat_tags:
|
|
|
|
description: 'Behat tags to execute'
|
2022-05-12 11:09:58 +00:00
|
|
|
moodle_branch:
|
|
|
|
description: 'Moodle branch'
|
|
|
|
required: true
|
2024-01-10 09:08:59 +00:00
|
|
|
default: 'main'
|
2022-05-12 11:09:58 +00:00
|
|
|
moodle_repository:
|
|
|
|
description: 'Moodle repository'
|
|
|
|
required: true
|
2024-01-25 16:28:12 +00:00
|
|
|
default: 'https://github.com/moodle/moodle.git'
|
2022-06-29 10:58:06 +00:00
|
|
|
pull_request:
|
2024-01-19 10:38:06 +00:00
|
|
|
branches: [ main, v*.x ]
|
2022-05-12 11:09:58 +00:00
|
|
|
|
2024-02-29 16:21:25 +00:00
|
|
|
concurrency:
|
|
|
|
group: acceptance-${{ github.ref }}
|
|
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
|
|
|
2022-05-12 11:09:58 +00:00
|
|
|
jobs:
|
2024-01-25 16:28:12 +00:00
|
|
|
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
tags: ${{ steps.set-tags.outputs.tags }}
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
path: app
|
|
|
|
|
|
|
|
- uses: actions/setup-node@v4
|
|
|
|
with:
|
|
|
|
node-version-file: 'app/.nvmrc'
|
|
|
|
|
|
|
|
- name: Install npm dependencies
|
|
|
|
working-directory: app
|
|
|
|
run: npm ci --no-audit
|
|
|
|
|
|
|
|
- name: Build app
|
|
|
|
working-directory: app
|
|
|
|
run: npm run build:test
|
|
|
|
|
2024-02-01 16:04:40 +00:00
|
|
|
- name: Generate SSL certificates
|
|
|
|
working-directory: app
|
|
|
|
run: |
|
|
|
|
mkdir ./ssl
|
|
|
|
openssl req -x509 -nodes \
|
|
|
|
-days 365 \
|
|
|
|
-newkey rsa:2048 \
|
|
|
|
-keyout ./ssl/certificate.key \
|
|
|
|
-out ./ssl/certificate.crt \
|
|
|
|
-subj="/O=Moodle"
|
|
|
|
|
2024-01-25 16:28:12 +00:00
|
|
|
- name: Build Behat plugin
|
|
|
|
working-directory: app
|
|
|
|
run: ./scripts/build-behat-plugin.js ../plugin
|
|
|
|
|
|
|
|
- name: Prepare Behat tags
|
|
|
|
id: set-tags
|
2024-03-19 14:41:52 +00:00
|
|
|
working-directory: app
|
2024-01-25 16:28:12 +00:00
|
|
|
run: |
|
|
|
|
if [ -z $BEHAT_TAGS ]; then
|
2024-03-19 14:41:52 +00:00
|
|
|
tags_json=`.github/scripts/print_behat_tags_json.sh`
|
2024-01-25 16:28:12 +00:00
|
|
|
echo "tags=$tags_json" >> $GITHUB_OUTPUT;
|
|
|
|
else
|
|
|
|
echo "tags=[\"$BEHAT_TAGS\"]" >> $GITHUB_OUTPUT;
|
|
|
|
fi
|
|
|
|
env:
|
|
|
|
BEHAT_TAGS: ${{ github.event.inputs.behat_tags }}
|
|
|
|
|
|
|
|
# We need to upload an artifact so that the download-artifact action
|
|
|
|
# in the "complete" job does not fail if no other artifacts were uploaded.
|
|
|
|
- name: Create build logs
|
|
|
|
run: touch logs.txt
|
|
|
|
|
|
|
|
- name: Upload build logs
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: build
|
|
|
|
path: logs.txt
|
|
|
|
|
|
|
|
- uses: actions/cache/save@v4
|
|
|
|
with:
|
2024-02-01 16:04:40 +00:00
|
|
|
key: build-${{ github.sha }}
|
|
|
|
path: |
|
|
|
|
app/ssl/**/*
|
|
|
|
app/node_modules/**/*
|
|
|
|
app/www/**/*
|
|
|
|
plugin/**/*
|
2024-01-25 16:28:12 +00:00
|
|
|
|
2022-05-12 11:09:58 +00:00
|
|
|
behat:
|
|
|
|
runs-on: ubuntu-latest
|
2024-01-25 16:28:12 +00:00
|
|
|
needs: build
|
|
|
|
continue-on-error: true
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
tags: ${{ fromJSON(needs.build.outputs.tags) }}
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
|
|
|
postgres:
|
2024-12-02 10:14:43 +00:00
|
|
|
image: postgres:14
|
2024-01-25 16:28:12 +00:00
|
|
|
env:
|
|
|
|
POSTGRES_USER: 'postgres'
|
|
|
|
POSTGRES_HOST_AUTH_METHOD: 'trust'
|
|
|
|
ports:
|
|
|
|
- 5432:5432
|
|
|
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
|
2022-11-08 08:35:08 +00:00
|
|
|
|
2022-05-12 11:09:58 +00:00
|
|
|
steps:
|
2024-01-25 16:28:12 +00:00
|
|
|
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
path: app
|
|
|
|
|
|
|
|
- uses: actions/setup-node@v4
|
|
|
|
with:
|
|
|
|
node-version-file: 'app/.nvmrc'
|
|
|
|
|
|
|
|
- uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
2024-12-02 10:14:43 +00:00
|
|
|
php-version: 8.2
|
2024-01-25 16:28:12 +00:00
|
|
|
ini-values: max_input_vars=5000
|
|
|
|
coverage: none
|
|
|
|
|
|
|
|
- uses: actions/cache/restore@v4
|
|
|
|
with:
|
|
|
|
key: build-${{ github.sha }}
|
|
|
|
path: |
|
2024-02-01 16:04:40 +00:00
|
|
|
app/ssl/**/*
|
2024-01-25 16:28:12 +00:00
|
|
|
app/node_modules/**/*
|
|
|
|
app/www/**/*
|
|
|
|
plugin/**/*
|
|
|
|
|
|
|
|
- name: Launch Docker images
|
|
|
|
working-directory: app
|
|
|
|
run: |
|
2024-02-01 16:04:40 +00:00
|
|
|
docker run -d --rm \
|
|
|
|
-p 8001:443 \
|
|
|
|
--name moodleapp \
|
|
|
|
-v ./www:/usr/share/nginx/html \
|
|
|
|
-v ./nginx.conf:/etc/nginx/conf.d/default.conf \
|
|
|
|
-v ./ssl/certificate.crt:/etc/ssl/certificate.crt \
|
|
|
|
-v ./ssl/certificate.key:/etc/ssl/certificate.key \
|
|
|
|
nginx:alpine
|
2024-01-25 16:28:12 +00:00
|
|
|
docker run -d --rm -p 8002:80 --name bigbluebutton moodlehq/bigbluebutton_mock:latest
|
|
|
|
|
|
|
|
- name: Initialise moodle-plugin-ci
|
|
|
|
run: |
|
2024-07-09 08:49:06 +00:00
|
|
|
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4.5
|
2024-01-25 16:28:12 +00:00
|
|
|
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
|
|
|
|
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
|
|
|
|
sudo locale-gen en_AU.UTF-8
|
2024-08-13 08:39:01 +00:00
|
|
|
|
|
|
|
# Install nvm v0.39.7 as a temporary workaround for issue:
|
|
|
|
# https://github.com/moodlehq/moodle-plugin-ci/issues/309
|
|
|
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
2024-01-25 16:28:12 +00:00
|
|
|
|
|
|
|
- name: Install Behat Snapshots plugin
|
2024-07-03 12:23:48 +00:00
|
|
|
run: moodle-plugin-ci add-plugin moodlemobile/moodle-local_behatsnapshots
|
2024-01-25 16:28:12 +00:00
|
|
|
|
|
|
|
- name: Install moodle-plugin-ci
|
|
|
|
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
|
|
|
|
env:
|
|
|
|
DB: pgsql
|
|
|
|
MOODLE_BRANCH: ${{ github.event.inputs.moodle_branch || 'main' }}
|
|
|
|
MOODLE_REPO: ${{ github.event.inputs.moodle_repository || 'https://github.com/moodle/moodle.git' }}
|
2024-02-01 16:04:40 +00:00
|
|
|
MOODLE_BEHAT_IONIC_WWWROOT: https://localhost:8001
|
2024-01-25 16:28:12 +00:00
|
|
|
MOODLE_BEHAT_DEFAULT_BROWSER: chrome
|
2024-07-03 12:23:48 +00:00
|
|
|
MOODLE_BEHAT_CHROME_CAPABILITIES: "['extra_capabilities' => ['chromeOptions' => ['args' => ['--ignore-certificate-errors', '--allow-running-insecure-content']]]]"
|
2024-01-25 16:28:12 +00:00
|
|
|
|
|
|
|
- name: Update config
|
|
|
|
run: moodle-plugin-ci add-config 'define("TEST_MOD_BIGBLUEBUTTONBN_MOCK_SERVER", "http://localhost:8002/hash" . sha1($CFG->wwwroot));'
|
|
|
|
|
|
|
|
- name: Run Behat tests
|
|
|
|
run: moodle-plugin-ci behat --auto-rerun 3 --profile chrome --tags="@app&&~@local&&$BEHAT_TAGS"
|
|
|
|
env:
|
|
|
|
BEHAT_TAGS: ${{ matrix.tags }}
|
2024-02-08 14:29:52 +00:00
|
|
|
MOODLE_BEHAT_SELENIUM_IMAGE: selenium/standalone-chrome:120.0
|
2024-01-25 16:28:12 +00:00
|
|
|
|
|
|
|
- name: Upload Snapshot failures
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
if: ${{ failure() }}
|
|
|
|
with:
|
|
|
|
name: snapshot_failures-${{ matrix.tags }}
|
|
|
|
path: moodle/local/moodleappbehat/tests/behat/snapshots/failures/*
|
|
|
|
|
|
|
|
- name: Upload Behat failures
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
if: ${{ failure() }}
|
|
|
|
with:
|
|
|
|
name: behat_failures-${{ matrix.tags }}
|
|
|
|
path: moodledata/behat_dump/*
|
|
|
|
|
|
|
|
complete:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [behat]
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
|
|
|
- uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
path: artifacts
|
|
|
|
|
|
|
|
- name: Check failure artifacts
|
|
|
|
run: |
|
|
|
|
rm ./artifacts/build -rf
|
|
|
|
if [ -n "$(ls -A ./artifacts)" ]; then
|
|
|
|
echo "There were some failures in the previous jobs"
|
|
|
|
exit 1
|
|
|
|
fi
|