ci: send Slack notification on nightly failures + modernize workflows #614
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run Haystack Tutorials | |
| on: | |
| pull_request: | |
| paths: | |
| - "tutorials/*.ipynb" | |
| jobs: | |
| generate-matrix: | |
| runs-on: ubuntu-slim | |
| outputs: | |
| matrix: ${{ steps.filter.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - id: generator | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| # Get tutorial notebooks | |
| VERSION=$(gh api /repos/deepset-ai/haystack/releases | \ | |
| jq -r '[.[].tag_name | select(test("^v2.[0-9]+.[0-9]+$"))] | first') | |
| NOTEBOOKS=$(python ./scripts/generate_matrix.py --haystack-version "$VERSION" --include-main) | |
| echo "matrix={\"include\":$NOTEBOOKS}" >> "$GITHUB_OUTPUT" | |
| - name: Get changed files | |
| id: files | |
| uses: tj-actions/changed-files@v47 | |
| with: | |
| matrix: true | |
| files: tutorials/*.ipynb | |
| - name: Filter non changed notebooks | |
| id: filter | |
| shell: python | |
| env: | |
| MATRIX: ${{ steps.generator.outputs.matrix }} | |
| CHANGED_FILES: ${{ steps.files.outputs.all_changed_files }} | |
| run: | | |
| import os | |
| import json | |
| matrix = json.loads(os.environ["MATRIX"]) | |
| changed_files = json.loads(os.environ["CHANGED_FILES"]) | |
| new_matrix = {"include": []} | |
| for item in matrix["include"]: | |
| notebook = item["notebook"] | |
| if f"tutorials/{notebook}.ipynb" not in changed_files: | |
| continue | |
| new_matrix["include"].append(item) | |
| new_matrix = json.dumps(new_matrix) | |
| with open(os.environ["GITHUB_OUTPUT"], "a") as f: | |
| print(f"matrix={new_matrix}", file=f) | |
| run-tutorials: | |
| runs-on: ubuntu-latest | |
| needs: generate-matrix | |
| container: deepset/haystack:base-${{ matrix.haystack_version }} | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} | |
| env: | |
| HAYSTACK_TELEMETRY_ENABLED: "False" | |
| HF_API_TOKEN: ${{ secrets.HF_API_KEY }} | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| SERPERDEV_API_KEY: ${{ secrets.SERPERDEV_API_KEY }} | |
| NOTION_API_KEY: ${{ secrets.NOTION_API_KEY }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup Python and uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| python-version: "3.11" | |
| - name: Install common dependencies | |
| run: | | |
| apt-get update && apt-get install -y \ | |
| build-essential \ | |
| gcc \ | |
| libsndfile1 \ | |
| ffmpeg | |
| uv venv | |
| uv pip install nbconvert ipython | |
| - name: Install tutorial dependencies | |
| if: toJSON(matrix.dependencies) != '[]' | |
| run: | | |
| uv pip install "${{ join(matrix.dependencies, '" "')}}" | |
| - name: Convert notebook to Python | |
| run: | | |
| uv run --no-project jupyter nbconvert --to python --RegexRemovePreprocessor.patterns '%%bash' ./tutorials/${{ matrix.notebook }}.ipynb | |
| - name: Run the converted notebook | |
| run: | | |
| NOTEBOOK="./tutorials/${{ matrix.notebook }}.py" | |
| if [ "${{ matrix.notebook }}" = "47_Human_in_the_Loop_Agent" ]; then | |
| # We add a prompt to confirm any user inputs in the HiTL notebook | |
| yes y | uv run --no-project python "$NOTEBOOK" | |
| elif [ "${{ matrix.notebook }}" = "48_Conversational_RAG" ]; then | |
| yes Q | uv run --no-project python "$NOTEBOOK" | |
| else | |
| uv run --no-project python "$NOTEBOOK" | |
| fi |