|
| 1 | +# Plays every in-app tutorial against the GDevelop editor (web build, master |
| 2 | +# branch) and fails if a tutorial step cannot be completed. A video of each |
| 3 | +# tutorial being played is uploaded as an artifact, for passing and failing |
| 4 | +# runs alike. |
| 5 | +# |
| 6 | +# Runs on every push to main (a tutorial change should not break the |
| 7 | +# tutorials) and every 6 hours (a change in GDevelop master should not |
| 8 | +# either). The schedule only runs from the default branch (main). |
| 9 | +# On pull requests, only the modified tutorials are played (all of them if the |
| 10 | +# test harness itself was modified). |
| 11 | +name: Test in-app tutorials |
| 12 | + |
| 13 | +on: |
| 14 | + push: |
| 15 | + branches: [main] |
| 16 | + pull_request: |
| 17 | + schedule: |
| 18 | + # Every 6 hours: GDevelop pushes do not trigger this workflow, the |
| 19 | + # schedule catches editor changes that break tutorials. |
| 20 | + - cron: '17 */6 * * *' |
| 21 | + workflow_dispatch: |
| 22 | + |
| 23 | +# A new push cancels the still-running workflow of the same pull request or |
| 24 | +# branch (scheduled runs are grouped separately and never cancel them). |
| 25 | +concurrency: |
| 26 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }} |
| 27 | + cancel-in-progress: true |
| 28 | + |
| 29 | +jobs: |
| 30 | + test-in-app-tutorials: |
| 31 | + # One job per editor layout (see the projects in e2e/playwright.config.js): |
| 32 | + # they run in parallel and each uploads its own videos. |
| 33 | + strategy: |
| 34 | + fail-fast: false |
| 35 | + matrix: |
| 36 | + project: [desktop, tablet, mobile] |
| 37 | + name: test-in-app-tutorials (${{ matrix.project }}) |
| 38 | + runs-on: ubuntu-latest |
| 39 | + timeout-minutes: 90 |
| 40 | + steps: |
| 41 | + - name: Checkout tutorials |
| 42 | + uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + # Full history, to diff against the base branch on pull requests. |
| 45 | + fetch-depth: 0 |
| 46 | + |
| 47 | + - name: Checkout GDevelop |
| 48 | + uses: actions/checkout@v4 |
| 49 | + with: |
| 50 | + repository: 4ian/GDevelop |
| 51 | + ref: master |
| 52 | + path: GDevelop |
| 53 | + |
| 54 | + - uses: actions/setup-node@v4 |
| 55 | + with: |
| 56 | + node-version: 22 |
| 57 | + cache: npm |
| 58 | + cache-dependency-path: | |
| 59 | + package-lock.json |
| 60 | + GDevelop/newIDE/app/package-lock.json |
| 61 | +
|
| 62 | + - name: Install dependencies |
| 63 | + run: npm ci |
| 64 | + |
| 65 | + - name: Install GDevelop editor dependencies |
| 66 | + run: npm ci |
| 67 | + working-directory: GDevelop/newIDE/app |
| 68 | + |
| 69 | + # Fast static check: every selector used by the tutorials must still |
| 70 | + # exist in the editor sources. Known broken tutorials are skipped — |
| 71 | + # remove them from --ignore (and from KNOWN_BROKEN_TUTORIAL_IDS in |
| 72 | + # e2e/in-app-tutorials.spec.js) once fixed. |
| 73 | + - name: Check tutorial selectors against the editor sources |
| 74 | + if: matrix.project == 'desktop' |
| 75 | + run: npm run check-in-app-tutorial-selectors -- --gdevelop-root-path ./GDevelop --ignore flingGame |
| 76 | + |
| 77 | + - name: Install Playwright browser |
| 78 | + run: npx playwright install --with-deps chromium |
| 79 | + |
| 80 | + # On pull requests, only play the tutorials whose json was modified — |
| 81 | + # or all of them if the test harness itself was modified, and none if |
| 82 | + # the changes concern neither. |
| 83 | + - name: Determine which tutorials to play |
| 84 | + id: scope |
| 85 | + if: github.event_name == 'pull_request' |
| 86 | + run: | |
| 87 | + changed=$(git diff --name-only "origin/$GITHUB_BASE_REF"...HEAD) |
| 88 | + echo "Changed files:"; echo "$changed" |
| 89 | + ids=$(echo "$changed" | grep -E '^tutorials/in-app/[^/]+\.json$' | xargs -rn1 basename | sed 's/\.json$//' | paste -sd, -) |
| 90 | + if echo "$changed" | grep -qE '^(e2e/|scripts/|package(-lock)?\.json|\.github/workflows/)'; then |
| 91 | + # The harness itself changed: play everything. |
| 92 | + echo "mode=all" >> "$GITHUB_OUTPUT" |
| 93 | + elif [ -n "$ids" ]; then |
| 94 | + echo "ids=$ids" >> "$GITHUB_OUTPUT" |
| 95 | + echo "mode=modified-tutorials" >> "$GITHUB_OUTPUT" |
| 96 | + else |
| 97 | + echo "mode=none" >> "$GITHUB_OUTPUT" |
| 98 | + fi |
| 99 | +
|
| 100 | + # Starts the editor dev server (from ./GDevelop) and plays the |
| 101 | + # tutorials. Known broken tutorials are expected to fail. |
| 102 | + - name: Play in-app tutorials |
| 103 | + if: steps.scope.outputs.mode != 'none' |
| 104 | + env: |
| 105 | + TUTORIAL_IDS: ${{ steps.scope.outputs.ids }} |
| 106 | + run: npm run test-in-app-tutorials -- --project=${{ matrix.project }} |
| 107 | + |
| 108 | + # Playwright records webm, which does not play natively on macOS: |
| 109 | + # convert to mp4 (H.264) so the videos open with QuickTime/Quick Look. |
| 110 | + - name: Convert videos to mp4 |
| 111 | + if: always() |
| 112 | + run: | |
| 113 | + [ -d test-results ] || exit 0 |
| 114 | + sudo apt-get update -qq && sudo apt-get install -y -qq ffmpeg |
| 115 | + find test-results -name "*.webm" -print0 | while IFS= read -r -d '' file; do |
| 116 | + ffmpeg -nostdin -y -loglevel error -i "$file" -c:v libx264 -preset veryfast -crf 28 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -movflags +faststart "${file%.webm}.mp4" && rm "$file" |
| 117 | + done |
| 118 | +
|
| 119 | + - name: Upload videos and screenshots |
| 120 | + if: always() |
| 121 | + uses: actions/upload-artifact@v4 |
| 122 | + with: |
| 123 | + name: tutorial-videos-${{ matrix.project }} |
| 124 | + path: | |
| 125 | + test-results/**/*.mp4 |
| 126 | + test-results/**/*.png |
| 127 | + test-results/**/error-context.md |
| 128 | + # Hourly runs would accumulate a lot of videos: keep them shorter. |
| 129 | + retention-days: ${{ github.event_name == 'schedule' && 3 || 14 }} |
| 130 | + if-no-files-found: warn |
| 131 | + |
| 132 | + # Traces are heavy (~50MB per failed test, with a DOM snapshot of every |
| 133 | + # action): uploaded separately so downloading the videos stays fast. |
| 134 | + # Inspect with: npx playwright show-trace trace.zip |
| 135 | + - name: Upload traces (failures only) |
| 136 | + if: always() |
| 137 | + uses: actions/upload-artifact@v4 |
| 138 | + with: |
| 139 | + name: test-traces-${{ matrix.project }} |
| 140 | + path: test-results/**/trace.zip |
| 141 | + retention-days: ${{ github.event_name == 'schedule' && 3 || 14 }} |
| 142 | + if-no-files-found: ignore |
0 commit comments