name: Testing on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 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 # 6 BigInt usage errors are expected, they are fine without polyfill because they are only used if available. # See https://github.com/videojs/mpd-parser/blob/v0.22.1/src/segment/urlType.js run: | result=$(npx check-es-compat www/*.js --polyfills="{Array,String,TypedArray}.prototype.at,Array.prototype.flatMap,Array.prototype.flat,Array.prototype.includes,globalThis,Object.fromEntries,Object.hasOwn,Promise.prototype.finally,String.prototype.matchAll,String.prototype.trimRight" | grep "6 problems (6 errors, 0 warnings)" | wc -l); test $result -eq 1 npx check-es-compat cordova-plugin-moodleapp/www/*.js