Skip to content

Improve test workflow, add sync option, and enhance requirements checking #3

Improve test workflow, add sync option, and enhance requirements checking

Improve test workflow, add sync option, and enhance requirements checking #3

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: Generate lock file
working-directory: test-project
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
uv sync
- name: Test basic usage
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: Generate lock and requirements files
working-directory: test-project
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_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
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: Generate lock and platform-specific requirements
working-directory: test-project
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_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-failure:
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: Generate lock file
working-directory: test-project
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
uv sync
- name: Modify pyproject.toml to cause failure
working-directory: test-project
run: |
sed -i 's/requests>=2.31.0/requests>=2.32.0/' pyproject.toml
- name: Test failure case
uses: ./
continue-on-error: true
with:
pyproject-path: test-project/pyproject.toml
test-requirements-failure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup 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
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Generate requirements.txt
working-directory: test-project
run: |
uv sync
uv pip compile pyproject.toml -o requirements.txt
- name: Modify pyproject.toml
run: sed -i 's/pytest>=7.4.0/pytest>=7.5.0/' test-project/pyproject.toml
- name: Run action
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-uv-lock-failure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup 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
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Generate uv.lock
working-directory: test-project
run: uv sync
- name: Modify pyproject.toml
run: sed -i 's/pytest>=7.4.0/pytest>=7.5.0/' test-project/pyproject.toml
- name: Update uv.lock
working-directory: test-project
run: uv sync
- name: Run action
uses: ./
with:
pyproject-path: test-project/pyproject.toml