-
Notifications
You must be signed in to change notification settings - Fork 93
202 lines (167 loc) · 6.88 KB
/
housekeeping.yml
File metadata and controls
202 lines (167 loc) · 6.88 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Housekeeping
on:
schedule:
- cron: "0 8 * * *" # daily at 8:00 UTC
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
housekeeping:
name: Housekeeping
runs-on: macos-26
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Select Newest Xcode
run: |
chmod +x Resources/DevKit/scripts/select_newest_xcode.sh
./Resources/DevKit/scripts/select_newest_xcode.sh
- name: Install Dependencies
run: brew install xcbeautify
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Check for Submodule Updates
id: check
run: |
set -euo pipefail
echo "[+] checking submodule updates..."
has_updates=false
update_summary=""
git submodule foreach --quiet '
name=$(basename "$sm_path")
current=$(git rev-parse HEAD)
git fetch origin --quiet
default_branch=$(git remote show origin | grep "HEAD branch" | sed "s/.*: //")
if [ -z "$default_branch" ]; then
default_branch="main"
fi
latest=$(git rev-parse "origin/$default_branch")
if [ "$current" != "$latest" ]; then
current_short=$(git rev-parse --short HEAD)
latest_short=$(git rev-parse --short "origin/$default_branch")
echo "UPDATE:$name:$current_short:$latest_short"
fi
' > /tmp/submodule_updates.txt || true
if [ -s /tmp/submodule_updates.txt ]; then
has_updates=true
while IFS=: read -r prefix name current latest; do
update_summary="${update_summary}- **${name}**: \`${current}\` → \`${latest}\`\n"
done < /tmp/submodule_updates.txt
fi
echo "has_updates=$has_updates" >> "$GITHUB_OUTPUT"
echo "update_summary<<EOF" >> "$GITHUB_OUTPUT"
echo -e "$update_summary" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
if [ "$has_updates" = "true" ]; then
echo "[+] updates found"
else
echo "[+] all submodules up to date"
fi
- name: Update Submodules
if: steps.check.outputs.has_updates == 'true'
run: |
set -euo pipefail
echo "[+] updating submodules..."
git submodule foreach --quiet '
git fetch origin --quiet
default_branch=$(git remote show origin | grep "HEAD branch" | sed "s/.*: //")
if [ -z "$default_branch" ]; then
default_branch="main"
fi
git checkout "origin/$default_branch" --quiet
'
echo "[+] submodules updated"
- name: Scan Licenses
id: licenses
run: |
set -euo pipefail
echo "[+] scanning licenses..."
ALLOW_DIRTY=1 Resources/DevKit/scripts/scan.license.sh
# check if license file changed
if git diff --quiet FlowDown/BundledResources/OpenSourceLicenses.md; then
echo "has_license_updates=false" >> "$GITHUB_OUTPUT"
echo "[+] licenses unchanged"
else
echo "has_license_updates=true" >> "$GITHUB_OUTPUT"
echo "[+] licenses updated"
fi
- name: Resolve Packages
if: steps.check.outputs.has_updates == 'true' || steps.licenses.outputs.has_license_updates == 'true'
run: |
set -o pipefail
xcodebuild -downloadComponent MetalToolchain
xcodebuild \
-workspace FlowDown.xcworkspace \
-scheme FlowDown \
-resolvePackageDependencies \
CODE_SIGNING_ALLOWED=NO \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_IDENTITY="" \
| xcbeautify --is-ci --disable-colored-output --disable-logging
- name: Disable CloudKit for CI Testing
if: steps.check.outputs.has_updates == 'true' || steps.licenses.outputs.has_license_updates == 'true'
run: |
echo '' >> FlowDown/Configuration/DevelopmentDeveloper.xcconfig
echo 'SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) TEST_SIMULATOR_DISABLE_CLOUD_KIT' >> FlowDown/Configuration/DevelopmentDeveloper.xcconfig
- name: Build (iOS)
if: steps.check.outputs.has_updates == 'true' || steps.licenses.outputs.has_license_updates == 'true'
run: |
set -o pipefail
xcodebuild -downloadComponent MetalToolchain
DESTINATION=$(bash Resources/DevKit/scripts/get_first_ios_simulator.sh)
xcodebuild \
-workspace FlowDown.xcworkspace \
-scheme FlowDown \
-configuration Debug \
-destination "$DESTINATION" \
build \
CODE_SIGNING_ALLOWED=NO \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_IDENTITY="" \
| xcbeautify --is-ci --disable-colored-output --disable-logging
- name: Run Unit Tests
if: steps.check.outputs.has_updates == 'true' || steps.licenses.outputs.has_license_updates == 'true'
run: |
set -o pipefail
xcodebuild -downloadComponent MetalToolchain
DESTINATION=$(bash Resources/DevKit/scripts/get_first_ios_simulator.sh)
xcodebuild \
-workspace FlowDown.xcworkspace \
-scheme FlowDownUnitTests \
-configuration Debug \
-destination "$DESTINATION" \
test \
CODE_SIGNING_ALLOWED=NO \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_IDENTITY="" \
| xcbeautify --is-ci --disable-colored-output --disable-logging
- name: Revert CI-only Config Changes
if: steps.check.outputs.has_updates == 'true' || steps.licenses.outputs.has_license_updates == 'true'
run: git checkout -- FlowDown/Configuration/DevelopmentDeveloper.xcconfig
- name: Create Pull Request
if: steps.check.outputs.has_updates == 'true' || steps.licenses.outputs.has_license_updates == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Housekeeping Updates"
title: "Housekeeping Updates"
body: |
## Housekeeping Updates
### Submodule Updates
${{ steps.check.outputs.update_summary }}
### License Updates
License file regenerated: `${{ steps.licenses.outputs.has_license_updates }}`
---
*This PR was automatically created by the housekeeping workflow.*
branch: housekeeping/updates
delete-branch: true
labels: |
housekeeping
dependencies