Skip to content

Commit c3baa9d

Browse files
committed
Workflow test
Signed-off-by: Jing Chen <[email protected]>
1 parent ef3ddd1 commit c3baa9d

File tree

4 files changed

+103
-3
lines changed

4 files changed

+103
-3
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
name: Run examples
3+
4+
on: [push, pull_request]
5+
6+
7+
jobs:
8+
tests:
9+
name: Execution tests
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
# python-version: ['3.11', '3.12', '3.13']
15+
python-version: ['3.11']
16+
17+
steps:
18+
19+
# # Free up some disk space
20+
# - name: Remove unnecessary files
21+
# run: |
22+
# sudo rm -rf /usr/share/dotnet
23+
# sudo rm -rf "$AGENT_TOOLSDIRECTORY"
24+
25+
# # Set up Ollama
26+
# - name: Install Ollama and start server
27+
# shell: bash
28+
# run: |
29+
# curl -fsSL https://ollama.com/install.sh | sudo -E sh
30+
31+
# - name: Pull models in examples/
32+
# shell: bash
33+
# run: |
34+
# ollama pull granite3.2:2b
35+
# ollama pull mxbai-embed-large
36+
# ollama list
37+
38+
# - name: Check that all required models are available
39+
# shell: bash
40+
# run: |
41+
# models=("mxbai-embed-large" "granite3.2:2b")
42+
# missing=0
43+
# for model in "${models[@]}"; do
44+
# if ! ollama list | awk 'NR>1 {print $1}' | grep -q "$model"; then
45+
# echo "❌ Model $model (or substring) is missing!"
46+
# missing=1
47+
# fi
48+
# done
49+
50+
# if [ "$missing" -eq 1 ]; then
51+
# exit 1
52+
# else
53+
# echo "✅ All expected models are available."
54+
# fi
55+
56+
# - name: Wait for Ollama server
57+
# shell: bash
58+
# run: |
59+
# sleep 10
60+
# time curl -i http://localhost:11434
61+
62+
# Run tests
63+
- uses: actions/checkout@v4
64+
- name: Set up Python ${{ matrix.python-version }}
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: ${{ matrix.python-version }}
68+
- name: Cache pip
69+
uses: actions/cache@v4
70+
with:
71+
# This path is specific to Ubuntu
72+
path: ${{ env.pythonLocation }}
73+
# Look to see if there is a cache hit for the setup file
74+
key: ${{ runner.os }}-pip-new3-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
75+
restore-keys: |
76+
${{ runner.os }}-pip-new3
77+
${{ runner.os }}-new3
78+
- name: Install dependencies
79+
run: pip install --upgrade --upgrade-strategy eager .[all]
80+
- name: pip list packages
81+
run: pip list
82+
- name: show pip dependencies
83+
run: |
84+
pip install pipdeptree
85+
pipdeptree -fl
86+
- name: run tests
87+
env:
88+
WATSONX_PROJECT_ID: ${{ secrets.WATSONX_PROJECT_ID }}
89+
WATSONX_APIKEY: ${{ secrets.WATSONX_APIKEY }}
90+
WATSONX_URL: ${{ secrets.WATSONX_URL }}
91+
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
92+
run: python env_test.py

.github/workflows/run-examples.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,5 @@ jobs:
9191
WATSONX_APIKEY: ${{ secrets.WATSONX_APIKEY }}
9292
WATSONX_URL: ${{ secrets.WATSONX_URL }}
9393
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
94-
run: py.test -v --capture=tee-sys -rfE -s tests/test_examples_run.py
94+
OLLAMA_GHACTIONS_RESULTS: True
95+
run: python env_test.py

env_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import os
2+
3+
print(os.getenv("OLLAMA_GHACTIONS_RESULTS"))
4+
print(os.getenv("OLLAMA_GHACTIONS_RESULTS") == True)

tests/test_examples_run.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import io
2+
import os
23
import pathlib
34
import random
45
from dataclasses import dataclass
@@ -16,9 +17,11 @@
1617
# to the expected results in tests/results/examples
1718

1819
UPDATE_RESULTS = True
19-
# OLLAMA_GHACTIONS_RESULTS = os.getenv("OLLAMA_GHACTIONS_RESULTS", False)
20-
OLLAMA_GHACTIONS_RESULTS = False
2120
RESULTS_VERSION = 1
21+
OLLAMA_GHACTIONS_RESULTS_ENV_VAR = os.getenv("OLLAMA_GHACTIONS_RESULTS", "False")
22+
OLLAMA_GHACTIONS_RESULTS = False
23+
if OLLAMA_GHACTIONS_RESULTS_ENV_VAR.lower().strip() == "true":
24+
OLLAMA_GHACTIONS_RESULTS = True
2225

2326
TO_SKIP = {
2427
str(name)

0 commit comments

Comments
 (0)