Skip to content

Commit 7c8030b

Browse files
ci: Fix bugs in eviction script. (#12)
1 parent 97c4ef2 commit 7c8030b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

.github/workflows/evict.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
# a cache entry from a non-default branch (on an LRU basis). That should create
2121
# enough space for a new cache entry.
2222

23-
import datetime
23+
from datetime import datetime
2424
import requests
25+
import operator
2526
import os
2627

2728
DEFAULT_BRANCH_NAME = 'scip-ruby/master'
@@ -75,13 +76,13 @@ def default_main():
7576
return
7677

7778
entries_and_times = [
78-
(x, datetime.fromisoformat(x['last_accessed_at']))
79+
(x, datetime.strptime(x['last_accessed_at'].split('.')[0], '%Y-%m-%dT%H:%M:%S'))
7980
for x in other_branch_cache_entries
8081
]
8182

8283
# Sort descending based on timestamps, and evict the oldest one.
83-
sorted(entries_and_times, key=itemgetter(1))
84-
earliest_entry = entries_and_times[0]
84+
sorted(entries_and_times, key=operator.itemgetter(1))
85+
earliest_entry = entries_and_times[0][0]
8586

8687
if os.getenv('DRY_RUN'):
8788
print('dry run: Will evict:\n{}'.format(earliest_entry))

0 commit comments

Comments
 (0)