diff --git a/.github/workflows/vendoring.yml b/.github/workflows/vendoring.yml new file mode 100644 index 0000000..fa37aae --- /dev/null +++ b/.github/workflows/vendoring.yml @@ -0,0 +1,43 @@ +name: Python Workers Vendoring CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + vendoring: + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Install Wrangler + run: npm install -g wrangler + + - name: Run vendoring script (Linux/macOS) + if: runner.os != 'Windows' + run: ./.github/workflows/vendoring/unix.sh + shell: bash + + - name: Run vendoring script (Windows) + if: runner.os == 'Windows' + continue-on-error: true + run: .github\workflows\vendoring\windows.bat \ No newline at end of file diff --git a/.github/workflows/vendoring/unix.sh b/.github/workflows/vendoring/unix.sh new file mode 100755 index 0000000..d84ed91 --- /dev/null +++ b/.github/workflows/vendoring/unix.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +cd 06-vendoring +python3.12 -m venv .venv +source .venv/bin/activate +.venv/bin/pip install pyodide-build +.venv/bin/pyodide venv .venv-pyodide +.venv-pyodide/bin/pip install -t src/vendor -r vendor.txt + +if [ -z "$(ls -A src/vendor)" ]; then + echo "Vendoring failed: No files in src/vendor" + exit 1 +fi + +wrangler deploy --dry-run + +echo "Vendoring succeeded, listing files in src/vendor..." +command -v tree &>/dev/null && tree src/vendor || find src/vendor \ No newline at end of file diff --git a/.github/workflows/vendoring/windows.bat b/.github/workflows/vendoring/windows.bat new file mode 100644 index 0000000..81676be --- /dev/null +++ b/.github/workflows/vendoring/windows.bat @@ -0,0 +1,18 @@ +@echo off + +cd 06-vendoring +python -m venv .venv +call .venv\Scripts\activate +.venv\Scripts\pip install pyodide-build +.venv\Scripts\pyodide venv .venv-pyodide +.venv-pyodide\Scripts\pip install -t src/vendor -r vendor.txt + +if not exist src\vendor\* ( + echo Vendoring failed: No files in src/vendor + exit /b 1 +) + +wrangler deploy --dry-run + +echo Vendoring succeeded, listing files in src/vendor... +tree /f /a src\vendor \ No newline at end of file diff --git a/06-vendoring/README.md b/06-vendoring/README.md index ca4482a..1395fd8 100644 --- a/06-vendoring/README.md +++ b/06-vendoring/README.md @@ -12,6 +12,8 @@ Vendored packages are added to your source files and need to be installed in a s ### Vendoring Packages +[//]: # (NOTE: when updating the instructions below, be sure to also update the vendoring.yml CI workflow) + First, install Python3.12 and pip for Python 3.12. *Currently, other versions of Python will not work - use 3.12!*