Skip to content

Commit 889d71d

Browse files
authored
chore: improve screenshot workflows (#1427)
1 parent 2e6880b commit 889d71d

File tree

5 files changed

+147
-56
lines changed

5 files changed

+147
-56
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: "iPad Screenshots Workflow"
2+
3+
inputs:
4+
IPAD_DEVICE_MODEL:
5+
description: 'Model of the iPad device to be used when running tests'
6+
required: false
7+
default: iPad Pro 13-inch (M4)
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- name: Set up Flutter
13+
uses: subosito/flutter-action@v2
14+
with:
15+
cache: true
16+
flutter-version-file: pubspec.yaml
17+
18+
- name: Update Podfile
19+
shell: bash
20+
run: |
21+
cd ./iOS
22+
flutter pub get
23+
pod install --repo-update
24+
25+
- name: Create iPad Simulator
26+
id: ipad_sim
27+
uses: futureware-tech/simulator-action@v4
28+
with:
29+
model: ${{ inputs.IPAD_DEVICE_MODEL }}
30+
wait_for_boot: true
31+
32+
- name: Capture iPad Screenshots
33+
shell: bash
34+
run: |
35+
DEVICE_NAME="${{ inputs.IPAD_DEVICE_MODEL }}" flutter drive --driver=test_integration/test_driver.dart --target=test_integration/screenshots.dart -d "${{ steps.ipad_sim.outputs.udid }}"
36+
37+
- name: Update Fastlane Metadata
38+
if: ${{ github.event_name == 'push' }}
39+
shell: bash
40+
run: |
41+
git config --global user.name "github-actions[bot]"
42+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
43+
44+
cd ./iOS
45+
git clone --branch=fastlane-ios --depth=1 https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} fastlane
46+
cd fastlane
47+
48+
rm -rf screenshots/iPad*
49+
cp -r ../../screenshots/. screenshots/
50+
51+
# Force push to fastlane branch
52+
git checkout --orphan temporary
53+
git add --all .
54+
git commit -am "[Auto] Update screenshots ($(date +%Y-%m-%d.%H:%M:%S))"
55+
git branch -D fastlane-ios
56+
git branch -m fastlane-ios
57+
git push --force origin fastlane-ios
58+
59+
- name: Upload Screenshots
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: iPad Screenshots
63+
path: screenshots/*

.github/actions/screenshot-ios/action.yml renamed to .github/actions/screenshot-iphone/action.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
name: "iOS Screenshots Workflow"
1+
name: "iPhone Screenshots Workflow"
22

33
inputs:
44
IPHONE_DEVICE_MODEL:
55
description: 'Model of the iPhone device to be used when running tests'
66
required: false
77
default: iPhone 16 Pro Max
8-
IPAD_DEVICE_MODEL:
9-
description: 'Model of the iPad device to be used when running tests'
10-
required: false
11-
default: iPad Pro 13-inch (M4)
128

139
runs:
1410
using: "composite"
@@ -27,26 +23,16 @@ runs:
2723
pod install --repo-update
2824
2925
- name: Create iPhone Simulator
26+
id: iphone_sim
3027
uses: futureware-tech/simulator-action@v4
3128
with:
3229
model: ${{ inputs.IPHONE_DEVICE_MODEL }}
3330
wait_for_boot: true
3431

35-
- name: Create iPad Simulator
36-
uses: futureware-tech/simulator-action@v4
37-
with:
38-
model: ${{ inputs.IPAD_DEVICE_MODEL }}
39-
wait_for_boot: true
40-
4132
- name: Capture iPhone Screenshots
4233
shell: bash
4334
run: |
44-
DEVICE_NAME="${{ inputs.IPHONE_DEVICE_MODEL }}" flutter drive --driver=test_integration/test_driver.dart --target=test_integration/screenshots.dart -d "${{ inputs.IPHONE_DEVICE_MODEL }}"
45-
46-
- name: Capture iPad Screenshots
47-
shell: bash
48-
run: |
49-
DEVICE_NAME="${{ inputs.IPAD_DEVICE_MODEL }}" flutter drive --driver=test_integration/test_driver.dart --target=test_integration/screenshots.dart -d "${{ inputs.IPAD_DEVICE_MODEL }}"
35+
DEVICE_NAME="${{ inputs.IPHONE_DEVICE_MODEL }}" flutter drive --driver=test_integration/test_driver.dart --target=test_integration/screenshots.dart -d "${{ steps.iphone_sim.outputs.udid }}"
5036
5137
- name: Update Fastlane Metadata
5238
if: ${{ github.event_name == 'push' }}
@@ -59,7 +45,7 @@ runs:
5945
git clone --branch=fastlane-ios --depth=1 https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} fastlane
6046
cd fastlane
6147
62-
rm -rf screenshots/*
48+
rm -rf screenshots/iPhone*
6349
cp -r ../../screenshots/. screenshots/
6450
6551
# Force push to fastlane branch
@@ -73,5 +59,5 @@ runs:
7359
- name: Upload Screenshots
7460
uses: actions/upload-artifact@v4
7561
with:
76-
name: iOS Screenshots
62+
name: iPhone Screenshots
7763
path: screenshots/*

.github/workflows/pull_request.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
pull_request:
55
branches: [ "development" ]
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
711
env:
812
ANDROID_EMULATOR_API: 34
913
ANDROID_EMULATOR_ARCH: x86_64
@@ -58,6 +62,7 @@ jobs:
5862
screenshots-android:
5963
name: Screenshots (Android)
6064
runs-on: ubuntu-latest
65+
timeout-minutes: 30
6166
steps:
6267
- uses: actions/checkout@v4
6368

@@ -67,9 +72,10 @@ jobs:
6772
ANDROID_EMULATOR_API: ${{ env.ANDROID_EMULATOR_API }}
6873
ANDROID_EMULATOR_ARCH: ${{ env.ANDROID_EMULATOR_ARCH }}
6974

70-
screenshots-ios:
71-
name: Screenshots (iOS)
75+
screenshots-iphone:
76+
name: Screenshots (iPhone)
7277
runs-on: macos-latest
78+
timeout-minutes: 30
7379
steps:
7480
- name: Set up Xcode
7581
uses: maxim-lobanov/setup-xcode@v1.6.0
@@ -78,9 +84,25 @@ jobs:
7884

7985
- uses: actions/checkout@v4
8086

81-
- name: iOS Screenshot Workflow
82-
uses: ./.github/actions/screenshot-ios
87+
- name: iPhone Screenshot Workflow
88+
uses: ./.github/actions/screenshot-iphone
8389
with:
8490
IPHONE_DEVICE_MODEL: ${{ env.IPHONE_DEVICE_MODEL }}
91+
92+
screenshots-ipad:
93+
name: Screenshots (iPad)
94+
runs-on: macos-latest
95+
timeout-minutes: 30
96+
steps:
97+
- name: Set up Xcode
98+
uses: maxim-lobanov/setup-xcode@v1.6.0
99+
with:
100+
xcode-version: latest-stable
101+
102+
- uses: actions/checkout@v4
103+
104+
- name: iPad Screenshot Workflow
105+
uses: ./.github/actions/screenshot-ipad
106+
with:
85107
IPAD_DEVICE_MODEL: ${{ env.IPAD_DEVICE_MODEL }}
86108

.github/workflows/pull_request_comment.yml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,38 @@ jobs:
4747
4848
fs.writeFileSync('${{github.workspace}}/androidScreenshots.zip', Buffer.from(downloadAndroidScreenshots.data));
4949
50-
var iosScreenshots = artifacts.data.artifacts.filter((artifact) => {
51-
return artifact.name == "iOS Screenshots"
50+
var iPadScreenshots = artifacts.data.artifacts.filter((artifact) => {
51+
return artifact.name == "iPad Screenshots"
5252
})[0];
53-
var downloadIosScreenshots = await github.rest.actions.downloadArtifact({
53+
var downloadiPadScreenshots = await github.rest.actions.downloadArtifact({
5454
owner: context.repo.owner,
5555
repo: context.repo.repo,
56-
artifact_id: iosScreenshots.id,
56+
artifact_id: iPadScreenshots.id,
5757
archive_format: 'zip',
5858
});
5959
60-
fs.writeFileSync('${{github.workspace}}/iosScreenshots.zip', Buffer.from(downloadIosScreenshots.data));
60+
fs.writeFileSync('${{github.workspace}}/iPadScreenshots.zip', Buffer.from(downloadiPadScreenshots.data));
61+
62+
var iPhoneScreenshots = artifacts.data.artifacts.filter((artifact) => {
63+
return artifact.name == "iPhone Screenshots"
64+
})[0];
65+
var downloadiPhoneScreenshots = await github.rest.actions.downloadArtifact({
66+
owner: context.repo.owner,
67+
repo: context.repo.repo,
68+
artifact_id: iPhoneScreenshots.id,
69+
archive_format: 'zip',
70+
});
71+
72+
fs.writeFileSync('${{github.workspace}}/iPhoneScreenshots.zip', Buffer.from(downloadiPhoneScreenshots.data));
6173
6274
- name: Unzip Artifacts
6375
shell: bash
6476
run: |
6577
unzip pr.zip
6678
mkdir screenshots
6779
unzip androidScreenshots.zip -d screenshots/
68-
unzip iosScreenshots.zip -d screenshots/
80+
unzip iPadScreenshots.zip -d screenshots/
81+
unzip iPhoneScreenshots.zip -d screenshots/
6982
7083
- name: Fetch PR Number
7184
id: fetch-pr-number
@@ -135,6 +148,8 @@ jobs:
135148
var statusText = `Build successful. APKs to test: ${artifact_url}.`;
136149
137150
var androidScreenshots = `
151+
<details>
152+
<summary>Android Screenshots</summary>
138153
<table>
139154
<tr>
140155
<td><img src="https://github.com/fossasia/badgemagic-app/blob/pr-screenshots/${issue_number}_Pixel_6-1_home_screen.png?raw=true" width="1080"/></td>
@@ -150,9 +165,12 @@ jobs:
150165
</td>
151166
</tr>
152167
</table>
168+
</details>
153169
`;
154170
155171
var iPhoneScreenshots = `
172+
<details>
173+
<summary>iPhone Screenshots</summary>
156174
<table>
157175
<tr>
158176
<td><img src="https://github.com/fossasia/badgemagic-app/blob/pr-screenshots/${issue_number}_iPhone_16_Pro_Max-1_home_screen.png?raw=true" width="1080"/></td>
@@ -168,9 +186,12 @@ jobs:
168186
</td>
169187
</tr>
170188
</table>
189+
</details>
171190
`;
172191
173192
var iPadScreenshots = `
193+
<details>
194+
<summary>iPad Screenshots</summary>
174195
<table>
175196
<tr>
176197
<td><img src="https://github.com/fossasia/badgemagic-app/blob/pr-screenshots/${issue_number}_iPad_Pro_13-inch_(M4)-1_home_screen.png?raw=true" width="1080"/></td>
@@ -186,19 +207,16 @@ jobs:
186207
</td>
187208
</tr>
188209
</table>
210+
</details>
189211
`;
190212
191213
const body = `
192214
## Build Status
193215
${statusText}
194216
195-
## Screenshots (Android)
217+
## Screenshots
196218
${androidScreenshots}
197-
198-
## Screenshots (iPhone)
199219
${iPhoneScreenshots}
200-
201-
## Screenshots (iPad)
202220
${iPadScreenshots}
203221
`;
204222
@@ -245,13 +263,7 @@ jobs:
245263
## Build Status
246264
_Build workflow failed. Please check the logs for more information._
247265
248-
## Screenshots (Android)
249-
_Not able to fetch screenshots._
250-
251-
## Screenshots (iPhone)
252-
_Not able to fetch screenshots._
253-
254-
## Screenshots (iPad)
266+
## Screenshots
255267
_Not able to fetch screenshots._
256268
`;
257269

.github/workflows/push.yml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@ env:
1010
ANDROID_EMULATOR_ARCH: x86_64
1111
IPHONE_DEVICE_MODEL: iPhone 16 Pro Max
1212
IPAD_DEVICE_MODEL: iPad Pro 13-inch (M4)
13-
BARECHECK_GITHUB_APP_TOKEN: ${{ secrets.BARECHECK_GITHUB_APP_TOKEN }}
14-
ENCRYPTED_F10B5E0E5262_IV: ${{ secrets.ENCRYPTED_F10B5E0E5262_IV }}
15-
ENCRYPTED_F10B5E0E5262_KEY: ${{ secrets.ENCRYPTED_F10B5E0E5262_KEY }}
16-
ENCRYPTED_IOS_IV: ${{ secrets.ENCRYPTED_IOS_IV }}
17-
ENCRYPTED_IOS_KEY: ${{ secrets.ENCRYPTED_IOS_KEY }}
18-
STORE_PASS: ${{ secrets.STORE_PASS }}
19-
ALIAS: ${{ secrets.ALIAS }}
20-
KEY_PASS: ${{ secrets.KEY_PASS }}
21-
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
22-
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
2313

2414
jobs:
2515
common:
@@ -236,6 +226,7 @@ jobs:
236226
screenshots-android:
237227
name: Screenshots (Android)
238228
runs-on: ubuntu-latest
229+
timeout-minutes: 30
239230
steps:
240231
- uses: actions/checkout@v4
241232

@@ -245,19 +236,36 @@ jobs:
245236
ANDROID_EMULATOR_API: ${{ env.ANDROID_EMULATOR_API }}
246237
ANDROID_EMULATOR_ARCH: ${{ env.ANDROID_EMULATOR_ARCH }}
247238

248-
screenshots-ios:
249-
name: Screenshots (iOS)
239+
screenshots-iphone:
240+
name: Screenshots (iPhone)
250241
runs-on: macos-latest
242+
timeout-minutes: 30
251243
steps:
244+
- name: Set up Xcode
245+
uses: maxim-lobanov/setup-xcode@v1.6.0
246+
with:
247+
xcode-version: latest-stable
248+
252249
- uses: actions/checkout@v4
253250

251+
- name: iPhone Screenshot Workflow
252+
uses: ./.github/actions/screenshot-iphone
253+
with:
254+
IPHONE_DEVICE_MODEL: ${{ env.IPHONE_DEVICE_MODEL }}
255+
256+
screenshots-ipad:
257+
name: Screenshots (iPad)
258+
runs-on: macos-latest
259+
timeout-minutes: 30
260+
steps:
254261
- name: Set up Xcode
255262
uses: maxim-lobanov/setup-xcode@v1.6.0
256263
with:
257264
xcode-version: latest-stable
258265

259-
- name: iOS Screenshot Workflow
260-
uses: ./.github/actions/screenshot-ios
266+
- uses: actions/checkout@v4
267+
268+
- name: iPad Screenshot Workflow
269+
uses: ./.github/actions/screenshot-ipad
261270
with:
262-
IPHONE_DEVICE_MODEL: ${{ env.IPHONE_DEVICE_MODEL }}
263271
IPAD_DEVICE_MODEL: ${{ env.IPAD_DEVICE_MODEL }}

0 commit comments

Comments
 (0)