Fix (#3) #32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| 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 |