Skip to content

Add hash-files argument to create-and-cache action #46

Add hash-files argument to create-and-cache action

Add hash-files argument to create-and-cache action #46

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
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"
test-cache-restore-install:
needs: clear-cache
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Test OS values with fixed test-folder and pixi-version
- os: ubuntu-latest
test-folder: just-pixi-toml
expected-hash: "pixi-lock__69110db0bf39d7ce64fd774c7078ccd56ebf8542d9a1e86f84e63011634dc43f_2026-02-24"
pixi-version: ""
- os: macos-latest
test-folder: just-pixi-toml
expected-hash: "pixi-lock__69110db0bf39d7ce64fd774c7078ccd56ebf8542d9a1e86f84e63011634dc43f_2026-02-24"
pixi-version: ""
- os: windows-latest
test-folder: just-pixi-toml
expected-hash: "pixi-lock__adbacdefe20c62f204989acf366ef09911f3af89f066088613341b946be131e8_2026-02-24"
pixi-version: ""
# Test test-folder values with fixed OS and pixi-version
- os: ubuntu-latest
test-folder: just-pixi-toml
expected-hash: "pixi-lock__69110db0bf39d7ce64fd774c7078ccd56ebf8542d9a1e86f84e63011634dc43f_2026-02-24"
pixi-version: ""
- os: ubuntu-latest
test-folder: just-pyproject-toml
expected-hash: "pixi-lock__5626c1bd50c85d7a0f8cd9758f61f1d7ee8f868b7a149f7bd970dcd846b60974_2026-02-24"
pixi-version: ""
- os: ubuntu-latest
test-folder: pyproject-and-pixi-toml
expected-hash: "pixi-lock__b5bae43771086cb1dd79c43dc06881f8b0e006ad8c54e7269dad1a4f8ce96522_2026-02-24"
pixi-version: ""
# Test pixi-version values with fixed OS and test-folder
- os: ubuntu-latest
test-folder: just-pixi-toml
expected-hash: "pixi-lock__69110db0bf39d7ce64fd774c7078ccd56ebf8542d9a1e86f84e63011634dc43f_2026-02-24"
pixi-version: ""
- os: ubuntu-latest
test-folder: just-pixi-toml
expected-hash: "pixi-lock_v0.63.2_69110db0bf39d7ce64fd774c7078ccd56ebf8542d9a1e86f84e63011634dc43f_2026-02-24"
pixi-version: "v0.63.2"
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/${{ matrix.test-folder }}/* .
- name: Run create-and-cache action
id: create-and-cache
uses: ./pixi-lock/create-and-cache
with:
pixi-version: ${{ matrix.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
- name: Cleanup pixi.lock
shell: bash
run: rm pixi.lock
- name: Cleanup pixi install
shell: bash
run: rm -rf ~/.pixi
- name: Restore pixi.lock from cache
uses: ./pixi-lock/restore
with:
cache-key: ${{ steps.create-and-cache.outputs.cache-key }}
- name: Verify cache key hash matches expected
shell: bash
run: |
actual_hash="${{ steps.create-and-cache.outputs.cache-key }}"
expected_hash="${{ matrix.expected-hash }}"
echo "Expected hash: $expected_hash"
echo "Actual hash: $actual_hash"
if [ "$actual_hash" != "$expected_hash" ]; then
echo "ERROR: Hash mismatch!"
echo "Please update the expected-hash in the workflow matrix to: $actual_hash"
exit 1
fi
echo "Hash matches expected value"
- name: Verify pixi.lock exists after restore
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: ${{ matrix.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