1+ name : Complete Clone Test BayesFlow
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ repo :
7+ description : ' Repository to fetch (owner/repo)'
8+ required : true
9+ default : ' bayesflow-org/bayesflow'
10+ branch :
11+ description : ' Branch to fetch from'
12+ required : true
13+ default : ' main'
14+ python_versions :
15+ description : ' Python versions to test (comma-separated)'
16+ required : true
17+ default : ' 3.10.8'
18+ type : string
19+ operating_systems :
20+ description : ' Operating systems to test'
21+ required : true
22+ default : ' ubuntu'
23+ type : choice
24+ options :
25+ - ubuntu
26+ - windows
27+ - macos
28+ - all
29+ backends :
30+ description : ' Backends to test (comma-separated)'
31+ required : true
32+ default : ' tensorflow'
33+ type : string
34+ pytest_command :
35+ description : ' Custom pytest command to run'
36+ required : false
37+ default : ' python -m pytest tests/test_approximators/test_approximator_standardization/test_approximator_standardization.py'
38+ type : string
39+ pull_request :
40+ branches :
41+ - ' **'
42+ push :
43+ branches :
44+ - force_test
45+
46+ defaults :
47+ run :
48+ shell : bash
49+
50+
51+ env :
52+ DEFAULT_PYTEST_CMD : ' python -m pytest tests/test_approximators/test_approximator_standardization/test_approximator_standardization.py'
53+
54+ jobs :
55+ prepare-matrix :
56+ runs-on : ubuntu-latest
57+ outputs :
58+ matrix : ${{ steps.set-matrix.outputs.matrix }}
59+ steps :
60+ - name : Set up matrix
61+ id : set-matrix
62+ run : |
63+ echo "Event name: ${{ github.event_name }}"
64+ echo "Inputs: repo=${{ github.event.inputs.repo }}, operating_systems=${{ github.event.inputs.operating_systems }}, python_versions=${{ github.event.inputs.python_versions }}, backends=${{ github.event.inputs.backends }}"
65+
66+ # Default values when not triggered manually
67+ if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
68+ echo "Using default matrix for non-manual trigger"
69+ echo 'matrix={"os":["ubuntu-latest"],"python-version":["3.10.8"],"backend":["tensorflow"]}' >> $GITHUB_OUTPUT
70+ else
71+ echo "Building matrix from workflow_dispatch inputs"
72+
73+ # Parse operating systems
74+ OS_INPUT="${{ github.event.inputs.operating_systems }}"
75+ echo "OS_INPUT: '$OS_INPUT'"
76+ case "$OS_INPUT" in
77+ "ubuntu")
78+ OS_LIST="\"ubuntu-latest\""
79+ ;;
80+ "windows")
81+ OS_LIST="\"windows-latest\""
82+ ;;
83+ "macos")
84+ OS_LIST="\"macos-latest\""
85+ ;;
86+ "all")
87+ OS_LIST="\"ubuntu-latest\",\"windows-latest\",\"macos-latest\""
88+ ;;
89+ *)
90+ OS_LIST="\"ubuntu-latest\""
91+ ;;
92+ esac
93+ echo "OS_LIST: $OS_LIST"
94+
95+ # Parse Python versions (comma-separated)
96+ PYTHON_INPUT="${{ github.event.inputs.python_versions }}"
97+ echo "PYTHON_INPUT: '$PYTHON_INPUT'"
98+ PYTHON_LIST=""
99+ IFS=',' read -ra PYTHON_ARRAY <<< "$PYTHON_INPUT"
100+ for version in "${PYTHON_ARRAY[@]}"; do
101+ # Trim whitespace
102+ version=$(echo "$version" | xargs)
103+ echo "Processing Python version: '$version'"
104+ # Validate version
105+ if [[ "$version" =~ ^3\.(10|11|12)(\.[0-9]+)?$ ]]; then
106+ if [ -n "$PYTHON_LIST" ]; then
107+ PYTHON_LIST="$PYTHON_LIST,\"$version\""
108+ else
109+ PYTHON_LIST="\"$version\""
110+ fi
111+ else
112+ echo "Invalid Python version: '$version'"
113+ fi
114+ done
115+ # Fallback if no valid versions
116+ if [ -z "$PYTHON_LIST" ]; then
117+ PYTHON_LIST="\"3.10\""
118+ echo "No valid Python versions found, using fallback"
119+ fi
120+ echo "PYTHON_LIST: $PYTHON_LIST"
121+
122+ # Parse backends (comma-separated)
123+ BACKEND_INPUT="${{ github.event.inputs.backends }}"
124+ echo "BACKEND_INPUT: '$BACKEND_INPUT'"
125+ BACKEND_LIST=""
126+ IFS=',' read -ra BACKEND_ARRAY <<< "$BACKEND_INPUT"
127+ for backend in "${BACKEND_ARRAY[@]}"; do
128+ # Trim whitespace
129+ backend=$(echo "$backend" | xargs)
130+ echo "Processing backend: '$backend'"
131+ # Validate backend
132+ if [[ "$backend" =~ ^(tensorflow|jax|torch|numpy)$ ]]; then
133+ if [ -n "$BACKEND_LIST" ]; then
134+ BACKEND_LIST="$BACKEND_LIST,\"$backend\""
135+ else
136+ BACKEND_LIST="\"$backend\""
137+ fi
138+ else
139+ echo "Invalid backend: '$backend'"
140+ fi
141+ done
142+ # Fallback if no valid backends
143+ if [ -z "$BACKEND_LIST" ]; then
144+ BACKEND_LIST="\"tensorflow\""
145+ echo "No valid backends found, using fallback"
146+ fi
147+ echo "BACKEND_LIST: $BACKEND_LIST"
148+
149+ MATRIX_JSON="{\"os\":[$OS_LIST],\"python-version\":[$PYTHON_LIST],\"backend\":[$BACKEND_LIST]}"
150+ echo "Generated matrix: $MATRIX_JSON"
151+ echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
152+ fi
153+
154+ test :
155+ needs : prepare-matrix
156+ name : Run Tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} and ${{ matrix.backend }} backend
157+
158+ strategy :
159+ matrix : ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
160+
161+ runs-on : ${{ matrix.os }}
162+
163+ env :
164+ KERAS_BACKEND : ${{ matrix.backend }}
165+
166+ steps :
167+ - name : 🎯 Display Matrix Configuration
168+ run : |
169+ echo "╔════════════════════════════════════════════════════════════════════════════════╗"
170+ echo "║ 🚀 MATRIX CONFIGURATION 🚀 ║"
171+ echo "╠════════════════════════════════════════════════════════════════════════════════╣"
172+ echo "║ 🖥️ Operating System: ${{ matrix.os }}"
173+ echo "║ 🐍 Python Version: ${{ matrix.python-version }}"
174+ echo "║ ⚡ Backend: ${{ matrix.backend }}"
175+ echo "║ 🎭 Event Type: ${{ github.event_name }}"
176+ echo "╚════════════════════════════════════════════════════════════════════════════════╝"
177+ echo ""
178+ echo "🔍 Matrix Debug Info:"
179+ echo " - Job Name: Run Tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} and ${{ matrix.backend }} backend"
180+ echo " - Runner OS: ${{ runner.os }}"
181+ echo " - KERAS_BACKEND env: ${{ env.KERAS_BACKEND }}"
182+ echo ""
183+
184+ - name : Checkout Repository
185+ uses : actions/checkout@v4
186+
187+ - name : Complete clone of bayesflow repository
188+ shell : bash
189+ run : |
190+ set -e
191+ # Use input values if available, otherwise use defaults
192+ REPO="${{ github.event.inputs.repo || 'bayesflow-org/bayesflow' }}"
193+ BRANCH="${{ github.event.inputs.branch || 'main' }}"
194+
195+ echo "Cloning complete ${REPO} repository from branch ${BRANCH}"
196+
197+ # Remove any existing directory
198+ rm -rf external/bayesflow
199+
200+ # Clone the complete repository
201+ git clone --single-branch --branch ${BRANCH} https://github.com/${REPO}.git external/bayesflow
202+
203+ echo "Successfully cloned ${REPO}@${BRANCH}"
204+
205+ # Verify we have the necessary files
206+ echo "Contents of bayesflow directory:"
207+ ls -la external/bayesflow/
208+
209+ echo "Checking for tests directory:"
210+ if [[ -d "external/bayesflow/tests" ]]; then
211+ echo "✅ Tests directory found"
212+ ls -la external/bayesflow/tests/ | head -5
213+ else
214+ echo "❌ Tests directory not found"
215+ fi
216+
217+
218+ - name : Set up Python
219+ uses : actions/setup-python@v5
220+ with :
221+ python-version : ${{ matrix.python-version }}
222+
223+ - name : Cache pip
224+ uses : actions/cache@v4
225+ with :
226+ path : ./.pip_cache
227+ key : ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/uv.lock') }}
228+ restore-keys : |
229+ ${{ runner.os }}-pip-${{ matrix.python-version }}-
230+
231+ - name : Install uv
232+ shell : bash
233+ run : |
234+ curl -LsSf https://astral.sh/uv/install.sh | sh
235+ if [[ "${{ runner.os }}" == "Windows" ]]; then
236+ echo "$HOME/.local/bin" >> $GITHUB_PATH
237+ else
238+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
239+ fi
240+ # Source the path for immediate use
241+ export PATH="$HOME/.cargo/bin:$PATH"
242+
243+ - name : Install external bayesflow package with all dependencies
244+ shell : bash
245+ run : |
246+ set -e
247+ cd external/bayesflow
248+ # Verify the directory has the expected files
249+ ls -la
250+ if [[ -f "pyproject.toml" || -f "setup.py" || -f "setup.cfg" ]]; then
251+ echo "Installing bayesflow with all dependencies..."
252+ uv pip install --system ".[all]"
253+
254+ echo "Ensuring TensorFlow is properly installed..."
255+ uv pip install --system tensorflow
256+
257+ echo "Verifying TensorFlow installation..."
258+ python -c "import tensorflow as tf; print(f'TensorFlow version: {tf.__version__}')"
259+ else
260+ echo "Error: No setup files found in bayesflow directory"
261+ exit 1
262+ fi
263+ cd -
264+
265+ - name : 📋 Show Environment Info
266+ run : |
267+ echo "╔════════════════════════════════════════════════════════════════════════════════╗"
268+ echo "║ 📋 ENVIRONMENT INFORMATION 📋 ║"
269+ echo "╠════════════════════════════════════════════════════════════════════════════════╣"
270+ echo "║ 🐍 Python Version: $(python --version)"
271+ echo "║ 📦 Pip Version: $(python -m pip --version)"
272+ echo "║ ⚡ Backend: $KERAS_BACKEND"
273+ echo "║ 🖥️ OS: ${{ runner.os }}"
274+ echo "║ 💻 Architecture: $(uname -m 2>/dev/null || echo 'N/A')"
275+ echo "╚════════════════════════════════════════════════════════════════════════════════╝"
276+ echo ""
277+ echo "🔍 Installed packages:"
278+ python -m pip list
279+ python -m pip freeze > packages_.txt
280+
281+ - name : Upload packages list artifact
282+ uses : actions/upload-artifact@v4
283+ with :
284+ name : packages-list-${{ matrix.os }}-${{ matrix.backend }}
285+ path : packages_.txt
286+ retention-days : 10
287+
288+ - name : Run Tests
289+ shell : bash
290+ run : |
291+ set -e
292+ echo "Current directory contents:"
293+ ls -la
294+
295+ echo "Checking external/bayesflow structure:"
296+ if [[ -d "external/bayesflow" ]]; then
297+ echo "Contents of external/bayesflow:"
298+ ls -la external/bayesflow/
299+
300+ echo "Changing to bayesflow directory to run tests..."
301+ cd external/bayesflow
302+
303+ echo "Exploring directory structure to find tests:"
304+ echo "Contents of current directory:"
305+ ls -la
306+
307+ echo "Looking for test directories:"
308+ find . -name "*test*" -type d | head -10
309+
310+ echo "Looking for the specific test file:"
311+ find . -name "*approximator_standardization*" -type f | head -5
312+
313+ echo "Checking if bayesflow subdirectory has tests:"
314+ if [[ -d "bayesflow" ]]; then
315+ echo "Contents of bayesflow subdirectory:"
316+ ls -la bayesflow/
317+ if [[ -d "bayesflow/tests" ]]; then
318+ echo "Found bayesflow/tests directory:"
319+ ls -la bayesflow/tests/ | head -10
320+ fi
321+ fi
322+
323+ echo "Running tests with backend: $KERAS_BACKEND"
324+
325+ # Use custom pytest command from input or default
326+ PYTEST_CMD="${{ github.event.inputs.pytest_command || env.DEFAULT_PYTEST_CMD }}"
327+ echo "Executing: $PYTEST_CMD"
328+ eval "$PYTEST_CMD"
329+ else
330+ echo "Error: external/bayesflow directory not found!"
331+ exit 1
332+ fi
333+
0 commit comments