Sync Requirements #63
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: Sync Requirements | |
| on: | |
| push: | |
| paths: | |
| - 'pyproject.toml' # Single source of truth | |
| - '.github/workflows/sync-requirements.yml' | |
| branches: ['**'] # Run on all branches | |
| schedule: | |
| - cron: '0 0 1 * *' # Monthly on the 1st | |
| workflow_dispatch: | |
| jobs: | |
| sync-requirements: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Cache pip packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-sync-${{ hashFiles('pyproject.toml') }} | |
| - name: Install pip-tools and dependencies | |
| run: | | |
| pip install --upgrade pip | |
| pip install pip-tools pyyaml | |
| - name: Sync requirements.txt from pyproject.toml | |
| run: pip-compile pyproject.toml --output-file=requirements.txt --resolver=backtracking | |
| - name: Sync requirements-dev.lock from pyproject.toml | |
| run: pip-compile --extra=dev pyproject.toml --output-file=requirements-dev.lock --resolver=backtracking | |
| - name: Sync docs/requirements.txt from pyproject.toml | |
| run: pip-compile --extra=docs pyproject.toml --output-file=docs/requirements.txt --resolver=backtracking | |
| - name: Update conda environment from lockfile | |
| run: | | |
| python scripts/requirements_to_conda_env.py requirements.txt --name solarwindpy --overwrite | |
| echo "CONDA_ENV_FILE=solarwindpy.yml" >> $GITHUB_ENV | |
| - name: Validate generated lockfiles | |
| run: | | |
| echo "Validating requirements.txt..." | |
| python -m pip install --dry-run -r requirements.txt | |
| echo "Validating requirements-dev.lock..." | |
| python -m pip install --dry-run -r requirements-dev.lock | |
| echo "Validating docs/requirements.txt..." | |
| python -m pip install --dry-run -r docs/requirements.txt | |
| echo "Validating conda environment..." | |
| if command -v conda &> /dev/null; then | |
| conda env create -f solarwindpy.yml --dry-run | |
| fi | |
| continue-on-error: true | |
| - name: Check for changes | |
| id: verify-changed-files | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Files changed:" | |
| git status --porcelain | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "No files changed" | |
| fi | |
| - name: Create Pull Request | |
| if: steps.verify-changed-files.outputs.changed == 'true' | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: | | |
| chore: auto-sync lockfiles from pyproject.toml | |
| - Updated requirements.txt (production dependencies) | |
| - Updated requirements-dev.lock (development dependencies) | |
| - Updated docs/requirements.txt (documentation dependencies) | |
| - Updated conda environment: solarwindpy.yml | |
| - Auto-generated via pip-compile from pyproject.toml | |
| title: "chore: Sync dependency lockfiles from pyproject.toml" | |
| body: | | |
| ## Automated Lockfile Synchronization | |
| This PR was automatically generated by the sync-requirements workflow. | |
| ### Changes: | |
| - **requirements.txt** - Production dependencies from `[project.dependencies]` | |
| - **requirements-dev.lock** - Development dependencies from `[project.optional-dependencies.dev]` | |
| - **docs/requirements.txt** - Documentation dependencies from `[project.optional-dependencies.docs]` | |
| - **solarwindpy.yml** - Conda environment generated from requirements.txt | |
| ### Source: | |
| Generated via `pip-compile` from `pyproject.toml` changes. | |
| ### Validation: | |
| All lockfiles validated with `pip install --dry-run`. | |
| branch: auto-update-requirements | |
| delete-branch: true | |
| labels: | | |
| dependencies | |
| automated |