Skip to content

Mobile 4974 lint: Safe eqeqeq fixes#4753 #4104

Mobile 4974 lint: Safe eqeqeq fixes#4753

Mobile 4974 lint: Safe eqeqeq fixes#4753 #4104

Workflow file for this run

name: Acceptance tests (Behat)
on:
workflow_dispatch:
inputs:
behat_tags:
description: "Behat tags to execute"
moodle_branch:
description: "Moodle branch"
required: true
default: "main"
moodle_repository:
description: "Moodle repository"
required: true
default: "https://github.com/moodle/moodle.git"
pull_request:
branches: [main, v*.x]
concurrency:
group: acceptance-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.set-tags.outputs.tags }}
node-version: ${{ steps.node-version.outputs.version }}
steps:
- uses: actions/checkout@v6
with:
path: app
- name: Read Node version
id: node-version
run: echo "version=$(cat app/.nvmrc | tr -d '[:space:]')" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v6
with:
node-version-file: "app/.nvmrc"
cache: "npm"
cache-dependency-path: "app/package-lock.json"
- name: Install npm dependencies
working-directory: app
run: npm ci --no-audit
- name: Install languages
working-directory: app
run: |
npx gulp lang
npm run lang:update-langpacks
- name: Build app
working-directory: app
run: npm run build:test
- 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"
- name: Build Behat plugin
working-directory: app
run: ./scripts/build-behat-plugin.js ../plugin
- name: Prepare Behat tags
id: set-tags
working-directory: app
run: |
if [ -z $BEHAT_TAGS ]; then
tags_json=`.github/scripts/print_behat_tags_json.sh`
echo "Generated tags: $tags_json"
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:
key: build-${{ github.sha }}
path: |
app/ssl/**/*
app/www/**/*
app/nginx.conf
plugin/**/*
behat:
runs-on: ubuntu-latest
needs: build
continue-on-error: true
strategy:
matrix:
tags: ${{ fromJSON(needs.build.outputs.tags) }}
services:
postgres:
image: postgres:16
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
steps:
- uses: actions/setup-node@v6
with:
node-version: ${{ needs.build.outputs.node-version }}
- uses: shivammathur/setup-php@v2
with:
php-version: 8.3
ini-values: max_input_vars=5000
coverage: none
- uses: actions/cache/restore@v5
with:
key: build-${{ github.sha }}
path: |
app/ssl/**/*
app/www/**/*
app/nginx.conf
plugin/**/*
- name: Setup environment
uses: nick-fields/retry@v4
with:
max_attempts: 3
retry_wait_seconds: 10
timeout_minutes: 5
command: |
docker pull nginx:alpine &
docker pull moodlehq/bigbluebutton_mock:latest &
sudo locale-gen en_AU.UTF-8 &
rm -rf ci
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4.5
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
wait
- name: Launch Docker images
working-directory: app
run: |
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
docker run -d --rm -p 8002:80 --name bigbluebutton moodlehq/bigbluebutton_mock:latest
- name: Install Behat Snapshots plugin
run: moodle-plugin-ci add-plugin moodlemobile/moodle-local_behatsnapshots
- 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://git.in.moodle.com/moodle/integration.git' }}
MOODLE_BEHAT_IONIC_WWWROOT: https://localhost:8001
MOODLE_BEHAT_DEFAULT_BROWSER: chrome
MOODLE_BEHAT_CHROME_CAPABILITIES: "['extra_capabilities' => ['chromeOptions' => ['args' => ['--ignore-certificate-errors', '--allow-running-insecure-content'], 'prefs' => ['credentials_enable_service' => false, 'profile.password_manager_enabled' => false, 'profile.password_manager_leak_detection' => false]]]]"
- name: Update config
run: moodle-plugin-ci add-config 'define("TEST_MOD_BIGBLUEBUTTONBN_MOCK_SERVER", "http://localhost:8002/hash" . sha1($CFG->wwwroot));'
# During Moodle onsync period, this value should be false to avoid lang tests to fail due to missing langpacks.
- name: Run or skip lang tests
run: moodle-plugin-ci add-config 'define("TOOL_LANGIMPORT_REMOTE_TESTS", true);'
- name: Run Behat tests
id: run-behat-tests
run: moodle-plugin-ci behat --auto-rerun 3 --profile chrome --tags="@app&&~@local&&$BEHAT_TAGS"
env:
BEHAT_TAGS: ${{ matrix.tags }}
MOODLE_BEHAT_SELENIUM_IMAGE: selenium/standalone-chrome:latest
- name: Rename snapshot failure files
id: filename
if: ${{ failure() && steps.run-behat-tests.conclusion == 'failure' }}
run: |
PARALLEL_NAME=$(echo "${{ matrix.tags }}" | sed 's/^@app_parallel_run_//')
echo "PARALLEL_NAME=$PARALLEL_NAME" >> $GITHUB_OUTPUT
echo "❌ $PARALLEL_NAME failed" >> $GITHUB_STEP_SUMMARY
- name: Upload Snapshot failures
uses: actions/upload-artifact@v6
if: ${{ failure() && steps.run-behat-tests.conclusion == 'failure' }}
env:
PARALLEL_NAME: ${{ steps.filename.outputs.PARALLEL_NAME }}
with:
name: snapshot_failures-${{ env.PARALLEL_NAME }}
path: moodle/public/local/moodleappbehat/tests/behat/snapshots/failures/*
if-no-files-found: ignore
- name: Upload Behat failures
uses: actions/upload-artifact@v6
if: ${{ failure() && steps.run-behat-tests.conclusion == 'failure' }}
env:
PARALLEL_NAME: ${{ steps.filename.outputs.PARALLEL_NAME }}
with:
name: behat_failures-${{ env.PARALLEL_NAME }}
path: moodledata/behat_dump/*
if-no-files-found: ignore
- name: Mark cancelled jobs as failed.
if: ${{ cancelled() }}
run: exit 1
complete:
runs-on: ubuntu-latest
needs: behat
steps:
- uses: technote-space/workflow-conclusion-action@v3
- name: Check job status and fail if they are red
if: env.WORKFLOW_CONCLUSION == 'failure'
run: |
echo "There were some failures in the previous jobs"
echo "### ❌ There were some failures in the previous jobs" >> $GITHUB_STEP_SUMMARY
exit 1