Skip to content

Introducing Run Examples check in PRs #908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2ffa89a
Pr pipeline 2 (#5)
jgchn Apr 12, 2025
54b6ab2
Update contrib readme
jgchn Apr 12, 2025
ec0a031
Get test results for nightly run
jgchn Apr 12, 2025
a745413
Update results on all files
jgchn Apr 12, 2025
b7cda95
Small fix
jgchn Apr 13, 2025
8e6d9de
Rm dependency on yaml actions
jgchn Apr 13, 2025
dc216c9
Add repo to checkout
jgchn Apr 13, 2025
c76a2a1
Update checkout ref
jgchn Apr 13, 2025
f4bd8fa
Dont check out again
jgchn Apr 13, 2025
7a6a69e
Rm another checkout
jgchn Apr 13, 2025
1bce474
Rm checkout refs
jgchn Apr 13, 2025
63830c4
Fix yq
jgchn Apr 13, 2025
20445b5
Configure git and try again
jgchn Apr 13, 2025
cfcae08
Fix source repo name
jgchn Apr 13, 2025
dc314fc
Checkout fix
jgchn Apr 13, 2025
559b926
Fix ref
jgchn Apr 13, 2025
79da481
github-actions[bot]: Run examples: reverting update_result to false o…
github-actions[bot] Apr 14, 2025
2457314
Try push again
jgchn Apr 14, 2025
a2538e1
Merge branch 'pr' of https://github.com/jgchn/prompt-declaration-lang…
jgchn Apr 14, 2025
7cd24ca
Fix update results bool
jgchn Apr 14, 2025
e21bbd1
Try another push
jgchn Apr 14, 2025
f5232cc
Try using secrets
jgchn Apr 14, 2025
d601797
github-actions[bot]: Run examples: reverting update_result to false o…
github-actions[bot] Apr 14, 2025
af5e740
Don't use composite action in pr
jgchn Apr 14, 2025
7cc677f
Merge branch 'pr' of https://github.com/jgchn/prompt-declaration-lang…
jgchn Apr 14, 2025
3905db1
Refine bool comparison
jgchn Apr 14, 2025
fec39b1
Don't cache ollama
jgchn Apr 15, 2025
85618bd
Add patch yaml step
jgchn Apr 15, 2025
6db7ba3
Test if PAT works
jgchn Apr 18, 2025
74410bc
Merge remote-tracking branch 'upstream/main' into pr
jgchn Apr 18, 2025
7c90638
Add checkout step
jgchn Apr 18, 2025
42133d6
Checkout modification
jgchn Apr 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/actions/ollama/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: 'Ollama Setup'
description: 'Composte action for Ollama set up in GH environment'
runs:
using: 'composite'
steps:
- name: Remove unnecessary files
shell: bash
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf "$AGENT_TOOLSDIRECTORY"

# Set up Ollama
- name: Install Ollama and start server
shell: bash
run: |
curl -fsSL https://ollama.com/install.sh | sudo -E sh

- name: Pull models in examples/
shell: bash
run: |
ollama pull granite3.2:2b
ollama pull granite3.2:8b
ollama pull mxbai-embed-large
ollama list

- name: Check that all required models are available
shell: bash
run: |
models=("mxbai-embed-large" "granite3.2:2b" "granite3.2:8b")
missing=0
for model in "${models[@]}"; do
if ! ollama list | awk 'NR>1 {print $1}' | grep -q "$model"; then
echo "❌ Model $model is missing!"
missing=1
fi
done

if [ "$missing" -eq 1 ]; then
exit 1
else
echo "✅ All expected models are available."
fi

- name: Wait for Ollama server
shell: bash
run: |
sleep 5
time curl -i http://localhost:11434
109 changes: 109 additions & 0 deletions .github/actions/run-examples/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: 'Ollama Setup'
description: 'Composte action to set up Run Examples'
inputs:
python-version:
description: 'Python version'
required: true
default: '3.11'
runner-os:
description: 'Runner OS'
required: true
repository:
description: 'Repository name this pull request is initiated from'
required: false
head-ref:
description: 'Head ref of the repo'
required: false
default: 'main'
token:
description: 'Github token'
required: false
update-results:
description: 'Whether to update the results for this run. Must be false for nightly runs'
required: true
check:
description: 'Files to patch tests/test_examples_run.yaml with. These are the PDL files that the test will run against. Defaults to all PDL files.'
required: false
default: '[]'
runs:
using: 'composite'
steps:
# # Set up Ollama
- uses: ./.github/actions/ollama

# Configure Run Examples environment
- uses: actions/checkout@v4
with:
token: ${{ inputs.token }}
ref: ${{ inputs.head-ref }}
repository: ${{ inputs.repository }}
fetch-depth: 0

- name: Patch tests/test_examples_run.yaml check with modified files
shell: bash
run: |
yq -i '.check = (${{ inputs.check }})' tests/test_examples_run.yaml

- name: Print test Run Examples config
shell: bash
run: cat tests/test_examples_run.yaml

# Run tests
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Cache pip
uses: actions/cache@v4
with:
# This path is specific to Ubuntu
path: ${{ env.pythonLocation }}
# Look to see if there is a cache hit for the setup file
key: ${{ inputs.runner-os }}-pip-new3-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
restore-keys: |
${{ inputs.runner-os }}-pip-new3
${{ inputs.runner-os }}-new3
- name: Install dependencies
shell: bash
run: pip install --upgrade --upgrade-strategy eager .[all]
- name: Pip list packages
shell: bash
run: pip list
- name: Run Pytest
shell: bash
run: |
cat tests/test_examples_run.yaml
(
set +e
py.test -v --capture=tee-sys -rfE -s tests/test_examples_run.py --disable-pytest-warnings
EXIT_CODE=$?

if [ $EXIT_CODE -eq 0 ]; then
echo "TEST_RESULT=PASSED" >> $GITHUB_ENV
else
echo "TEST_RESULT=FAILED" >> $GITHUB_ENV
fi
)

# Commit the results if update results
- name: Push new results to branch
shell: bash
if: ${{ inputs.update-results == 'true' }}
run: |
git config --local user.name github-actions[bot]
git config --local user.email 41898282+github-actions[bot]@users.noreply.github.com
git status
git pull origin ${{ inputs.head-ref }}
git add tests/results/
git diff --cached --quiet || git commit -s -m "github-actions[bot]: Run examples: updated result files on your behalf"
# git push origin ${{ inputs.head-ref }}
git push https://x-access-token:${{ inputs.token }}@github.com/${{ inputs.repository }} HEAD:${{ inputs.head-ref }}

- name: Check if pytest passed
shell: bash
run: |
if [ "$TEST_RESULT" == "PASSED" ]; then
exit 0
else
exit 1
fi
174 changes: 174 additions & 0 deletions .github/workflows/run-examples-prep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
---
name: Run examples on modified PDL files
on: [pull_request]
jobs:
tests:
name: Execution tests
runs-on: ubuntu-latest
permissions:
contents: write
# strategy:
# fail-fast: false
# max-parallel: 1
# matrix:
# python-version: ['3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ secrets.PDL_PAT }}
fetch-depth: 0

- name: Push the new run-examples yaml config
shell: bash
run: |
echo "This is a test: $(date)" > test-file.txt
git config --local user.name github-actions[bot]
git config --local user.email 41898282+github-actions[bot]@users.noreply.github.com
git remote set-url fork-remote https://${{ secrets.PDL_PAT }}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git
git status
git pull fork-remote ${{ github.head_ref }}
git add test-file.txt
git diff --cached --quiet || git commit -s -m "github-actions[bot]: Simple test for PAT"
git push fork-remote ${{ github.head_ref }}

# # Detect modified PDL files, includes Add, Modified, but not Deleted
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Detect all PDL files that were changed or added
# id: changed-pdl-files
# uses: tj-actions/changed-files@6cb76d07bee4c9772c6882c06c37837bf82a04d3 # v46
# with:
# files: |
# **.pdl
# json: "true"
# escape_json: "false"
# - name: List PDL files that were modified or added and append to test_examples_run
# run: |
# echo ${{ steps.changed-pdl-files.outputs.all_changed_files }}
# if [ ${{ steps.changed-pdl-files.outputs.all_changed_files_count }} -gt 0 ]; then
# echo "early-stop=false" >> $GITHUB_ENV
# else
# echo "No file need to be checked, skipping all subsequent tests."
# echo "early-stop=true" >> $GITHUB_ENV
# fi

# # Run tests if there are modified PDL files
# - name: Check if update results automatically by GitHub Actions Bot
# if: ${{ env.early-stop == 'false' }}
# id: parse-run-examples-config
# shell: bash
# run: |
# value=$(yq '.update_results' tests/test_examples_run.yaml | tr '[:upper:]' '[:lower:]')
# echo "value=$value"
# echo "update_results=$value" >> $GITHUB_ENV

# # Set up Ollama
# # - name: Cache Ollama model files
# # if: ${{ env.early-stop == 'false' }}
# # uses: actions/cache@v4
# # with:
# # path: /usr/share/ollama/.ollama/models
# # key: ${{ runner.os }}-build-ollama-cache
# # restore-keys: |
# # ${{ runner.os }}-build-
# # ${{ runner.os }}
# - uses: ./.github/actions/ollama
# if: ${{ env.early-stop == 'false' }}

# # Set up Run Examples environment
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v5
# if: ${{ env.early-stop == 'false' }}
# with:
# python-version: ${{ matrix.python-version }}
# - name: Cache pip
# uses: actions/cache@v4
# if: ${{ env.early-stop == 'false' }}
# with:
# # This path is specific to Ubuntu
# path: ${{ env.pythonLocation }}
# # Look to see if there is a cache hit for the setup file
# key: ${{ runner.os }}-pip-new3-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
# restore-keys: |
# ${{ runner.os }}-pip-new3
# ${{ runner.os }}-new3
# - name: Install dependencies
# if: ${{ env.early-stop == 'false' }}
# shell: bash
# run: pip install --upgrade --upgrade-strategy eager .[all]
# - name: Pip list packages
# if: ${{ env.early-stop == 'false' }}
# shell: bash
# run: pip list
# - name: Patch tests/test_examples_run.yaml check with modified files
# if: ${{ env.early-stop == 'false' }}
# shell: bash
# run: |
# yq -i '.check = (${{ steps.changed-pdl-files.outputs.all_changed_files }})' tests/test_examples_run.yaml
# - name: View Run Examples config
# if: ${{ env.early-stop == 'false' }}
# shell: bash
# run: cat tests/test_examples_run.yaml
# - name: Run Pytest
# if: ${{ env.early-stop == 'false' }}
# shell: bash
# run: |
# (
# set +e
# py.test -v --capture=tee-sys -rfE -s tests/test_examples_run.py --disable-pytest-warnings
# EXIT_CODE=$?

# if [ $EXIT_CODE -eq 0 ]; then
# echo "TEST_RESULT=PASSED" >> $GITHUB_ENV
# else
# echo "TEST_RESULT=FAILED" >> $GITHUB_ENV
# fi
# )

# # Commit the results if update results
# - name: Push new results to branch
# shell: bash
# if: ${{ env.early-stop == 'false' && env.update_results == 'true' }}
# run: |
# git config --local user.name github-actions[bot]
# git config --local user.email 41898282+github-actions[bot]@users.noreply.github.com
# git status
# git pull
# git add tests/results/
# git diff --cached --quiet || git commit -s -m "github-actions[bot]: Run examples: updated result files on your behalf"
# git push

# # Patch config with update_results to false and commit to PR
# - name: Patch tests/test_examples_run.yaml with update_results to False, only for the last job in the series
# if: ${{ env.early-stop == 'false' && env.update_results == 'true' && matrix.python-version == '3.13' }}
# shell: bash
# run: |
# yq -i '.update_results = ('false')' tests/test_examples_run.yaml
# - name: Push the new run-examples yaml config
# if: ${{ env.early-stop == 'false' && env.update_results == 'true' && matrix.python-version == '3.13' }}
# shell: bash
# run: |
# git config --local user.name github-actions[bot]
# git config --local user.email 41898282+github-actions[bot]@users.noreply.github.com
# git remote set-url origin https://${{ secrets.PDL_PAT }}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git
# git status
# git pull origin ${{ github.head_ref }}
# git add tests/test_examples_run.yaml
# git diff --cached --quiet || git commit -s -m "github-actions[bot]: Run examples: reverting update_result to false on your behalf"
# git push origin ${{ github.head_ref }}

# - name: Check if pytest passed
# shell: bash
# if: ${{ env.early-stop == 'false' }}
# run: |
# if [ "$TEST_RESULT" == "PASSED" ]; then
# exit 0
# else
# exit 1
# fi


Loading
Loading