Skip to content

Commit

Permalink
Merge pull request #2 from getsentry/mattgauntseo-install-cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgauntseo-sentry authored Jan 12, 2023
2 parents f1a2605 + f64eb1f commit 30b11e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +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 }}"
- 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/
- name: Ensurenvironment works
ls -la ${VIRTUAL_ENV}/lib/*/site-packages/
# Test the venv and install worked
- name: Ensure environment works
run: python3 ./test/testdata/demo.py

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ inputs:
default: '**/requirements*.txt'
venv-dir:
default: '.venv'
install-cmd:
default: 'Command to install python dependencies.'

outputs:
cache-hit:
Expand All @@ -22,14 +24,12 @@ 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
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'
Expand All @@ -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

0 comments on commit 30b11e1

Please sign in to comment.