-
Notifications
You must be signed in to change notification settings - Fork 36
100 lines (85 loc) · 3.19 KB
/
_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Test
on:
workflow_call:
inputs:
retake_snapshots:
required: false
default: false
type: boolean
defaults:
run:
shell: bash -l {0}
jobs:
TestPods:
name: Testing Pods
runs-on: macos-15
outputs:
changed-files: ${{ steps.checkSnapshotChanges.outputs.didChangeFiles }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up node and ruby
uses: asdf-vm/actions/install@v3 # Sets ruby and node version via `.tool-versions`
- name: Cache Bundler install Gems
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ env.ImageVersion }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-${{ env.ImageVersion }}
- name: Cache Pods
uses: actions/cache@v4
with:
path: Example/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Bundle Install
run: bundle install --jobs 4 --retry 3
- name: Pod Install
run: bundle exec pod install
working-directory: Example
- name: Select Xcode 16
run: sudo xcode-select --switch /Applications/Xcode_16.app
- name: Remove snapshots
if: ${{inputs.retake_snapshots}}
run: find . -type d -name "__Snapshots__" -exec rm -rf {} +;
- name: Run UIKit tests
run: ./scripts/ci uikit test
continue-on-error: ${{inputs.retake_snapshots}}
- name: Run SwiftUI tests
run: ./scripts/ci swiftui test
continue-on-error: ${{inputs.retake_snapshots}}
- name: Check snapshot changes
id: checkSnapshotChanges
run: changedFiles=`git status --porcelain` && echo "didChangeFiles=${changedFiles//$'\n'/'%0A'}" >> $GITHUB_OUTPUT
- name: Save snapshots
if: ${{inputs.retake_snapshots}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git remote set-url origin https://x-access-token:$GITHUB_TOKEN@github.com/${{ github.repository }}
git fetch origin $GITHUB_HEAD_REF
git checkout $GITHUB_HEAD_REF
git add --ignore-removal */**/__Snapshots__/*.png
git diff-index --quiet HEAD || git commit -m "Updated snapshots"
git push
NotifyChanges:
name: "Notify about changes made"
runs-on: ubuntu-22.04
needs: [TestPods]
if: ${{ needs.TestPods.outputs.changed-files != '' && inputs.retake_snapshots}}
steps:
- name: Notify PR of screenshots changes
uses: actions/github-script@v7
with:
script: |
var body = `### Snapshots were updated. Please verify the changes match the expected layout. \n\n>'${{ needs.TestPods.outputs.changed-files }}'`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})