diff --git a/.github/workflows/structure.yml b/.github/workflows/structure.yml new file mode 100644 index 00000000000..1afa5274e61 --- /dev/null +++ b/.github/workflows/structure.yml @@ -0,0 +1,66 @@ +name: Update Moodle WS Structure + +on: + workflow_dispatch: + inputs: + moodle_branch: + description: 'Moodle branch' + required: true + default: 'master' + schedule: + - cron: '0 4 * * *' + push: + +jobs: + structure: + runs-on: ubuntu-latest + services: + exttests: + image: moodlehq/moodle-exttests + ports: + - 8080:80 + redis: + image: redis + ports: + - 6379:6379 + + strategy: + matrix: + moodle_branch: ['master'] # , 'MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE' + env: + dbtype: pgsql + php: 8.2 + MOODLE_BRANCH: ${{ github.event.inputs.moodle_branch || 'master' }} + MOODLE_REPOSITORY: 'https://github.com/moodle/moodle' + steps: + - name: Checking out code from ${{ env.GITHUB_REF_SLUG }} + uses: actions/checkout@v3 + + - name: Checking out Moodle ${{ env.MOODLE_BRANCH }} + run: | + git clone --branch $MOODLE_BRANCH --depth 1 $MOODLE_REPOSITORY $GITHUB_WORKSPACE/moodle + + - name: Setting up DB ${{ env.dbtype }} + uses: m4nu56/postgresql-action@v1 + with: + postgresql version: 13 + postgresql db: test + postgresql user: test + postgresql password: test + - name: Setting up PHP ${{ env.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.php }} + ini-values: max_input_vars=5000 + coverage: none + + - name: Setting up Moodle + env: + dbtype: ${{ env.dbtype }} + run: | + cd $GITHUB_WORKSPACE/moodle + echo "pathtophp=$(which php)" >> $GITHUB_ENV # Inject installed pathtophp to env. The template config needs it. + cp .github/workflows/config-template.php config.php + mkdir ../moodledata + # sudo locale-gen en_AU.UTF-8 + php admin/cli/install_database.php --agree-license --adminpass=1234 --adminemail=admin@moodle.invalid --fullname=Structure --shortname=structure --summary=Structure --supportemail=admin@moodle.invalid diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml deleted file mode 100644 index a8962277607..00000000000 --- a/.github/workflows/testing.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Testing - -on: [push, pull_request] - -jobs: - test: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - - name: Install npm packages - run: | - npm ci --no-audit - npm ci --no-audit --prefix cordova-plugin-moodleapp - - name: Check langindex - run: | - result=$(cat scripts/langindex.json | grep \"TBD\" | wc -l); test $result -eq 0 - if [ $result -ne 0 ]; then - echo "There are lang strings to be decided on langindex.json" - exit 1 - fi - gulp - langcount=`jq -r '. | length' src/assets/lang/en.json` - langindexcount=`jq -r '. | length' scripts/langindex.json` - if [ $langcount -ne $langindexcount ]; then - echo "Lang file has $langcount while langindex $langindexcount" - exit 1 - fi - - langkeys=`jq -r 'keys[]' src/assets/lang/en.json` - langindex=`jq -r 'keys[]' scripts/langindex.json` - found=0 - for i in $langkeys; do - skip= - for j in $langindex; do - if [ "$i" == "$j" ]; then - skip=1 - break; - fi - done - [[ -n $skip ]] || { echo "$i key not found"; found=$(($found + 1)); } - done - if [ $found -ne 0 ]; then - echo "Found $found missing langkeys" - exit 1 - fi - - name: Run Linters (ignore warnings) - run: | - npm run lint -- --quiet - npm run lint --prefix cordova-plugin-moodleapp - - name: Run tests - run: npm run test:ci - - name: Production builds - run: | - npm run build:prod - npm run prod --prefix cordova-plugin-moodleapp - - name: JavaScript code compatibility - run: result=$(npx check-es-compat www/*.js 2> /dev/null | grep -v -E "Array\.prototype\.includes|Promise\.prototype\.finally|String\.prototype\.(matchAll|trimRight)|globalThis" | grep -Po "(?<=error).*?(?=\s+ecmascript)" | wc -l); test $result -eq 1