Skip to content

ci: Fix bugs in eviction script. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/evict.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
# a cache entry from a non-default branch (on an LRU basis). That should create
# enough space for a new cache entry.

import datetime
from datetime import datetime
import requests
import operator
import os

DEFAULT_BRANCH_NAME = 'scip-ruby/master'
Expand Down Expand Up @@ -75,13 +76,13 @@ def default_main():
return

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

# Sort descending based on timestamps, and evict the oldest one.
sorted(entries_and_times, key=itemgetter(1))
earliest_entry = entries_and_times[0]
sorted(entries_and_times, key=operator.itemgetter(1))
earliest_entry = entries_and_times[0][0]

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