From 4c5283ebfce9e72528ac12c9183d4a7d97fa672c Mon Sep 17 00:00:00 2001 From: Matt Gaunt-Seo Date: Thu, 12 Jan 2023 11:03:11 -0800 Subject: [PATCH 1/4] Adding install-cmd and remove cache pip --- .github/workflows/self-test.yml | 3 +-- README.md | 3 +-- action.yml | 8 ++++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/self-test.yml b/.github/workflows/self-test.yml index a358795..9114a22 100644 --- a/.github/workflows/self-test.yml +++ b/.github/workflows/self-test.yml @@ -15,13 +15,12 @@ jobs: uses: ./ with: python-version: 3.8.13 + install-cmd: pip install -r test/testdata/requirements.txt - name: Print variables for debugging run: | echo "VIRTUAL_ENV: ${VIRTUAL_ENV}" echo "PATH: ${PATH}" echo "Cache Hit: ${{ steps.venv.outputs.cache-hit }}" - - run: pip install -r test/testdata/requirements.txt - if: steps.venv.outputs.cache-hit != 'true' shell: bash - name: Print site-packages for debugging run: ls -la ${VIRTUAL_ENV}/lib/*/site-packages/ diff --git a/README.md b/README.md index abc80b4..c5db394 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,5 @@ Sets up python and a virtual environment with caching. cache-dependency-path: | requirements.txt requirements-frozen.txt - - run: pip install -r requirements.txt - if: steps.venv.outputs.cache-hit != 'true' + install-cmd: pip install -r requirements.txt -c requirements-frozen.txt ``` diff --git a/action.yml b/action.yml index 8f67c73..158444a 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,8 @@ inputs: default: '**/requirements*.txt' venv-dir: default: '.venv' + install-cmd: + default: 'Command to install python dependencies.' outputs: cache-hit: @@ -22,8 +24,6 @@ runs: id: setup-python with: python-version: ${{ inputs.python-version }} - cache: 'pip' - cache-dependency-path: ${{ inputs.cache-dependency-path }} - uses: actions/cache@v3 id: cache-venv @@ -40,3 +40,7 @@ runs: echo "VIRTUAL_ENV=${VIRTUAL_ENV}" >> $GITHUB_ENV echo "${VIRTUAL_ENV}/bin" >> $GITHUB_PATH shell: bash + + - run: ${{ inputs.install-cmd }} + if: steps.cache-venv.outputs.cache-hit != 'true' + shell: bash From 2822bbcb9f6c34978b2bda817765a27ef785efc2 Mon Sep 17 00:00:00 2001 From: Matt Gaunt-Seo Date: Thu, 12 Jan 2023 11:11:35 -0800 Subject: [PATCH 2/4] Add comments and cleanup test action --- .github/workflows/self-test.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/self-test.yml b/.github/workflows/self-test.yml index 9114a22..8525c1d 100644 --- a/.github/workflows/self-test.yml +++ b/.github/workflows/self-test.yml @@ -10,20 +10,24 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + + # Run local action - name: Test action-setup-venv id: venv uses: ./ with: python-version: 3.8.13 install-cmd: pip install -r test/testdata/requirements.txt + + # Print debug vars - name: Print variables for debugging run: | echo "VIRTUAL_ENV: ${VIRTUAL_ENV}" echo "PATH: ${PATH}" echo "Cache Hit: ${{ steps.venv.outputs.cache-hit }}" - shell: bash - - name: Print site-packages for debugging - run: ls -la ${VIRTUAL_ENV}/lib/*/site-packages/ + ls -la ${VIRTUAL_ENV}/lib/*/site-packages/ + + # Test the venv and install worked - name: Ensurenvironment works run: python3 ./test/testdata/demo.py From c79e7b184e477b118d1ccfd12356a9e9f1ab1683 Mon Sep 17 00:00:00 2001 From: Matt Gaunt-Seo Date: Thu, 12 Jan 2023 11:12:06 -0800 Subject: [PATCH 3/4] Add install cmd to cache key --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 158444a..c124180 100644 --- a/action.yml +++ b/action.yml @@ -29,7 +29,7 @@ runs: id: cache-venv with: path: ${{ inputs.venv-dir }} - key: setup-venv-${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-${{ steps.setup-python.outputs.python-path }}-${{ hashFiles(inputs.cache-dependency-path) }} + key: setup-venv-${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-${{ steps.setup-python.outputs.python-path }}-${{ hashFiles(inputs.cache-dependency-path) }}-${{ inputs.install-cmd }} - run: python3 -m venv ${{ inputs.venv-dir }} if: steps.cache-venv.outputs.cache-hit != 'true' From f64eb1fca1d46941a2e521d011ad3d84f4cb983c Mon Sep 17 00:00:00 2001 From: Matt Gaunt-Seo Date: Thu, 12 Jan 2023 11:14:06 -0800 Subject: [PATCH 4/4] Fix typos --- .github/workflows/self-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/self-test.yml b/.github/workflows/self-test.yml index 8525c1d..c3a5d1f 100644 --- a/.github/workflows/self-test.yml +++ b/.github/workflows/self-test.yml @@ -28,6 +28,6 @@ jobs: ls -la ${VIRTUAL_ENV}/lib/*/site-packages/ # Test the venv and install worked - - name: Ensurenvironment works + - name: Ensure environment works run: python3 ./test/testdata/demo.py