Skip to content
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

Fix Python script path, test correctly #3

Merged
merged 17 commits into from
Mar 1, 2024
13 changes: 9 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@ jobs:
shell: pwsh
- os: macos-latest
shell: pwsh
defaults:
run:
working-directory: src/test_assets

steps:
- uses: actions/checkout@v4
with:
path: src

- name: Set up Python with uv (local source)
uses: ./
uses: ./src
with:
python-version: "3.12"
cache: ${{ matrix.cache }}
cache-dependency-path: >-
test_assets/requirements.txt
src/test_assets/requirements.txt

- name: Check active Python (bash)
if: ${{ matrix.shell == 'bash' }}
Expand All @@ -54,13 +59,13 @@ jobs:
if: ${{ matrix.shell == 'bash' }}
shell: bash
run: |
uv pip install -r test_assets/requirements.txt
uv pip install -r requirements.txt

- name: Install dependencies (pwsh)
if: ${{ matrix.shell == 'pwsh' }}
shell: pwsh
run: |
uv pip install -r test_assets/requirements.txt
uv pip install -r requirements.txt

- name: Test some stuff (bash)
if: ${{ matrix.shell == 'bash' }}
Expand Down
13 changes: 8 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,27 @@ runs:
shell: bash
run: |
pipx install uv
echo "uv-path=$(which uv)" >> $GITHUB_OUTPUT
echo "uv-cache-dir=$(uv cache dir)" >> $GITHUB_OUTPUT
uv_path=$(which uv)
echo "uv-path=$uv_path" >> $GITHUB_OUTPUT
uv_cache_dir=$(uv cache dir)
echo "uv-cache-dir=$uv_cache_dir" >> $GITHUB_OUTPUT
echo "venv-dir=$HOME/.venv" >> $GITHUB_OUTPUT

- name: Windows venv dir (Windows)
id: venv-dir-windows
if: ${{ runner.os == 'Windows'}}
shell: bash
run: |
# actions/cache needs a Windows-style path for Windows, not Unix-style
echo "venv-dir=$(cygpath -w ${{ steps.setup-uv.outputs.venv-dir }})" >> $GITHUB_OUTPUT
venv_dir=$(cygpath -w ${{ steps.setup-uv.outputs.venv-dir }})
echo "venv-dir=$venv_dir" >> $GITHUB_OUTPUT

- name: Generate checksum of cache dependencies
id: cache-dependency-checksum
if: ${{ (inputs.cache == 'packages' || inputs.cache == 'venv') && inputs.cache-dependency-path }}
shell: bash
run: |
echo "checksum-suffix=-$(python checksum.py ${{ inputs.cache-dependency-path }})" >> $GITHUB_OUTPUT
overall_checksum=$(python $GITHUB_ACTION_PATH/checksum.py ${{ inputs.cache-dependency-path }})
echo "checksum-suffix=-$overall_checksum" >> $GITHUB_OUTPUT

- name: Set up package cache
id: setup-package-cache
Expand Down
5 changes: 4 additions & 1 deletion checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ def main():
dep_checksums = []
for dep in sorted(sys.argv[1:]):
# In general, dep is a glob
for path in sorted(Path().glob(dep)):
paths = sorted(Path().glob(dep))
if not paths:
raise Exception(f"No files found for dependency path: {dep}")
for path in paths:
dep_checksums.append((path, hashlib.md5(path.read_bytes()).hexdigest()))
dep_checksums_str = "\n".join(
[f"{path} {checksum}" for path, checksum in dep_checksums]
Expand Down
File renamed without changes.