1- name : Run Haystack Tutorials
1+ name : Run Tutorials
22
33on :
4+ workflow_dispatch : # Activate this workflow manually
5+ schedule :
6+ - cron : " 0 0 * * *"
47 pull_request :
58 paths :
69 - " tutorials/*.ipynb"
710
811jobs :
912 generate-matrix :
10- runs-on : ubuntu-latest
13+ runs-on : ubuntu-slim
1114 outputs :
12- matrix : ${{ steps.filter .outputs.matrix }}
15+ matrix : ${{ steps.matrix .outputs.matrix }}
1316 steps :
14- - uses : actions/checkout@v4
17+ - uses : actions/checkout@v6
1518
16- - uses : actions/setup-python@v5
19+ - uses : actions/setup-python@v6
1720 with :
1821 python-version : " 3.11"
1922
@@ -28,39 +31,41 @@ jobs:
2831 echo "matrix={\"include\":$NOTEBOOKS}" >> "$GITHUB_OUTPUT"
2932
3033 - name : Get changed files
34+ if : github.event_name == 'pull_request'
3135 id : files
32- uses : tj-actions/changed-files@v46
36+ uses : tj-actions/changed-files@v47
3337 with :
3438 matrix : true
3539 files : tutorials/*.ipynb
3640
37- - name : Filter non changed notebooks
38- id : filter
41+ - name : Filter to changed notebooks (pull request only)
42+ id : matrix
3943 shell : python
4044 env :
45+ EVENT_NAME : ${{ github.event_name }}
4146 MATRIX : ${{ steps.generator.outputs.matrix }}
4247 CHANGED_FILES : ${{ steps.files.outputs.all_changed_files }}
4348 run : |
4449 import os
4550 import json
4651
4752 matrix = json.loads(os.environ["MATRIX"])
48- changed_files = json.loads(os.environ["CHANGED_FILES"])
49- new_matrix = {"include": []}
50- for item in matrix["include"]:
51- notebook = item["notebook"]
52- if f"tutorials/{notebook}.ipynb" not in changed_files:
53- continue
54- new_matrix["include"].append(item)
55-
56- new_matrix = json.dumps(new_matrix)
53+
54+ if os.environ["EVENT_NAME"] == "pull_request":
55+ changed_files = json.loads(os.environ["CHANGED_FILES"])
56+ new_matrix = {"include": []}
57+ for item in matrix["include"]:
58+ notebook = item["notebook"]
59+ if f"tutorials/{notebook}.ipynb" in changed_files:
60+ new_matrix["include"].append(item)
61+ matrix = new_matrix
62+
5763 with open(os.environ["GITHUB_OUTPUT"], "a") as f:
58- print(f"matrix={new_matrix }", file=f)
64+ print(f"matrix={json.dumps(matrix) }", file=f)
5965
6066 run-tutorials :
61- runs-on : ubuntu-latest
6267 needs : generate-matrix
63- container : deepset/haystack:base-${{ matrix.haystack_version }}
68+ runs-on : ubuntu-latest
6469
6570 strategy :
6671 fail-fast : false
@@ -75,29 +80,37 @@ jobs:
7580
7681 steps :
7782 - name : Checkout
78- uses : actions/checkout@v4
83+ uses : actions/checkout@v6
84+
85+ - name : Setup Python and uv
86+ uses : astral-sh/setup-uv@v7
87+ with :
88+ python-version : " 3.11"
7989
8090 - name : Install common dependencies
8191 run : |
82- apt-get update && apt-get install -y \
83- build-essential \
84- gcc \
85- libsndfile1 \
86- ffmpeg
87-
88- pip install nbconvert ipython
92+ uv venv
93+ if [ "${{ matrix.haystack_version }}" = "main" ]; then
94+ uv pip install "haystack-ai @ git+https://github.com/deepset-ai/haystack.git@main"
95+ else
96+ VERSION="${{ matrix.haystack_version }}"
97+ uv pip install "haystack-ai==${VERSION#v}"
98+ fi
99+ uv pip install nbconvert ipython
89100
90101 - name : Install tutorial dependencies
91102 if : toJSON(matrix.dependencies) != '[]'
92103 run : |
93- pip install "${{ join(matrix.dependencies, '" "')}}"
104+ uv pip install "${{ join(matrix.dependencies, '" "')}}"
94105
95106 - name : Convert notebook to Python
96107 run : |
108+ . .venv/bin/activate
97109 jupyter nbconvert --to python --RegexRemovePreprocessor.patterns '%%bash' ./tutorials/${{ matrix.notebook }}.ipynb
98110
99111 - name : Run the converted notebook
100112 run : |
113+ . .venv/bin/activate
101114 NOTEBOOK="./tutorials/${{ matrix.notebook }}.py"
102115 if [ "${{ matrix.notebook }}" = "47_Human_in_the_Loop_Agent" ]; then
103116 # We add a prompt to confirm any user inputs in the HiTL notebook
@@ -107,3 +120,9 @@ jobs:
107120 else
108121 python "$NOTEBOOK"
109122 fi
123+
124+ - name : Notify Slack on nightly failure
125+ if : failure() && github.event_name != 'pull_request'
126+ uses : deepset-ai/notify-slack-action@v1
127+ with :
128+ slack-webhook-url : ${{ secrets.SLACK_WEBHOOK_URL_NOTIFICATIONS }}
0 commit comments