Skip to content

Commit

Permalink
Merge pull request #3570 from moodlehq/integration
Browse files Browse the repository at this point in the history
Integration
  • Loading branch information
moodlemobile committed Feb 28, 2023
2 parents a7b5091 + 9a2720a commit 15fafef
Show file tree
Hide file tree
Showing 329 changed files with 6,615 additions and 1,449 deletions.
33 changes: 30 additions & 3 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
env:
MOODLE_DOCKER_DB: pgsql
MOODLE_DOCKER_BROWSER: chrome
MOODLE_DOCKER_PHP_VERSION: 7.4
MOODLE_DOCKER_PHP_VERSION: '8.0'
MOODLE_BRANCH: ${{ github.event.inputs.moodle_branch || 'master' }}
MOODLE_REPOSITORY: ${{ github.event.inputs.moodle_repository || 'https://github.com/moodle/moodle' }}
BEHAT_TAGS: ${{ github.event.inputs.behat_tags || '~@performance' }}
Expand All @@ -42,6 +42,12 @@ jobs:
git clone --branch master --depth 1 https://github.com/moodlehq/moodle-docker $GITHUB_WORKSPACE/moodle-docker
- name: Install npm packages
run: npm ci --no-audit
- name: Create Behat faildumps folder
run: |
mkdir moodle/behatfaildumps
chmod 777 moodle/behatfaildumps
- name: Install Behat Snapshots plugin
run: git clone --branch main --depth 1 https://github.com/NoelDeMartin/moodle-local_behatsnapshots $GITHUB_WORKSPACE/moodle/local/behatsnapshots
- name: Generate Behat tests plugin
run: |
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
Expand All @@ -50,12 +56,21 @@ jobs:
run: |
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
cp $GITHUB_WORKSPACE/moodle-docker/config.docker-template.php $GITHUB_WORKSPACE/moodle/config.php
sed -i "61c\$CFG->behat_faildump_path = '/var/www/html/behatfaildumps';" $GITHUB_WORKSPACE/moodle/config.php
sed -i "61i\$CFG->behat_increasetimeout = 2;" $GITHUB_WORKSPACE/moodle/config.php
sed -i "61i\$CFG->behat_ionic_wwwroot = 'http://moodleapp';" $GITHUB_WORKSPACE/moodle/config.php
sed -i "61i\$CFG->behat_snapshots_path = '/var/www/html/local/moodleappbehat/tests/behat/snapshots';" $GITHUB_WORKSPACE/moodle/config.php
echo "define('TEST_MOD_BIGBLUEBUTTONBN_MOCK_SERVER', 'http://bbbmockserver/hash' . sha1(\$CFG->behat_wwwroot));" >> $GITHUB_WORKSPACE/moodle/config.php
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose pull
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose up -d
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-wait-for-db
- name: Install Imagick PHP extension
run: |
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
./moodle-docker/bin/moodle-docker-compose exec webserver apt-get update
./moodle-docker/bin/moodle-docker-compose exec webserver apt-get install -y libmagickwand-dev --no-install-recommends
./moodle-docker/bin/moodle-docker-compose exec webserver pecl install imagick
./moodle-docker/bin/moodle-docker-compose exec webserver docker-php-ext-enable imagick
- name: Compile & launch app with Docker
run: |
docker build --build-arg build_command="npm run build:test" -t moodlehq/moodleapp:behat .
Expand All @@ -65,8 +80,20 @@ jobs:
- name: Init Behat
run: |
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/init.php --parallel=8 --optimize-runs='@app&&$BEHAT_TAGS'"
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/init.php --parallel=8 --optimize-runs='@app&&~@local&&$BEHAT_TAGS'"
- name: Run Behat tests
run: |
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/run.php --verbose --tags='@app&&$BEHAT_TAGS' --auto-rerun=3"
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/run.php --verbose --tags='@app&&~@local&&$BEHAT_TAGS' --auto-rerun=3"
- name: Upload Snapshot failures
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: snapshot_failures
path: moodle/local/moodleappbehat/tests/behat/snapshots/failures/*
- name: Upload Behat failures
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: behat_failures
path: moodle/behatfaildumps
2 changes: 1 addition & 1 deletion .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
env:
MOODLE_DOCKER_DB: pgsql
MOODLE_DOCKER_BROWSER: chrome
MOODLE_DOCKER_PHP_VERSION: 7.4
MOODLE_DOCKER_PHP_VERSION: '8.0'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ WORKDIR /app
# Prepare node dependencies
RUN apt-get update && apt-get install libsecret-1-0 -y
COPY package*.json ./
COPY patches ./patches
RUN echo "unsafe-perm=true" > ./.npmrc
RUN npm ci --no-audit

# Build source
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ Moodle App
This is the primary repository of source code for the official mobile app for Moodle.

* [User documentation](https://docs.moodle.org/en/Moodle_app)
* [Developer documentation](http://docs.moodle.org/dev/Moodle_App)
* [Development environment setup](https://docs.moodle.org/dev/Setting_up_your_development_environment_for_the_Moodle_App)
* [Developer documentation](https://moodledev.io/general/app)
* [Development environment setup](https://moodledev.io/general/app/development/setup)
* [Bug Tracker](https://tracker.moodle.org/browse/MOBILE)
* [Release Notes](https://docs.moodle.org/dev/Moodle_App_Release_Notes)
* [Release Notes](https://moodledev.io/general/app_releases)

This project is tested with BrowserStack.

License
-------
Expand Down
7 changes: 6 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,19 @@
"input": "src/theme/theme.scss"
}
],
"scripts": []
"scripts": [],
"webWorkerTsConfig": "tsconfig.worker.json"
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/testing/testing.module.ts",
"with": "src/testing/testing.module.prod.ts"
},
{
"replace": "src/core/features/emulator/emulator.module.ts",
"with": "src/core/features/emulator/emulator.module.prod.ts"
}
],
"optimization": {
Expand Down
12 changes: 4 additions & 8 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="41001" id="com.moodle.moodlemobile" ios-CFBundleVersion="4.1.0.1" version="4.1.0" versionCode="41001" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget android-versionCode="41100" id="com.moodle.moodlemobile" ios-CFBundleVersion="4.1.1.0" version="4.1.1" versionCode="41100" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Moodle</name>
<description>Moodle official app</description>
<author email="mobile@moodle.com" href="http://moodle.com">Moodle Mobile team</author>
Expand Down Expand Up @@ -27,7 +27,7 @@
<preference name="UIWebViewBounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="AppendUserAgent" value="MoodleMobile 4.1.0 (41001)" />
<preference name="AppendUserAgent" value="MoodleMobile 4.1.1 (41100)" />
<preference name="BackupWebStorage" value="none" />
<preference name="ScrollEnabled" value="false" />
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
Expand Down Expand Up @@ -196,13 +196,9 @@
<param name="android-package" value="com.adobe.phonegap.push.PushPlugin" />
</feature>
</config-file>
<config-file parent="/*" target="res/xml/config.xml">
<feature name="Media">
<param name="android-package" value="org.apache.cordova.media.AudioHandler" />
</feature>
</config-file>
<config-file parent="/*" target="AndroidManifest.xml">
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
</config-file>
<config-file parent="/*" target="AndroidManifest.xml">
<queries>
Expand Down Expand Up @@ -236,7 +232,7 @@
<true />
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="CFBundleShortVersionString">
<string>4.1.0</string>
<string>4.1.1</string>
</edit-config>
<edit-config file="*-Info.plist" mode="overwrite" target="CFBundleLocalizations">
<array>
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ gulp.task('watch', () => {
});

gulp.task('watch-behat', () => {
gulp.watch(['./src/**/*.feature', './local_moodleappbehat'], { interval: 500 }, gulp.parallel('behat'));
gulp.watch(['./src/**/*.feature', './src/**/*.png', './local_moodleappbehat'], { interval: 500 }, gulp.parallel('behat'));
});
38 changes: 34 additions & 4 deletions local_moodleappbehat/tests/behat/behat_app.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
require_once(__DIR__ . '/behat_app_helper.php');

use Behat\Behat\Hook\Scope\ScenarioScope;
use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Exception\DriverException;
use Behat\Mink\Exception\ExpectationException;
Expand All @@ -45,6 +46,27 @@ class behat_app extends behat_app_helper {

protected $windowsize = '360x720';

/**
* @BeforeScenario
*/
public function before_scenario(ScenarioScope $scope) {
if (!$scope->getFeature()->hasTag('app')) {
return;
}

global $CFG;

$performanceLogs = $CFG->behat_profiles['default']['capabilities']['extra_capabilities']['goog:loggingPrefs']['performance'] ?? null;

if ($performanceLogs !== 'ALL') {
return;
}

// Enable DB Logging only for app tests with performance logs activated.
$this->getSession()->visit($this->get_app_url() . '/assets/env.json');
$this->execute_script("document.cookie = 'MoodleAppDBLoggingEnabled=true;path=/';");
}

/**
* Opens the Moodle App in the browser and optionally logs in.
*
Expand Down Expand Up @@ -215,13 +237,21 @@ public function i_load_more_items_in_the_app(bool $not = false) {
/**
* Trigger swipe gesture.
*
* @When /^I swipe to the (left|right) in the app$/
* @When /^I swipe to the (left|right) (in (".+") )?in the app$/
* @param string $direction Swipe direction
* @param bool $hasLocator Whether a reference locator is used.
* @param string $locator Reference locator.
*/
public function i_swipe_in_the_app(string $direction) {
$method = 'swipe' . ucwords($direction);
public function i_swipe_in_the_app(string $direction, bool $hasLocator = false, string $locator = '') {
if ($hasLocator) {
$locator = $this->parse_element_locator($locator);
}

$result = $this->zone_js("swipe('$direction'" . ($hasLocator ? ", $locator" : '') . ')');

$this->zone_js("getAngularInstance('ion-content', 'CoreSwipeNavigationDirective').$method()");
if ($result !== 'OK') {
throw new DriverException('Error when swiping - ' . $result);
}

$this->wait_for_pending_js();

Expand Down
Empty file.
4 changes: 2 additions & 2 deletions moodle.config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"app_id": "com.moodle.moodlemobile",
"appname": "Moodle Mobile",
"versioncode": 41001,
"versionname": "4.1.0",
"versioncode": 41100,
"versionname": "4.1.1",
"cache_update_frequency_usually": 420000,
"cache_update_frequency_often": 1200000,
"cache_update_frequency_sometimes": 3600000,
Expand Down
Loading

0 comments on commit 15fafef

Please sign in to comment.