Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,48 @@ jobs:
steps:
- uses: actions/checkout@v3

- run: echo "3.11.6" > .python-version
shell: bash

# Run local action
- name: Test action-setup-venv
id: venv
uses: ./
with:
# this should override .python-version
python-version: 3.11.4
install-cmd: pip install -r test/testdata/requirements.txt

# Print debug vars
- name: Print variables for debugging
shell: bash
run: |
echo "VIRTUAL_ENV: ${VIRTUAL_ENV}"
echo "PATH: ${PATH}"
echo "Cache Hit: ${{ steps.venv.outputs.cache-hit }}"
ls -la ${VIRTUAL_ENV}/${{ runner.os == 'Windows' && 'Lib' || 'lib/*' }}/site-packages

# Test the venv and install worked
- name: Ensure environment works
run: |
python -Sc 'import sys; assert sys.version_info[:3] == (3, 11, 4), sys.version_info'
python ./test/testdata/demo.py

self-test-python-version-file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- run: echo "3.11.6" > .python-version
shell: bash

# Run local action
- name: Test action-setup-venv
id: venv
uses: ./
with:
python-version: 3.8
# since there is a .python-version file and we did not specify
# python-version, it should be used
install-cmd: pip install -r test/testdata/requirements.txt

# Print debug vars
Expand All @@ -35,7 +71,9 @@ jobs:

# Test the venv and install worked
- name: Ensure environment works
run: python ./test/testdata/demo.py
run: |
python -Sc 'import sys; assert sys.version_info[:3] == (3, 11, 6), sys.version_info'
python ./test/testdata/demo.py

no-install-self-test:
runs-on: ubuntu-latest
Expand All @@ -47,11 +85,13 @@ jobs:
id: venv
uses: ./
with:
python-version: 3.8
python-version: 3.11.6

# Test the venv and external install work
- name: Pip install
if: steps.venv.outputs.cache-hit != 'true'
run: pip install -r test/testdata/requirements.txt
- name: Ensure environment works
run: python ./test/testdata/demo.py
run: |
python -Sc 'import sys; assert sys.version_info[:3] == (3, 11, 6), sys.version_info'
python ./test/testdata/demo.py
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,28 @@ when the cache is available.

### Usage

uv:
```yaml
- uses: getsentry/[email protected]
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6
with:
version: "0.8.2"
# we just cache the venv-dir directly in action-setup-venv
enable-cache: false

- uses: getsentry/[email protected]
with:
cache-dependency-path: uv.lock
install-cmd: uv sync --frozen --active
```

pip:
```yaml
- uses: getsentry/[email protected]
id: venv
with:
python-version: 3.10.7
# starting from [email protected], if python-version isn't specified,
# we default to using the version in .python-version file.
python-version: 3.11.6
cache-dependency-path: |
requirements.txt
requirements-frozen.txt
Expand Down
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ description: 'configures venv, python and caches'

inputs:
python-version:
description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax."
description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax. If not set, the version in .python-version file will be used."
default: ''
cache-dependency-path:
description: "Requirement files to install. Can be a glob pattern."
default: '**/requirements*.txt'
Expand All @@ -24,6 +25,7 @@ runs:
id: setup-python
with:
python-version: ${{ inputs.python-version }}
python-version-file: ${{ hashFiles('.python-version') == '' && '' || '.python-version' }}

- run: echo '::remove-matcher owner=python::'
shell: bash
Expand Down
Loading