| 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 }} |
|
|
| - 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: 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 |
| env: |
| GIT_LFS_SKIP_SMUDGE: "1" |
| 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 |
|
|
| |
| if [ -f ".gitattributes" ]; then |
| echo "π§Ή Removing .gitattributes (LFS cleanup)" |
| git rm .gitattributes 2>/dev/null || rm -f .gitattributes |
| fi |
| 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 [ -f "README.md" ]; then |
| git ls-files | grep -v "README.md" | xargs -r git rm 2>/dev/null || true |
| else |
| git ls-files | 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 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-2 files." |
| 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 |
| |