Skip to content

Fixed parsing error when Python version is defined with tilde #45

Fixed parsing error when Python version is defined with tilde

Fixed parsing error when Python version is defined with tilde #45

Workflow file for this run

name: Test Action
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
test-basic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create test project
run: |
mkdir -p test-project
cat > test-project/pyproject.toml << EOF
[project]
name = "test-project"
version = "0.1.0"
requires-python = ">=3.9"
dependencies = [
"requests>=2.31.0",
"pytest>=7.4.0",
]
EOF
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
- name: Generate lock file
working-directory: test-project
run: |
export PATH="$HOME/.local/bin:$PATH"
uv sync
- name: Test basic usage (with default uv sync command)
uses: ./
with:
pyproject-path: test-project/pyproject.toml
test-default-sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create test project
run: |
mkdir -p test-project
cat > test-project/pyproject.toml << EOF
[project]
name = "test-project"
version = "0.1.0"
requires-python = ">=3.9"
dependencies = [
"requests>=2.31.0",
"pytest>=7.4.0",
]
EOF
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
- name: Generate lock file
working-directory: test-project
run: |
export PATH="$HOME/.local/bin:$PATH"
uv sync
- name: Test with default uv sync command (no requirements-command specified)
uses: ./
with:
pyproject-path: test-project/pyproject.toml
test-requirements:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create test project
run: |
mkdir -p test-project
cat > test-project/pyproject.toml << EOF
[project]
name = "test-project"
version = "0.1.0"
requires-python = ">=3.9"
dependencies = [
"requests>=2.31.0",
"pytest>=7.4.0",
]
EOF
- name: Install uv
working-directory: test-project
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
- name: Generate lock and requirements files
working-directory: test-project
run: |
export PATH="$HOME/.local/bin:$PATH"
uv sync
uv pip compile pyproject.toml -o requirements.txt
- name: Test with requirements
uses: ./
with:
pyproject-path: test-project/pyproject.toml
requirements-path: test-project/requirements.txt
requirements-command: uv pip compile pyproject.toml -o requirements.txt
test-custom-requirements:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create test project
run: |
mkdir -p test-project
cat > test-project/pyproject.toml << EOF
[project]
name = "test-project"
version = "0.1.0"
requires-python = ">=3.9"
dependencies = [
"requests>=2.31.0",
"pytest>=7.4.0",
]
EOF
- name: Install uv
working-directory: test-project
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
- name: Generate lock and platform-specific requirements
working-directory: test-project
run: |
export PATH="$HOME/.local/bin:$PATH"
uv sync
uv pip compile --python-platform=linux pyproject.toml -o requirements-linux.txt
- name: Test with custom requirements command
uses: ./
with:
pyproject-path: test-project/pyproject.toml
requirements-path: test-project/requirements-linux.txt
requirements-command: uv pip compile --python-platform=linux pyproject.toml -o requirements-linux.txt
test-requirements-failure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
- name: Run action (should fail)
id: action_step
continue-on-error: true
uses: ./
with:
pyproject-path: ./test-fixtures/requirements-out-of-sync/pyproject.toml
requirements-path: ./test-fixtures/requirements-out-of-sync/requirements.txt
requirements-command: uv sync --directory ./test-fixtures/requirements-out-of-sync
- name: Assert action failed
run: |
if [[ "${{ steps.action_step.outcome }}" == "success" ]]; then
echo "Expected action to fail, but it succeeded!"
exit 1
else
echo "Action failed as expected."
fi
test-multiple-requirements:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create test project
run: |
mkdir -p test-project
cat > test-project/pyproject.toml << EOF
[project]
name = "test-project"
version = "0.1.0"
requires-python = ">=3.9"
dependencies = [
"requests>=2.31.0",
"pytest>=7.4.0",
]
EOF
- name: Install uv
working-directory: test-project
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
- name: Print uv version
working-directory: test-project
run: |
export PATH="$HOME/.local/bin:$PATH"
uv --version
- name: Generate requirements-linux.txt
working-directory: test-project
run: |
export PATH="$HOME/.local/bin:$PATH"
uv pip compile --python-platform=linux pyproject.toml -o requirements-linux.txt
- name: Generate requirements-win.txt
working-directory: test-project
run: |
export PATH="$HOME/.local/bin:$PATH"
uv pip compile --python-platform=windows pyproject.toml -o requirements-win.txt
- name: Check Linux Requirements
uses: ./
with:
pyproject-path: test-project/pyproject.toml
requirements-command: uv pip compile --python-platform=linux pyproject.toml -o requirements-linux.txt
requirements-path: test-project/requirements-linux.txt
- name: Check Windows Requirements
uses: ./
with:
pyproject-path: test-project/pyproject.toml
requirements-command: uv pip compile --python-platform=windows pyproject.toml -o requirements-win.txt
requirements-path: test-project/requirements-win.txt
test-failure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
- name: Run action (should fail)
id: action_step
continue-on-error: true
uses: ./
with:
pyproject-path: ./test-fixtures/uv-lock-out-of-sync/pyproject.toml
requirements-path: ./test-fixtures/uv-lock-out-of-sync/requirements.txt
requirements-command: uv sync --directory ./test-fixtures/uv-lock-out-of-sync
- name: Assert action failed
run: |
if [[ "${{ steps.action_step.outcome }}" == "success" ]]; then
echo "Expected action to fail, but it succeeded!"
exit 1
else
echo "Action failed as expected."
fi
test-python-version-tilde:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
- name: Debug - List test-fixtures/python-version-tilde
run: |
pwd
ls -l ./test-fixtures/python-version-tilde
cat ./test-fixtures/python-version-tilde/pyproject.toml
- name: Run action
id: action_step
uses: ./
with:
pyproject-path: ./test-fixtures/python-version-tilde/pyproject.toml
requirements-command: uv sync --directory ./test-fixtures/python-version-tilde