|
| 1 | +name: Workspace Validation |
| 2 | + |
| 3 | +# Pulse-owned workspace-integration validation (Stage 4 Phase B). |
| 4 | +# |
| 5 | +# This is the "heavy validation CI" that used to live in PyAutoBuild's |
| 6 | +# release.yml (find_scripts / run_scripts / analyze_results). Pulse owns it now: |
| 7 | +# Build is a pure executor. It runs every workspace's scripts against the CURRENT |
| 8 | +# source `main` of the 5 libraries (source-shadowed via PYTHONPATH), aggregates |
| 9 | +# into the same report.json contract, and uploads it as the |
| 10 | +# `workspace-validation-report` artifact. Pulse's test_run check reads that run's |
| 11 | +# conclusion + timestamp into the authoritative `readiness` verdict (with a |
| 12 | +# staleness window). |
| 13 | +# |
| 14 | +# Run mechanics (script_matrix.py / run_python.py / aggregate_results.py) are |
| 15 | +# Build's executor primitives — checked out from PyAutoBuild, not duplicated. |
| 16 | +# |
| 17 | +# Triggers: weekly schedule (the continuous readiness signal), manual dispatch, |
| 18 | +# and workflow_call (so a release path can invoke it on demand). Heavy, so never |
| 19 | +# in the <30s pulse tick. |
| 20 | + |
| 21 | +on: |
| 22 | + schedule: |
| 23 | + - cron: "0 3 * * 1" # Mondays 03:00 UTC |
| 24 | + workflow_dispatch: |
| 25 | + workflow_call: |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: read |
| 29 | + |
| 30 | +env: |
| 31 | + # Workspace pins lag the libraries' source __version__ between releases; |
| 32 | + # without this every script fails fast with WorkspaceVersionMismatchError. |
| 33 | + # Same bypass run_scripts uses in release.yml. |
| 34 | + PYAUTO_SKIP_WORKSPACE_VERSION_CHECK: "1" |
| 35 | + |
| 36 | +jobs: |
| 37 | + find_scripts: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + outputs: |
| 40 | + matrix: ${{ steps.script_matrix.outputs.matrix }} |
| 41 | + steps: |
| 42 | + - name: Checkout PyAutoBuild (run primitives) |
| 43 | + uses: actions/checkout@v4 |
| 44 | + with: |
| 45 | + repository: PyAutoLabs/PyAutoBuild |
| 46 | + path: PyAutoBuild |
| 47 | + - name: Clone workspaces (paths match script_matrix project names) |
| 48 | + run: | |
| 49 | + set -e |
| 50 | + declare -A WS=( |
| 51 | + [autofit]=autofit_workspace [autogalaxy]=autogalaxy_workspace [autolens]=autolens_workspace |
| 52 | + [autofit_test]=autofit_workspace_test [autogalaxy_test]=autogalaxy_workspace_test |
| 53 | + [autolens_test]=autolens_workspace_test |
| 54 | + [howtogalaxy]=HowToGalaxy [howtolens]=HowToLens [howtofit]=HowToFit |
| 55 | + ) |
| 56 | + for proj in "${!WS[@]}"; do |
| 57 | + git clone --depth 1 "https://github.com/PyAutoLabs/${WS[$proj]}" "$proj" |
| 58 | + done |
| 59 | + - name: Make script matrix |
| 60 | + id: script_matrix |
| 61 | + run: | |
| 62 | + matrix="$(python3 PyAutoBuild/autobuild/script_matrix.py \ |
| 63 | + autofit autogalaxy autolens autofit_test autogalaxy_test autolens_test \ |
| 64 | + howtogalaxy howtolens howtofit)" |
| 65 | + echo "matrix=$matrix" >> "$GITHUB_OUTPUT" |
| 66 | +
|
| 67 | + run_scripts: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + needs: find_scripts |
| 70 | + strategy: |
| 71 | + fail-fast: false |
| 72 | + matrix: |
| 73 | + python-version: ["3.12"] |
| 74 | + project: ${{ fromJSON(needs.find_scripts.outputs.matrix) }} |
| 75 | + steps: |
| 76 | + - name: Checkout PyAutoBuild (run primitives) |
| 77 | + uses: actions/checkout@v4 |
| 78 | + with: |
| 79 | + repository: PyAutoLabs/PyAutoBuild |
| 80 | + path: PyAutoBuild |
| 81 | + - name: Resolve workspace repo for ${{ matrix.project.name }} |
| 82 | + id: ws |
| 83 | + run: | |
| 84 | + case "${{ matrix.project.name }}" in |
| 85 | + autofit) echo "repo=autofit_workspace" >> "$GITHUB_OUTPUT" ;; |
| 86 | + autogalaxy) echo "repo=autogalaxy_workspace" >> "$GITHUB_OUTPUT" ;; |
| 87 | + autolens) echo "repo=autolens_workspace" >> "$GITHUB_OUTPUT" ;; |
| 88 | + autofit_test) echo "repo=autofit_workspace_test" >> "$GITHUB_OUTPUT" ;; |
| 89 | + autogalaxy_test) echo "repo=autogalaxy_workspace_test" >> "$GITHUB_OUTPUT" ;; |
| 90 | + autolens_test) echo "repo=autolens_workspace_test" >> "$GITHUB_OUTPUT" ;; |
| 91 | + howtogalaxy) echo "repo=HowToGalaxy" >> "$GITHUB_OUTPUT" ;; |
| 92 | + howtolens) echo "repo=HowToLens" >> "$GITHUB_OUTPUT" ;; |
| 93 | + howtofit) echo "repo=HowToFit" >> "$GITHUB_OUTPUT" ;; |
| 94 | + *) echo "repo=autolens_workspace_test" >> "$GITHUB_OUTPUT" ;; |
| 95 | + esac |
| 96 | + - name: Checkout workspace |
| 97 | + uses: actions/checkout@v4 |
| 98 | + with: |
| 99 | + repository: PyAutoLabs/${{ steps.ws.outputs.repo }} |
| 100 | + ref: main |
| 101 | + path: workspace |
| 102 | + - name: Checkout libraries (current main; source-shadowed via PYTHONPATH) |
| 103 | + run: | |
| 104 | + set -e |
| 105 | + for lib in PyAutoConf PyAutoArray PyAutoFit PyAutoGalaxy PyAutoLens; do |
| 106 | + git clone --depth 1 "https://github.com/PyAutoLabs/$lib" "libs/$lib" |
| 107 | + done |
| 108 | + - name: Set up Python ${{ matrix.python-version }} |
| 109 | + uses: actions/setup-python@v5 |
| 110 | + with: |
| 111 | + python-version: ${{ matrix.python-version }} |
| 112 | + cache: pip |
| 113 | + - name: Install third-party deps (libs run from source) |
| 114 | + run: | |
| 115 | + # Pull the full transitive dependency set (matplotlib/numba/jax/…) by |
| 116 | + # installing the published autolens[optional]; the source checkouts |
| 117 | + # below shadow the PyAuto packages via PYTHONPATH. |
| 118 | + pip install "autolens[optional]" |
| 119 | + pip install "jax>=0.7,<0.11" "jaxlib>=0.7,<0.11" |
| 120 | + - name: Run Python scripts |
| 121 | + run: | |
| 122 | + LIBS="$(pwd)/libs" |
| 123 | + export PYTHONPATH="$LIBS/PyAutoConf:$LIBS/PyAutoArray:$LIBS/PyAutoFit:$LIBS/PyAutoGalaxy:$LIBS/PyAutoLens:$(pwd)/PyAutoBuild:$PYTHONPATH" |
| 124 | + pushd workspace |
| 125 | + python3 "$(pwd)/../PyAutoBuild/autobuild/run_python.py" \ |
| 126 | + "${{ matrix.project.name }}" "scripts/${{ matrix.project.directory }}" \ |
| 127 | + --report-dir test-results |
| 128 | + - name: Upload script results |
| 129 | + if: always() |
| 130 | + uses: actions/upload-artifact@v4 |
| 131 | + with: |
| 132 | + name: results-scripts-${{ matrix.project.name }}-${{ matrix.project.directory }} |
| 133 | + path: workspace/test-results/ |
| 134 | + retention-days: 30 |
| 135 | + |
| 136 | + analyze: |
| 137 | + runs-on: ubuntu-latest |
| 138 | + needs: run_scripts |
| 139 | + if: always() |
| 140 | + steps: |
| 141 | + - name: Checkout PyAutoBuild (aggregate_results) |
| 142 | + uses: actions/checkout@v4 |
| 143 | + with: |
| 144 | + repository: PyAutoLabs/PyAutoBuild |
| 145 | + path: PyAutoBuild |
| 146 | + - name: Set up Python |
| 147 | + uses: actions/setup-python@v5 |
| 148 | + with: |
| 149 | + python-version: "3.12" |
| 150 | + - name: Download all result artifacts |
| 151 | + uses: actions/download-artifact@v4 |
| 152 | + with: |
| 153 | + path: all-results |
| 154 | + pattern: results-* |
| 155 | + merge-multiple: true |
| 156 | + - name: Aggregate into report.json |
| 157 | + run: | |
| 158 | + export PYTHONPATH="$PYTHONPATH:$(pwd)/PyAutoBuild" |
| 159 | + python3 PyAutoBuild/autobuild/aggregate_results.py all-results/ \ |
| 160 | + --output report.json --markdown report.md |
| 161 | + - name: Post summary |
| 162 | + if: always() |
| 163 | + run: cat report.md >> "$GITHUB_STEP_SUMMARY" || true |
| 164 | + - name: Upload report (consumed by pyauto-pulse readiness) |
| 165 | + if: always() |
| 166 | + uses: actions/upload-artifact@v4 |
| 167 | + with: |
| 168 | + name: workspace-validation-report |
| 169 | + path: | |
| 170 | + report.json |
| 171 | + report.md |
| 172 | + retention-days: 90 |
| 173 | + - name: Fail the run if validation is not ready |
| 174 | + run: | |
| 175 | + python3 -c "import json,sys; sys.exit(0 if json.load(open('report.json')).get('ready') else 1)" |
0 commit comments