Skip to content

MAINT: Add clear-cache job (#12) #35

MAINT: Add clear-cache job (#12)

MAINT: Add clear-cache job (#12) #35

Workflow file for this run

name: Test pixi-lock actions
on:
push:
branches: [main, test-me/*]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PIXI_VERSION: "v0.63.0"
jobs:
clear-cache:
runs-on: ubuntu-slim
permissions:
actions: write
steps:
- name: Clear pixi-lock cache entries
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "Clearing pixi-lock-* cache entries"
gh cache list --repo ${{ github.repository }} --json key --jq '.[].key' | grep '^pixi-lock_' | while read -r key; do
echo "Deleting cache: $key"
for attempt in 1 2 3; do
if gh cache delete "$key" --repo ${{ github.repository }}; then
break
fi
echo "Attempt $attempt failed, retrying in 5 seconds..."
sleep 5
done
done
sleep 5
echo "Verifying all caches are cleared..."
remaining=$(gh cache list --repo ${{ github.repository }} --json key --jq '.[].key' | grep '^pixi-lock_' || true)
if [ -n "$remaining" ]; then
echo "Error: Some caches still exist:"
echo "$remaining"
exit 1
fi
echo "Cache cleared"
cache-pixi-lock:
needs: clear-cache
runs-on: ubuntu-slim
outputs:
cache-key: ${{ steps.create-and-cache.outputs.cache-key }}
pixi-version: ${{ steps.create-and-cache.outputs.pixi-version }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
path: pixi-lock
- name: Copy test files to working directory
shell: bash
run: cp -r pixi-lock/ci/test/* .
- name: Run create-and-cache action
id: create-and-cache
uses: ./pixi-lock/create-and-cache
with:
pixi-version: ${{ env.PIXI_VERSION }}
- name: Verify pixi.lock exists
shell: bash
run: |
if [ -f "pixi.lock" ]; then
echo "pixi.lock exists"
else
echo "pixi.lock does not exist"
exit 1
fi
restore-and-install:
needs: cache-pixi-lock
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-slim, macos-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
path: pixi-lock
- name: Copy test files to working directory
shell: bash
run: cp -r pixi-lock/ci/test/* .
- name: Restore pixi.lock from cache
uses: ./pixi-lock/restore
with:
cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }}
- name: Verify pixi.lock exists
shell: bash
run: |
if [ -f "pixi.lock" ]; then
echo "pixi.lock exists"
else
echo "pixi.lock does not exist"
exit 1
fi
- name: Setup pixi and install environment
uses: prefix-dev/setup-pixi@v0.9.3
with:
pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }}
- name: Verify environment installed
shell: bash
run: |
if [ -d ".pixi/envs/default" ]; then
echo "Environment installed successfully"
else
echo "Environment not installed"
exit 1
fi