Commit 7a230e3
authored
Cache at action level instead of group (#213)
#208 fixed one caching bug by changing when we update the cache.
I'm unsure if that PR introduced this bug (it may have) but this PR
fixes another.
When ever the _same_ file path is used to cache on in subsequent
actions, the cache is updated when the first succeeds, so the cache is
read as valid for the second action when it should be invalid.
Example config file
```yaml
apiVersion: scope.github.com/v1alpha
kind: ScopeDoctorGroup
metadata:
name: ssh
description: Setup SSH keys for GitHub authentication
spec:
include: when-required
needs: []
actions:
- name: private-key-exists
description: Ensures SSH private key exists
check:
paths:
- ~/.ssh/id_ed25519
commands:
- ./bin/ssh.sh check private-key
fix:
commands:
- ./bin/ssh.sh fix private-key
- name: public-key-exists
description: Ensures SSH public key exists
check:
paths:
- ~/.ssh/id_ed25519.pub
commands:
- ./bin/ssh.sh check public-key
fix:
commands:
- ./bin/ssh.sh fix public-key
- name: key-added
description: Uploads the pub key to GitHub
check:
# The paths in this were previously erroneously cached too early
# so the check was always passing
paths:
# if either of these files have changed, we need to re-check
- ~/.ssh/id_ed25519
- ~/.ssh/id_ed25519.pub
commands:
- ./bin/ssh.sh check github
fix:
commands:
- ./bin/ssh.sh fix github
```
This because we were keying _only_ off the group name and the fully
qualified file name.
This PR updates the cache to _also_ key off of the action name, so that
each check has a unique key in the cache.
Old cache format
```json
{
"checksums": {
"rails-group": {
"/path/to/file1.txt": "abc123",
"/path/to/file2.txt": "def456"
},
"ruby-group": {
"/path/to/ruby-version": "xyz789"
}
}
}
```
New cache format
```json
{
"checksums": {
"rails-group": {
"action-1": { "/path/to/file1.txt": "abc123" },
"action-2": { "/path/to/file2.txt": "def456" }
},
"ruby-group": {
"action-3": { "/path/to/ruby-version": "xyz789" }
}
}
}
```
_IMPORTANT:_ This will invalidate any existing cache on a user's
machine. The first time a user runs with this new version, we will
invalidate all of their existing caches.1 parent ed48782 commit 7a230e3
File tree
4 files changed
+775
-28
lines changed- scope
- src/doctor
4 files changed
+775
-28
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
271 | 272 | | |
272 | 273 | | |
273 | 274 | | |
| |||
592 | 593 | | |
593 | 594 | | |
594 | 595 | | |
| 596 | + | |
595 | 597 | | |
596 | 598 | | |
597 | 599 | | |
| |||
682 | 684 | | |
683 | 685 | | |
684 | 686 | | |
| 687 | + | |
685 | 688 | | |
686 | 689 | | |
687 | 690 | | |
| |||
690 | 693 | | |
691 | 694 | | |
692 | 695 | | |
| 696 | + | |
693 | 697 | | |
694 | 698 | | |
695 | 699 | | |
| |||
746 | 750 | | |
747 | 751 | | |
748 | 752 | | |
| 753 | + | |
749 | 754 | | |
750 | 755 | | |
751 | 756 | | |
| |||
757 | 762 | | |
758 | 763 | | |
759 | 764 | | |
760 | | - | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
761 | 768 | | |
762 | 769 | | |
763 | 770 | | |
| |||
774 | 781 | | |
775 | 782 | | |
776 | 783 | | |
| 784 | + | |
777 | 785 | | |
778 | 786 | | |
779 | 787 | | |
780 | 788 | | |
781 | 789 | | |
782 | 790 | | |
783 | | - | |
| 791 | + | |
784 | 792 | | |
785 | 793 | | |
786 | 794 | | |
| |||
1068 | 1076 | | |
1069 | 1077 | | |
1070 | 1078 | | |
1071 | | - | |
| 1079 | + | |
1072 | 1080 | | |
1073 | 1081 | | |
1074 | 1082 | | |
1075 | | - | |
| 1083 | + | |
1076 | 1084 | | |
1077 | 1085 | | |
1078 | 1086 | | |
| |||
1098 | 1106 | | |
1099 | 1107 | | |
1100 | 1108 | | |
1101 | | - | |
| 1109 | + | |
1102 | 1110 | | |
1103 | 1111 | | |
1104 | 1112 | | |
1105 | | - | |
| 1113 | + | |
1106 | 1114 | | |
1107 | 1115 | | |
1108 | 1116 | | |
| |||
1128 | 1136 | | |
1129 | 1137 | | |
1130 | 1138 | | |
1131 | | - | |
| 1139 | + | |
1132 | 1140 | | |
1133 | 1141 | | |
1134 | 1142 | | |
| |||
1170 | 1178 | | |
1171 | 1179 | | |
1172 | 1180 | | |
1173 | | - | |
| 1181 | + | |
1174 | 1182 | | |
1175 | 1183 | | |
1176 | 1184 | | |
1177 | | - | |
| 1185 | + | |
1178 | 1186 | | |
1179 | 1187 | | |
1180 | 1188 | | |
| |||
1228 | 1236 | | |
1229 | 1237 | | |
1230 | 1238 | | |
1231 | | - | |
| 1239 | + | |
1232 | 1240 | | |
1233 | 1241 | | |
1234 | 1242 | | |
1235 | | - | |
| 1243 | + | |
1236 | 1244 | | |
1237 | 1245 | | |
1238 | 1246 | | |
| |||
1267 | 1275 | | |
1268 | 1276 | | |
1269 | 1277 | | |
| 1278 | + | |
1270 | 1279 | | |
1271 | 1280 | | |
1272 | | - | |
| 1281 | + | |
1273 | 1282 | | |
1274 | 1283 | | |
1275 | 1284 | | |
| |||
1286 | 1295 | | |
1287 | 1296 | | |
1288 | 1297 | | |
| 1298 | + | |
1289 | 1299 | | |
1290 | 1300 | | |
1291 | 1301 | | |
| |||
1302 | 1312 | | |
1303 | 1313 | | |
1304 | 1314 | | |
| 1315 | + | |
1305 | 1316 | | |
1306 | 1317 | | |
1307 | | - | |
| 1318 | + | |
1308 | 1319 | | |
1309 | 1320 | | |
1310 | 1321 | | |
| |||
1321 | 1332 | | |
1322 | 1333 | | |
1323 | 1334 | | |
| 1335 | + | |
1324 | 1336 | | |
1325 | 1337 | | |
1326 | 1338 | | |
| |||
1340 | 1352 | | |
1341 | 1353 | | |
1342 | 1354 | | |
| 1355 | + | |
1343 | 1356 | | |
1344 | 1357 | | |
1345 | | - | |
| 1358 | + | |
1346 | 1359 | | |
1347 | 1360 | | |
1348 | 1361 | | |
| |||
1367 | 1380 | | |
1368 | 1381 | | |
1369 | 1382 | | |
| 1383 | + | |
1370 | 1384 | | |
1371 | 1385 | | |
1372 | 1386 | | |
| |||
1385 | 1399 | | |
1386 | 1400 | | |
1387 | 1401 | | |
| 1402 | + | |
1388 | 1403 | | |
1389 | 1404 | | |
1390 | | - | |
| 1405 | + | |
1391 | 1406 | | |
1392 | 1407 | | |
1393 | 1408 | | |
| |||
1407 | 1422 | | |
1408 | 1423 | | |
1409 | 1424 | | |
| 1425 | + | |
1410 | 1426 | | |
1411 | 1427 | | |
1412 | 1428 | | |
| |||
0 commit comments