|
3 | 3 | # tutorial being played is uploaded as an artifact, for passing and failing |
4 | 4 | # runs alike. |
5 | 5 | # |
6 | | -# Runs on every push (a tutorial change should not break the tutorials) and |
7 | | -# every 6 hours (a change in GDevelop master should not either). The schedule |
8 | | -# only runs from the default branch (main). |
| 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). |
9 | 11 | name: Test in-app tutorials |
10 | 12 |
|
11 | 13 | on: |
12 | 14 | push: |
13 | 15 | branches: [main, automatic-tests] |
| 16 | + pull_request: |
14 | 17 | schedule: |
15 | 18 | # Every 6 hours: GDevelop pushes do not trigger this workflow, the |
16 | 19 | # schedule catches editor changes that break tutorials. |
|
31 | 34 | steps: |
32 | 35 | - name: Checkout tutorials |
33 | 36 | uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + # Full history, to diff against the base branch on pull requests. |
| 39 | + fetch-depth: 0 |
34 | 40 |
|
35 | 41 | - name: Checkout GDevelop |
36 | 42 | uses: actions/checkout@v4 |
@@ -65,16 +71,39 @@ jobs: |
65 | 71 | - name: Install Playwright browser |
66 | 72 | run: npx playwright install --with-deps chromium |
67 | 73 |
|
68 | | - # Starts the editor dev server (from ./GDevelop) and plays every |
69 | | - # tutorial. Known broken tutorials are expected to fail. |
70 | | - - name: Play all in-app tutorials |
| 74 | + # On pull requests, only play the tutorials whose json was modified — |
| 75 | + # or all of them if the test harness itself was modified, and none if |
| 76 | + # the changes concern neither. |
| 77 | + - name: Determine which tutorials to play |
| 78 | + id: scope |
| 79 | + if: github.event_name == 'pull_request' |
| 80 | + run: | |
| 81 | + changed=$(git diff --name-only "origin/$GITHUB_BASE_REF"...HEAD) |
| 82 | + echo "Changed files:"; echo "$changed" |
| 83 | + ids=$(echo "$changed" | grep -E '^tutorials/in-app/[^/]+\.json$' | xargs -rn1 basename | sed 's/\.json$//' | paste -sd, -) |
| 84 | + if [ -n "$ids" ]; then |
| 85 | + echo "ids=$ids" >> "$GITHUB_OUTPUT" |
| 86 | + echo "mode=modified-tutorials" >> "$GITHUB_OUTPUT" |
| 87 | + elif echo "$changed" | grep -qE '^(e2e/|scripts/|package(-lock)?\.json|\.github/workflows/)'; then |
| 88 | + echo "mode=all" >> "$GITHUB_OUTPUT" |
| 89 | + else |
| 90 | + echo "mode=none" >> "$GITHUB_OUTPUT" |
| 91 | + fi |
| 92 | +
|
| 93 | + # Starts the editor dev server (from ./GDevelop) and plays the |
| 94 | + # tutorials. Known broken tutorials are expected to fail. |
| 95 | + - name: Play in-app tutorials |
| 96 | + if: steps.scope.outputs.mode != 'none' |
| 97 | + env: |
| 98 | + TUTORIAL_IDS: ${{ steps.scope.outputs.ids }} |
71 | 99 | run: npm run test-in-app-tutorials -- --project=${{ matrix.project }} |
72 | 100 |
|
73 | 101 | # Playwright records webm, which does not play natively on macOS: |
74 | 102 | # convert to mp4 (H.264) so the videos open with QuickTime/Quick Look. |
75 | 103 | - name: Convert videos to mp4 |
76 | 104 | if: always() |
77 | 105 | run: | |
| 106 | + [ -d test-results ] || exit 0 |
78 | 107 | sudo apt-get update -qq && sudo apt-get install -y -qq ffmpeg |
79 | 108 | find test-results -name "*.webm" -print0 | while IFS= read -r -d '' file; do |
80 | 109 | 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" |
|
0 commit comments