Skip to content

Commit 78ce5d7

Browse files
committed
Test 6
Signed-off-by: Jing Chen <[email protected]>
1 parent aae5358 commit 78ce5d7

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

.github/workflows/run-examples-jing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,5 @@ jobs:
9999
git config --local user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
100100
git status
101101
git add tests/results/
102-
git diff --cached --quiet || git commit -m "GH Action updated results file when running examples $(date)"
102+
git diff --cached --quiet || git commit -m "github-actions[bot]: Updated results file when running examples on $(date)"
103103
git push

.github/workflows/run-examples.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ jobs:
6464
6565
# Run tests
6666
- uses: actions/checkout@v4
67+
with:
68+
ref: ${{ github.head_ref }}
6769
- name: Set up Python ${{ matrix.python-version }}
6870
uses: actions/setup-python@v5
6971
with:
@@ -93,4 +95,12 @@ jobs:
9395
WATSONX_URL: ${{ secrets.WATSONX_URL }}
9496
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
9597
OLLAMA_GHACTIONS_RESULTS: true
96-
run: py.test -v --capture=tee-sys -rfE -s tests/test_examples_run.py
98+
run: py.test -v --capture=tee-sys -rfE -s tests/test_examples_run.py
99+
- name: Update example result files (if any) generated from Ollama running on GH Actions
100+
run: |
101+
git config --local user.name github-actions[bot]
102+
git config --local user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
103+
git status
104+
git add tests/results/
105+
git diff --cached --quiet || git commit -m "github-actions[bot]: Updated results file when running examples on $(date)"
106+
git push

tests/test_examples_run.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# test_examples_run.py runs the examples and compares the results
1717
# to the expected results in tests/results/examples
1818

19-
UPDATE_RESULTS = True
19+
UPDATE_RESULTS = False
2020
RESULTS_VERSION = 1
2121
OLLAMA_GHACTIONS_RESULTS_ENV_VAR = os.getenv("OLLAMA_GHACTIONS_RESULTS", "")
2222
OLLAMA_GHACTIONS_RESULTS = False
@@ -191,28 +191,34 @@ def test_valid_programs(capsys: CaptureFixture[str], monkeypatch: MonkeyPatch) -
191191
output="all",
192192
config=pdl.InterpreterConfig(batch=0),
193193
)
194-
result = output["result"]
194+
actual_result = output["result"]
195195

196196
block_to_dict(output["trace"], json_compatible=True)
197197
result_dir_name = (
198198
pathlib.Path(".") / "tests" / "results" / pdl_file_name.parent
199199
)
200200

201-
if not __find_and_compare_results(pdl_file_name, str(result)):
201+
if not __find_and_compare_results(pdl_file_name, str(actual_result)):
202202

203203
if OLLAMA_GHACTIONS_RESULTS:
204204
print(
205-
"-------------------- Updating result from running Ollama on GitHub Actions -------------------- "
205+
f"Program {str(pdl_file_name)} requries updating its result on GitHub Actions"
206206
)
207+
print(f"Actual results: {str(actual_result)}")
207208
result_file_name = f"{pdl_file_name.stem}.ollama_ghactions.result"
208209
__write_to_results_file(
209-
result_dir_name, result_file_name, str(result)
210+
result_dir_name, result_file_name, str(actual_result)
210211
)
211212

212213
# Evaluate the results again. If fails again, then consider this program as failing
213-
if not __find_and_compare_results(pdl_file_name, str(result)):
214+
if not __find_and_compare_results(
215+
pdl_file_name, str(actual_result)
216+
):
217+
print(
218+
f"Program {str(pdl_file_name)} failed second time even after generating results from Github Actions. Consider this failing!"
219+
)
214220
wrong_results[str(pdl_file_name)] = {
215-
"actual": str(result),
221+
"actual": str(actual_result),
216222
}
217223
# If evaluating results produces correct result, then this is considered passing
218224
else:
@@ -223,11 +229,11 @@ def test_valid_programs(capsys: CaptureFixture[str], monkeypatch: MonkeyPatch) -
223229
f"{pdl_file_name.stem}.{str(RESULTS_VERSION)}.result"
224230
)
225231
__write_to_results_file(
226-
result_dir_name, result_file_name, str(result)
232+
result_dir_name, result_file_name, str(actual_result)
227233
)
228234

229235
wrong_results[str(pdl_file_name)] = {
230-
"actual": str(result),
236+
"actual": str(actual_result),
231237
}
232238
except PDLParseError:
233239
actual_parse_error |= {str(pdl_file_name)}

tests/test_examples_run_jing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# test_examples_run.py runs the examples and compares the results
1717
# to the expected results in tests/results/examples
1818

19-
UPDATE_RESULTS = True
19+
UPDATE_RESULTS = False
2020
RESULTS_VERSION = 1
2121
OLLAMA_GHACTIONS_RESULTS_ENV_VAR = os.getenv("OLLAMA_GHACTIONS_RESULTS", "")
2222
OLLAMA_GHACTIONS_RESULTS = False

0 commit comments

Comments
 (0)