Skip to content

Commit 63e1369

Browse files
Improve CI experience (#370)
1 parent 2e67149 commit 63e1369

File tree

18 files changed

+265
-145
lines changed

18 files changed

+265
-145
lines changed

.github/actions/bootstrap/action.yml

+13-7
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,25 @@ runs:
77
shell: bash
88
- run: echo "$HOME/.mint/bin" >> $GITHUB_PATH
99
shell: bash
10-
- name: Cache RubyGems
11-
uses: actions/cache@v3
12-
id: rubygem-cache
13-
with:
14-
path: vendor/bundle
15-
key: ${{ env.IMAGE }}-gem-${{ hashFiles('**/Gemfile.lock') }}
16-
restore-keys: ${{ env.IMAGE }}-gem-
1710
- name: Cache Mint
1811
uses: actions/cache@v3
1912
id: mint-cache
2013
with:
2114
path: ~/.mint
2215
key: ${{ env.IMAGE }}-mint-${{ hashFiles('**/Mintfile') }}
2316
restore-keys: ${{ env.IMAGE }}-mint-
17+
- name: Cache brew
18+
uses: actions/cache@v3
19+
id: brew-cache
20+
with:
21+
path: |
22+
~/Library/Caches/Homebrew/mint*
23+
~/Library/Caches/Homebrew/vale*
24+
~/Library/Caches/Homebrew/xcparse*
25+
~/Library/Caches/Homebrew/sonar-scanner*
26+
key: ${{ env.IMAGE }}-brew-${{ hashFiles('**/Brewfile.lock.json') }}
27+
restore-keys: ${{ env.IMAGE }}-brew-
28+
- uses: ./.github/actions/ruby-cache
29+
- uses: ./.github/actions/xcode-cache
2430
- run: ./Scripts/bootstrap.sh
2531
shell: bash
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: 'Python Cache'
2+
description: 'Cache Python dependencies'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- uses: actions/setup-python@v4
7+
with:
8+
python-version: 3.11
9+
cache: 'pip'
10+
- run: pip install -r requirements.txt
11+
shell: bash

.github/actions/ruby-cache/action.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: 'Ruby Cache'
2+
description: 'Cache Ruby dependencies'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- uses: ruby/setup-ruby@v1
7+
with:
8+
ruby-version: 3.1
9+
bundler-cache: true
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Xcode Cache'
2+
description: 'Cache Xcode dependencies'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- run: echo "IMAGE=${ImageOS}-${ImageVersion}" >> $GITHUB_ENV
7+
shell: bash
8+
- run: echo "$HOME/.mint/bin" >> $GITHUB_PATH
9+
shell: bash
10+
- name: Cache SPM
11+
uses: actions/cache@v3
12+
id: spm-cache
13+
with:
14+
path: spm_cache
15+
key: ${{ env.IMAGE }}-spm-${{ hashFiles('**/Package.resolved') }}
16+
restore-keys: ${{ env.IMAGE }}-spm-
17+
- uses: mikehardy/buildcache-action@v2
18+
with:
19+
cache_key: ${{ env.IMAGE }}-buildcache-

.github/workflows/cron-checks.yml

+39-6
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,28 @@ env:
2020
HOMEBREW_NO_INSTALL_CLEANUP: 1 # Disable cleanup for homebrew, we don't need it on CI
2121

2222
jobs:
23-
build-and-test-e2e-debug:
23+
build-test-app-and-frameworks:
24+
name: Build Test App and Frameworks
25+
runs-on: macos-13
26+
steps:
27+
- uses: actions/[email protected]
28+
- uses: ./.github/actions/ruby-cache
29+
- uses: ./.github/actions/xcode-cache
30+
- name: Build
31+
run: bundle exec fastlane build_test_app_and_frameworks
32+
timeout-minutes: 60
33+
- uses: actions/upload-artifact@v3
34+
if: success()
35+
with:
36+
name: cache-derived-data
37+
path: |
38+
derived_data/Build/**/*.app
39+
derived_data/Build/**/*.xctestrun
40+
derived_data/Build/**/*.framework
41+
42+
test-e2e-debug:
2443
name: Test E2E UI (Debug)
44+
needs: build-test-app-and-frameworks
2545
strategy:
2646
matrix:
2747
include:
@@ -45,17 +65,27 @@ jobs:
4565
XCODE_VERSION: ${{ matrix.xcode }}
4666
steps:
4767
- uses: actions/[email protected]
68+
- uses: actions/download-artifact@v3
69+
with:
70+
name: cache-derived-data
71+
path: derived_data/Build/
4872
- uses: ./.github/actions/bootstrap
4973
env:
5074
INSTALL_ALLURE: true
51-
INSTALL_XCPARSE: true
75+
- name: Cache iOS Simulator Runtime
76+
uses: actions/cache@v3
77+
id: runtime-cache
78+
with:
79+
path: ~/Library/Caches/XcodeInstall/
80+
key: runtime-ios-${{ matrix.ios }}
81+
restore-keys: runtime-ios-${{ matrix.ios }}
5282
- name: Setup iOS ${{ matrix.ios }} Runtime
5383
if: ${{ matrix.setup_runtime }}
54-
run: xcversion simulators --install='iOS ${{ matrix.ios }}'
84+
run: bundle exec fastlane install_sim ios:"${{ matrix.ios }}"
5585
- name: Launch Allure TestOps
5686
run: bundle exec fastlane allure_launch cron:true
5787
- name: Run UI Tests (Debug)
58-
run: bundle exec fastlane test_e2e_mock cron:true device:"${{ matrix.device }} (${{ matrix.ios }})"
88+
run: bundle exec fastlane test_e2e_mock device:"${{ matrix.device }} (${{ matrix.ios }})" cron:true test_without_building:true
5989
timeout-minutes: 90
6090
- name: Allure TestOps Upload
6191
if: success() || failure()
@@ -75,7 +105,9 @@ jobs:
75105
if: failure() && github.event_name == 'schedule'
76106
- name: Parse xcresult
77107
if: failure()
78-
run: xcparse logs fastlane/test_output/StreamChatSwiftUITestsApp.xcresult fastlane/test_output/logs/
108+
run: |
109+
brew install chargepoint/xcparse/xcparse
110+
xcparse logs fastlane/test_output/StreamChatUITestsApp.xcresult fastlane/test_output/logs/
79111
- uses: actions/upload-artifact@v3
80112
if: failure()
81113
with:
@@ -100,7 +132,8 @@ jobs:
100132
runs-on: ${{ matrix.os }}
101133
steps:
102134
- uses: actions/[email protected]
103-
- uses: ./.github/actions/bootstrap
135+
- uses: ./.github/actions/ruby-cache
136+
- uses: ./.github/actions/xcode-cache
104137
- name: Build Demo App
105138
run: bundle exec fastlane build_demo
106139
env:

.github/workflows/smoke-checks.yml

+50-21
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,40 @@ jobs:
3636
- name: Run Podspec Linting
3737
run: bundle exec fastlane pod_lint
3838

39-
build-and-test-ui-debug:
39+
build-test-app-and-frameworks:
40+
name: Build Test App and Frameworks
41+
runs-on: macos-13
42+
if: ${{ github.event_name != 'push' }}
43+
steps:
44+
- uses: actions/[email protected]
45+
- uses: ./.github/actions/ruby-cache
46+
- uses: ./.github/actions/xcode-cache
47+
- name: Build
48+
run: bundle exec fastlane build_test_app_and_frameworks
49+
timeout-minutes: 60
50+
- uses: actions/upload-artifact@v3
51+
if: success()
52+
with:
53+
name: cache-derived-data
54+
path: |
55+
derived_data/Build/**/*.app
56+
derived_data/Build/**/*.xctestrun
57+
derived_data/Build/**/*.framework
58+
59+
test-ui-debug:
4060
name: Test SwiftUI (Debug)
4161
runs-on: macos-13
62+
needs: build-test-app-and-frameworks
4263
steps:
4364
- uses: actions/[email protected]
44-
- uses: actions/setup-python@v4
65+
- uses: actions/download-artifact@v3
4566
with:
46-
python-version: 3.11
47-
cache: 'pip'
67+
name: cache-derived-data
68+
path: derived_data/Build/
4869
- uses: ./.github/actions/bootstrap
49-
env:
50-
INSTALL_SONAR: true
51-
INSTALL_XCPARSE: true
70+
- uses: ./.github/actions/python-cache
5271
- name: Run UI Tests (Debug)
53-
run: bundle exec fastlane test_ui device:"${{ env.IOS_SIMULATOR_DEVICE }}"
72+
run: bundle exec fastlane test_ui device:"${{ env.IOS_SIMULATOR_DEVICE }}" skip_build:true
5473
timeout-minutes: 40
5574
env:
5675
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -78,19 +97,23 @@ jobs:
7897
if: ${{ github.event_name == 'push' && failure() }}
7998
- name: Parse xcresult
8099
if: failure()
81-
run: xcparse screenshots fastlane/test_output/StreamChatSwiftUI.xcresult fastlane/test_output/snapshots --test
100+
run: |
101+
brew install chargepoint/xcparse/xcparse
102+
xcparse screenshots fastlane/test_output/StreamChatSwiftUI.xcresult fastlane/test_output/snapshots --test
82103
- uses: actions/upload-artifact@v3
83104
if: failure()
84105
with:
85106
name: Test Data
86107
path: |
87108
fastlane/test_output/snapshots
88109
89-
build-and-test-e2e-debug:
110+
test-e2e-debug:
90111
name: Test E2E UI (Debug)
91112
runs-on: macos-13
92113
if: ${{ github.event_name != 'push' }}
93-
needs: allure_testops_launch
114+
needs:
115+
- allure_testops_launch
116+
- build-test-app-and-frameworks
94117
env:
95118
LAUNCH_ID: ${{ needs.allure_testops_launch.outputs.launch_id }}
96119
strategy:
@@ -99,15 +122,15 @@ jobs:
99122
fail-fast: false
100123
steps:
101124
- uses: actions/[email protected]
102-
if: env.LAUNCH_ID != ''
125+
- uses: actions/download-artifact@v3
126+
with:
127+
name: cache-derived-data
128+
path: derived_data/Build/
103129
- uses: ./.github/actions/bootstrap
104-
if: env.LAUNCH_ID != ''
105130
env:
106131
INSTALL_ALLURE: true
107-
INSTALL_XCPARSE: true
108132
- name: Run UI Tests (Debug)
109-
if: env.LAUNCH_ID != ''
110-
run: bundle exec fastlane test_e2e_mock device:"${{ env.IOS_SIMULATOR_DEVICE }}" batch:'${{ matrix.batch }}'
133+
run: bundle exec fastlane test_e2e_mock device:"${{ env.IOS_SIMULATOR_DEVICE }}" batch:'${{ matrix.batch }}' test_without_building:true
111134
env:
112135
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113136
GITHUB_PR_NUM: ${{ github.event.number }}
@@ -127,7 +150,9 @@ jobs:
127150
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
128151
- name: Parse xcresult
129152
if: failure()
130-
run: xcparse logs fastlane/test_output/StreamChatSwiftUITestsApp.xcresult fastlane/test_output/logs/
153+
run: |
154+
brew install chargepoint/xcparse/xcparse
155+
xcparse logs fastlane/test_output/StreamChatUITestsApp.xcresult fastlane/test_output/logs/
131156
- uses: actions/upload-artifact@v3
132157
if: failure()
133158
with:
@@ -145,9 +170,7 @@ jobs:
145170
launch_id: ${{ steps.get_launch_id.outputs.launch_id }}
146171
steps:
147172
- uses: actions/[email protected]
148-
- uses: ./.github/actions/bootstrap
149-
env:
150-
XCODE_ACTIONS: false
173+
- uses: ./.github/actions/ruby-cache
151174
- name: Launch Allure TestOps
152175
run: bundle exec fastlane allure_launch
153176
env:
@@ -161,9 +184,15 @@ jobs:
161184
build-apps:
162185
name: Build Demo App
163186
runs-on: macos-13
187+
needs: build-test-app-and-frameworks
164188
if: ${{ github.event_name != 'push' }}
165189
steps:
166190
- uses: actions/[email protected]
167-
- uses: ./.github/actions/bootstrap
191+
- uses: actions/download-artifact@v3
192+
with:
193+
name: cache-derived-data
194+
path: derived_data/Build/
195+
- uses: ./.github/actions/ruby-cache
196+
- uses: ./.github/actions/xcode-cache
168197
- name: Build Demo App
169198
run: bundle exec fastlane build_demo

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,5 @@ reports/
8383
.scannerwork/
8484
push_payload.json
8585
sinatra_log.txt
86+
derived_data/
87+
spm_cache/

.slather.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
coverage_service: sonarqube_xml
22
xcodeproj: StreamChatSwiftUI.xcodeproj
33
scheme: StreamChatSwiftUI
4+
build_directory: derived_data/
45
source_directory: Sources/
56
output_directory: reports
67
ignore:

Brewfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
brew 'mint'
2+
brew 'sonar-scanner'

0 commit comments

Comments
 (0)