App Tests workflow (Azure-Samples/rag-postgres-openai-python)
The App Tests workflow from Azure-Samples/rag-postgres-openai-python, explained and optimized by Latchkey.
CI health: F - at risk
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the App Tests workflow from the Azure-Samples/rag-postgres-openai-python repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: App Tests
on:
push:
branches: [ main ]
paths-ignore:
- "**.md"
- ".azdo/**"
- ".devcontainer/**"
- ".github/**"
pull_request:
branches: [ main ]
paths-ignore:
- "**.md"
- ".azdo/**"
- ".devcontainer/**"
- ".github/**"
workflow_dispatch:
permissions:
contents: read
jobs:
test-package:
name: Test ${{ matrix.os }} Python ${{ matrix.python_version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-26", "windows-latest"]
python_version: ["3.10", "3.11", "3.12"]
exclude:
- os: macos-26
python_version: "3.10"
env:
UV_SYSTEM_PYTHON: 1
POSTGRES_HOST: localhost
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: root
POSTGRES_DATABASE: postgres
POSTGRES_SSL: disable
steps:
- uses: actions/checkout@v4
- name: (MacOS) Install postgreSQL and pgvector using brew
if: matrix.os == 'macos-26'
run: |
brew install postgresql@18
brew link --overwrite postgresql@18
brew install pgvector
brew services start postgresql@18 && sleep 1
createuser -s ${{ env.POSTGRES_USERNAME }}
psql -d postgres -c "ALTER USER ${{ env.POSTGRES_USERNAME }} WITH PASSWORD '${{ env.POSTGRES_PASSWORD }}'"
psql -d postgres -c 'CREATE EXTENSION vector'
- name: Install pgvector
if: matrix.os == 'windows-latest'
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cd %TEMP%
git clone --branch v0.8.1 https://github.com/pgvector/pgvector.git
cd pgvector
nmake /NOLOGO /F Makefile.win
nmake /NOLOGO /F Makefile.win install
sc config postgresql-x64-17 start=auto
net start postgresql-x64-17
"%PGBIN%/psql" -d postgres -c "CREATE EXTENSION vector"
- name: (Linux) Install pgvector and set password
if: matrix.os == 'ubuntu-latest'
run: |
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
sudo apt-get install postgresql-16-pgvector
sudo systemctl start postgresql
sudo -u postgres psql -c "ALTER USER ${{ env.POSTGRES_USERNAME }} PASSWORD '${{ env.POSTGRES_PASSWORD }}'"
sudo -u postgres psql -c 'CREATE EXTENSION vector'
- name: Setup python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
architecture: x64
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
version: "0.4.20"
cache-dependency-glob: "requirements**.txt"
- name: Install dependencies
run: |
uv pip install -r requirements-dev.txt
uv pip install -r evals/requirements.txt
- name: Install app as editable app
run: |
uv pip install -e src/backend
- name: Setup local database with seed data
run: |
python ./src/backend/fastapi_app/setup_postgres_database.py
python ./src/backend/fastapi_app/setup_postgres_seeddata.py
- name: Setup node
uses: actions/setup-node@v5
with:
node-version: 18
- name: Build frontend
run: |
cd ./src/frontend
npm install
npm run build
- name: Run ty
run: python3 -m ty check . --python-version ${{ matrix.python_version }} --output-format github
- name: Run Pytest
run: python3 -m pytest -s -vv --cov --cov-fail-under=85
- name: Run E2E tests with Playwright
id: e2e
run: |
playwright install chromium --with-deps
python3 -m pytest tests/e2e.py --tracing=retain-on-failure
- name: Upload test artifacts
if: ${{ failure() && steps.e2e.conclusion == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: playwright-traces${{ matrix.python_version }}
path: test-results
The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: App Tests on: push: branches: [ main ] paths-ignore: - "**.md" - ".azdo/**" - ".devcontainer/**" - ".github/**" pull_request: branches: [ main ] paths-ignore: - "**.md" - ".azdo/**" - ".devcontainer/**" - ".github/**" workflow_dispatch: permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: test-package: timeout-minutes: 30 name: Test ${{ matrix.os }} Python ${{ matrix.python_version }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: ["ubuntu-latest", "macos-26", "windows-latest"] python_version: ["3.10", "3.11", "3.12"] exclude: - os: macos-26 python_version: "3.10" env: UV_SYSTEM_PYTHON: 1 POSTGRES_HOST: localhost POSTGRES_USERNAME: postgres POSTGRES_PASSWORD: root POSTGRES_DATABASE: postgres POSTGRES_SSL: disable steps: - uses: actions/checkout@v4 - name: (MacOS) Install postgreSQL and pgvector using brew if: matrix.os == 'macos-26' run: | brew install postgresql@18 brew link --overwrite postgresql@18 brew install pgvector brew services start postgresql@18 && sleep 1 createuser -s ${{ env.POSTGRES_USERNAME }} psql -d postgres -c "ALTER USER ${{ env.POSTGRES_USERNAME }} WITH PASSWORD '${{ env.POSTGRES_PASSWORD }}'" psql -d postgres -c 'CREATE EXTENSION vector' - name: Install pgvector if: matrix.os == 'windows-latest' shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" cd %TEMP% git clone --branch v0.8.1 https://github.com/pgvector/pgvector.git cd pgvector nmake /NOLOGO /F Makefile.win nmake /NOLOGO /F Makefile.win install sc config postgresql-x64-17 start=auto net start postgresql-x64-17 "%PGBIN%/psql" -d postgres -c "CREATE EXTENSION vector" - name: (Linux) Install pgvector and set password if: matrix.os == 'ubuntu-latest' run: | sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y sudo apt-get install postgresql-16-pgvector sudo systemctl start postgresql sudo -u postgres psql -c "ALTER USER ${{ env.POSTGRES_USERNAME }} PASSWORD '${{ env.POSTGRES_PASSWORD }}'" sudo -u postgres psql -c 'CREATE EXTENSION vector' - name: Setup python uses: actions/setup-python@v6 with: python-version: ${{ matrix.python_version }} architecture: x64 - name: Install uv uses: astral-sh/setup-uv@v6 with: enable-cache: true version: "0.4.20" cache-dependency-glob: "requirements**.txt" - name: Install dependencies run: | uv pip install -r requirements-dev.txt uv pip install -r evals/requirements.txt - name: Install app as editable app run: | uv pip install -e src/backend - name: Setup local database with seed data run: | python ./src/backend/fastapi_app/setup_postgres_database.py python ./src/backend/fastapi_app/setup_postgres_seeddata.py - name: Setup node uses: actions/setup-node@v5 with: cache: 'npm' node-version: 18 - name: Build frontend run: | cd ./src/frontend npm install npm run build - name: Run ty run: python3 -m ty check . --python-version ${{ matrix.python_version }} --output-format github - name: Run Pytest run: python3 -m pytest -s -vv --cov --cov-fail-under=85 - name: Run E2E tests with Playwright id: e2e run: | playwright install chromium --with-deps python3 -m pytest tests/e2e.py --tracing=retain-on-failure - name: Upload test artifacts if: ${{ failure() && steps.e2e.conclusion == 'failure' }} uses: actions/upload-artifact@v4 with: name: playwright-traces${{ matrix.python_version }} path: test-results
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
- End-to-end and browser tests
This workflow runs 1 job (9 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.