|
|
name: Generate Cached Results |
|
|
|
|
|
on: |
|
|
push: |
|
|
branches: [main] |
|
|
|
|
|
workflow_dispatch: |
|
|
|
|
|
jobs: |
|
|
generate-cache: |
|
|
runs-on: ubuntu-latest |
|
|
steps: |
|
|
- name: Free disk space |
|
|
run: | |
|
|
sudo rm -rf /usr/share/dotnet |
|
|
sudo rm -rf /opt/ghc |
|
|
sudo rm -rf /usr/local/share/boost |
|
|
docker system prune -af |
|
|
|
|
|
- name: Checkout repository |
|
|
uses: actions/checkout@v4 |
|
|
with: |
|
|
fetch-depth: 0 |
|
|
token: ${{ secrets.GITHUB_TOKEN }} |
|
|
lfs: true |
|
|
|
|
|
- name: Setup Python |
|
|
uses: actions/setup-python@v5 |
|
|
with: |
|
|
python-version: '3.10' |
|
|
cache: 'pip' |
|
|
|
|
|
- name: Install dependencies |
|
|
run: | |
|
|
pip install git+https://github.com/embeddings-benchmark/mteb.git |
|
|
|
|
|
- name: Generate cached results |
|
|
run: | |
|
|
python scripts/generate_cached_results.py |
|
|
env: |
|
|
PYTHONUNBUFFERED: 1 |
|
|
|
|
|
- name: Install Git LFS |
|
|
run: | |
|
|
sudo apt-get update |
|
|
sudo apt-get install -y git-lfs |
|
|
git lfs install |
|
|
# Explicitly pull LFS files to work around checkout action issues |
|
|
git lfs pull || true |
|
|
|
|
|
- name: Configure Git |
|
|
run: | |
|
|
git config --global user.name "github-actions[bot]" |
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com" |
|
|
|
|
|
- name: Update cached-data branch |
|
|
run: | |
|
|
# Check if __cached_results.json.gz was created |
|
|
if [ ! -f "__cached_results.json.gz" ]; then |
|
|
echo "β Cached results file not found" |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
|
|
|
FILE_SIZE=$(stat -f%z __cached_results.json.gz 2>/dev/null || stat -c%s __cached_results.json.gz) |
|
|
echo "π¦ Generated cache file: $(echo "scale=1; $FILE_SIZE/1024/1024" | bc -l)MB" |
|
|
|
|
|
|
|
|
if [ -f "__cached_results.json.gz" ]; then |
|
|
mv __cached_results.json.gz __cached_results.json.gz.tmp |
|
|
fi |
|
|
|
|
|
|
|
|
if git show-ref --verify --quiet refs/remotes/origin/cached-data; then |
|
|
echo "π Switching to existing cached-data branch" |
|
|
git checkout cached-data |
|
|
git pull origin cached-data |
|
|
|
|
|
git lfs pull || true |
|
|
else |
|
|
echo "π Creating new cached-data branch" |
|
|
git checkout --orphan cached-data |
|
|
|
|
|
git rm -rf . 2>/dev/null || true |
|
|
fi |
|
|
|
|
|
|
|
|
if [ -f "__cached_results.json.gz.tmp" ]; then |
|
|
mv __cached_results.json.gz.tmp __cached_results.json.gz |
|
|
fi |
|
|
|
|
|
|
|
|
if ! git lfs ls-files | grep -q "__cached_results.json.gz"; then |
|
|
git lfs track "__cached_results.json.gz" |
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [ -f "README.md" ]; then |
|
|
git ls-files | grep -v "README.md" | grep -v ".gitattributes" | xargs -r git rm 2>/dev/null || true |
|
|
else |
|
|
git ls-files | grep -v ".gitattributes" | xargs -r git rm 2>/dev/null || true |
|
|
fi |
|
|
|
|
|
|
|
|
git add __cached_results.json.gz |
|
|
|
|
|
|
|
|
if [ -f "README.md" ]; then |
|
|
git add README.md |
|
|
fi |
|
|
|
|
|
|
|
|
if [ -f ".gitattributes" ]; then |
|
|
git add .gitattributes |
|
|
fi |
|
|
|
|
|
|
|
|
if git diff --staged --quiet; then |
|
|
echo "β
No changes in cached results, skipping commit" |
|
|
else |
|
|
|
|
|
STAGED_FILES=$(git diff --staged --name-only | wc -l) |
|
|
if [ "$STAGED_FILES" -gt 10 ]; then |
|
|
echo "β ERROR: Too many files staged ($STAGED_FILES). Expected only 1-3 files (__cached_results.json.gz, README.md, .gitattributes)." |
|
|
echo "Staged files:" |
|
|
git diff --staged --name-only |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
|
|
|
TIMESTAMP=$(date -u '+%Y-%m-%d %H:%M:%S UTC') |
|
|
COMMIT_MSG="Update cached results - $TIMESTAMP ($(echo "scale=1; $FILE_SIZE/1024/1024" | bc -l)MB)" |
|
|
git commit -m "$COMMIT_MSG" |
|
|
|
|
|
|
|
|
git push origin cached-data |
|
|
echo "β
Successfully updated cached-data branch" |
|
|
fi |
|
|
|
|
|
- name: Report status |
|
|
if: always() |
|
|
run: | |
|
|
if [ -f "__cached_results.json.gz" ]; then |
|
|
FILE_SIZE=$(stat -f%z __cached_results.json.gz 2>/dev/null || stat -c%s __cached_results.json.gz) |
|
|
echo "β
Workflow completed. Cache file size: $(echo "scale=1; $FILE_SIZE/1024/1024" | bc -l)MB" |
|
|
else |
|
|
echo "β Workflow failed - no cache file generated" |
|
|
fi |
|
|
|