From 4249c9eb1ee7cbedb66dc2f7268033354b1e5be3 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 16:59:46 -0500 Subject: [PATCH 01/17] Fail purposefully --- action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index aa71a53..51efe0d 100644 --- a/action.yml +++ b/action.yml @@ -37,8 +37,8 @@ runs: shell: bash run: | pipx install uv - echo "uv-path=$(which uv)" >> $GITHUB_OUTPUT - echo "uv-cache-dir=$(uv cache dir)" >> $GITHUB_OUTPUT + echo "uv-path=$(which uv000)" >> $GITHUB_OUTPUT + echo "uv-cache-dir=$(uv cache dir000)" >> $GITHUB_OUTPUT echo "venv-dir=$HOME/.venv" >> $GITHUB_OUTPUT - name: Windows venv dir (Windows) @@ -47,14 +47,14 @@ runs: 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 + echo "venv-dir=$(cygpath000 -w ${{ steps.setup-uv.outputs.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 + echo "checksum-suffix=-$(python checksum.py000 ${{ inputs.cache-dependency-path }})" >> $GITHUB_OUTPUT - name: Set up package cache id: setup-package-cache From 9d911df9d4321d364e89111da03f000df8eed42c Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:04:07 -0500 Subject: [PATCH 02/17] Use variable assignments --- action.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 51efe0d..57002df 100644 --- a/action.yml +++ b/action.yml @@ -37,8 +37,12 @@ runs: shell: bash run: | pipx install uv - echo "uv-path=$(which uv000)" >> $GITHUB_OUTPUT - echo "uv-cache-dir=$(uv cache dir000)" >> $GITHUB_OUTPUT + uv_path=$(which uv000) + echo "UV_PATH=$uv_path" + echo "uv-path=$uv_path" >> $GITHUB_OUTPUT + uv_cache_dir = $(uv cache dir000) + echo "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) From b281b7fbc73a8ceeb5b3e3fba8ee223b0b543f92 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:12:53 -0500 Subject: [PATCH 03/17] Fix which --- action.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 57002df..8e71bed 100644 --- a/action.yml +++ b/action.yml @@ -37,11 +37,9 @@ runs: shell: bash run: | pipx install uv - uv_path=$(which uv000) - echo "UV_PATH=$uv_path" + uv_path=$(which uv) echo "uv-path=$uv_path" >> $GITHUB_OUTPUT uv_cache_dir = $(uv cache dir000) - echo "uv_cache_dir" = $uv_cache_dir echo "uv-cache-dir=$uv_cache_dir" >> $GITHUB_OUTPUT echo "venv-dir=$HOME/.venv" >> $GITHUB_OUTPUT From 1b47d3ac4509c7b4d8615196c9edd458a0fb81f6 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:15:51 -0500 Subject: [PATCH 04/17] Fix uv cache dir --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 8e71bed..877905d 100644 --- a/action.yml +++ b/action.yml @@ -39,7 +39,7 @@ runs: pipx install uv uv_path=$(which uv) echo "uv-path=$uv_path" >> $GITHUB_OUTPUT - uv_cache_dir = $(uv cache dir000) + uv_cache_dir = $(uv cache dir) echo "uv-cache-dir=$uv_cache_dir" >> $GITHUB_OUTPUT echo "venv-dir=$HOME/.venv" >> $GITHUB_OUTPUT From 31715341f1b796a8f1e492d8b954bd531d256206 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:17:52 -0500 Subject: [PATCH 05/17] Checkout into a subdirectory --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a118f8..e4b5a77 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,9 +23,11 @@ jobs: 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 }} From a4597347f7ced6393d7732657d0d152aad5778f4 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:18:50 -0500 Subject: [PATCH 06/17] Fix bad spacing --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 877905d..d204db0 100644 --- a/action.yml +++ b/action.yml @@ -39,7 +39,7 @@ runs: pipx install uv uv_path=$(which uv) echo "uv-path=$uv_path" >> $GITHUB_OUTPUT - uv_cache_dir = $(uv cache dir) + uv_cache_dir=$(uv cache dir) echo "uv-cache-dir=$uv_cache_dir" >> $GITHUB_OUTPUT echo "venv-dir=$HOME/.venv" >> $GITHUB_OUTPUT From 16ab08e6e5977b2f1c654dab50c855dd3377175f Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:22:25 -0500 Subject: [PATCH 07/17] Use real python script --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index d204db0..385cf56 100644 --- a/action.yml +++ b/action.yml @@ -56,7 +56,7 @@ runs: if: ${{ (inputs.cache == 'packages' || inputs.cache == 'venv') && inputs.cache-dependency-path }} shell: bash run: | - echo "checksum-suffix=-$(python checksum.py000 ${{ inputs.cache-dependency-path }})" >> $GITHUB_OUTPUT + echo "checksum-suffix=-$(python checksum.py ${{ inputs.cache-dependency-path }})" >> $GITHUB_OUTPUT - name: Set up package cache id: setup-package-cache From 0cb25910d365b1c32ccaa1b658b3f4ae9f47dc08 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:23:12 -0500 Subject: [PATCH 08/17] Use correct path syntax --- .github/workflows/test.yml | 2 +- action.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e4b5a77..a849927 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - path: src + path: ./src - name: Set up Python with uv (local source) uses: src diff --git a/action.yml b/action.yml index 385cf56..dcbef38 100644 --- a/action.yml +++ b/action.yml @@ -56,7 +56,8 @@ runs: 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 checksum.py ${{ inputs.cache-dependency-path }}) + echo "checksum-suffix=-$overall_checksum" >> $GITHUB_OUTPUT - name: Set up package cache id: setup-package-cache From 9b5c7e3624ad1a9d30f47daac76120a465608b8d Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:23:52 -0500 Subject: [PATCH 09/17] Use correct path syntax, for real --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a849927..32169d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,10 +24,10 @@ jobs: steps: - uses: actions/checkout@v4 with: - path: ./src + path: src - name: Set up Python with uv (local source) - uses: src + uses: ./src with: python-version: "3.12" cache: ${{ matrix.cache }} From eef4519fa592b7aee2f3b0201746935ee1b93da1 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:27:12 -0500 Subject: [PATCH 10/17] Point to --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index dcbef38..26a11e6 100644 --- a/action.yml +++ b/action.yml @@ -56,7 +56,7 @@ runs: if: ${{ (inputs.cache == 'packages' || inputs.cache == 'venv') && inputs.cache-dependency-path }} shell: bash run: | - overall_checksum=$(python checksum.py ${{ inputs.cache-dependency-path }}) + overall_checksum=$(python $GITHUB_ACTION_PATH/checksum.py ${{ inputs.cache-dependency-path }}) echo "checksum-suffix=-$overall_checksum" >> $GITHUB_OUTPUT - name: Set up package cache From a94f5e0457ec35e33cc55b4b2009051617723a3e Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:29:57 -0500 Subject: [PATCH 11/17] Error if glob does not find anything --- checksum.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/checksum.py b/checksum.py index 4093885..f5aaf4a 100644 --- a/checksum.py +++ b/checksum.py @@ -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] From 3c00576ed6e46fc38630833b93b8e194c038e962 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:31:30 -0500 Subject: [PATCH 12/17] Fix requirements file path --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 32169d1..124034f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: 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' }} @@ -56,7 +56,7 @@ jobs: if: ${{ matrix.shell == 'bash' }} shell: bash run: | - uv pip install -r test_assets/requirements.txt + uv pip install -r src/test_assets/requirements.txt - name: Install dependencies (pwsh) if: ${{ matrix.shell == 'pwsh' }} From 3cf86a99f32e2bf77ef7a8345bb46982e857a786 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:38:26 -0500 Subject: [PATCH 13/17] Use working directory instead --- .github/workflows/test.yml | 13 +++++++------ Makefile => test_assets/Makefile | 0 2 files changed, 7 insertions(+), 6 deletions(-) rename Makefile => test_assets/Makefile (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 124034f..790fefd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,19 +20,20 @@ jobs: shell: pwsh - os: macos-latest shell: pwsh + defaults: + run: + working-directory: ./test_assets steps: - uses: actions/checkout@v4 - with: - path: src - name: Set up Python with uv (local source) - uses: ./src + uses: ./ with: python-version: "3.12" cache: ${{ matrix.cache }} cache-dependency-path: >- - src/test_assets/requirements.txt + requirements.txt - name: Check active Python (bash) if: ${{ matrix.shell == 'bash' }} @@ -56,13 +57,13 @@ jobs: if: ${{ matrix.shell == 'bash' }} shell: bash run: | - uv pip install -r src/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' }} diff --git a/Makefile b/test_assets/Makefile similarity index 100% rename from Makefile rename to test_assets/Makefile From 34bb479a0fa772fa51b6836f469d80fcfc75e383 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:48:30 -0500 Subject: [PATCH 14/17] Both checkout to src and default directory --- .github/workflows/test.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 790fefd..915889f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,18 +22,20 @@ jobs: shell: pwsh defaults: run: - working-directory: ./test_assets + 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: >- - requirements.txt + src/test_assets/requirements.txt - name: Check active Python (bash) if: ${{ matrix.shell == 'bash' }} From 5b0e57e4ee82a769d8000f62ece9647e007d076c Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:51:22 -0500 Subject: [PATCH 15/17] Separate out command substitution --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 26a11e6..003e551 100644 --- a/action.yml +++ b/action.yml @@ -48,8 +48,8 @@ runs: if: ${{ runner.os == 'Windows'}} shell: bash run: | - # actions/cache needs a Windows-style path for Windows, not Unix-style - echo "venv-dir=$(cygpath000 -w ${{ steps.setup-uv.outputs.venv-dir }})" >> $GITHUB_OUTPUT + venv_dir=$(cygpath000 -w ${{ steps.setup-uv.outputs.venv-dir }}) + echo "venv-dir=$venv_dir" >> $GITHUB_OUTPUT - name: Generate checksum of cache dependencies id: cache-dependency-checksum From 171ecf56dc0ef9d35e4b296cefbc9c33fca890bf Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:54:04 -0500 Subject: [PATCH 16/17] Add 0 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 003e551..0d13062 100644 --- a/action.yml +++ b/action.yml @@ -48,7 +48,7 @@ runs: if: ${{ runner.os == 'Windows'}} shell: bash run: | - venv_dir=$(cygpath000 -w ${{ steps.setup-uv.outputs.venv-dir }}) + venv_dir=$(cygpath0000 -w ${{ steps.setup-uv.outputs.venv-dir }}) echo "venv-dir=$venv_dir" >> $GITHUB_OUTPUT - name: Generate checksum of cache dependencies From c632ef4d15dca5b47f28992ea4d5a84a245bd602 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 1 Mar 2024 17:55:11 -0500 Subject: [PATCH 17/17] Use real cygpath --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 0d13062..9285e96 100644 --- a/action.yml +++ b/action.yml @@ -48,7 +48,7 @@ runs: if: ${{ runner.os == 'Windows'}} shell: bash run: | - venv_dir=$(cygpath0000 -w ${{ steps.setup-uv.outputs.venv-dir }}) + venv_dir=$(cygpath -w ${{ steps.setup-uv.outputs.venv-dir }}) echo "venv-dir=$venv_dir" >> $GITHUB_OUTPUT - name: Generate checksum of cache dependencies