PAI-RAG CI Build workflow (aigc-apps/PAI-RAG)
The PAI-RAG CI Build workflow from aigc-apps/PAI-RAG, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get caching, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the PAI-RAG CI Build workflow from the aigc-apps/PAI-RAG 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: PAI-RAG CI Build
on:
push:
# Sequence of patterns matched against refs/heads
branches:
- main
- feature
- "releases/**"
concurrency:
group: pairag-ci-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
# This is the version of the action for setting up Python, not the Python version.
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: "3.11"
# Optional - x64 or x86 architecture, defaults to x64
architecture: "x64"
- name: Set up redis-server
uses: shogo82148/actions-setup-redis@v1
with:
redis-version: "7.x"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install poetry
poetry env activate
poetry install
- name: Run Linter
shell: bash
run: |
poetry run pip install pre-commit
poetry run make lint
- name: Run Tests
run: |
poetry run make coveragetest
env:
DASHSCOPE_API_KEY: ${{ secrets.TESTDASHSCOPEKEY }}
BING_SEARCH_KEY: ${{ secrets.BING_SEARCH_KEY }}
OSS_ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }}
OSS_ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
PAIRAG_RAG__embedding__source: "huggingface"
PAIRAG_RAG__llm__source: "DashScope"
PAIRAG_RAG__llm__model: "qwen-max"
TRACE_TOKEN: ${{ secrets.TRACE_TOKEN }}
DISABLE_REDIS_CACHE_IN_TESTS: "true"
ENCRYPTION_KEY: ${{ secrets.ENCRYPTION_KEY }}
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: PAI-RAG CI Build on: push: # Sequence of patterns matched against refs/heads branches: - main - feature - "releases/**" concurrency: group: pairag-ci-${{ github.head_ref || github.run_id }} cancel-in-progress: true permissions: contents: read pull-requests: write jobs: build: timeout-minutes: 30 name: Build and Test runs-on: latchkey-small steps: - uses: actions/checkout@v4 - name: Set up Python 3.11 # This is the version of the action for setting up Python, not the Python version. uses: actions/setup-python@v5 with: cache: 'pip' # Semantic version range syntax or exact version of a Python version python-version: "3.11" # Optional - x64 or x86 architecture, defaults to x64 architecture: "x64" - name: Set up redis-server uses: shogo82148/actions-setup-redis@v1 with: redis-version: "7.x" - name: Install Dependencies run: | python -m pip install --upgrade pip setuptools wheel pip install poetry poetry env activate poetry install - name: Run Linter shell: bash run: | poetry run pip install pre-commit poetry run make lint - name: Run Tests run: | poetry run make coveragetest env: DASHSCOPE_API_KEY: ${{ secrets.TESTDASHSCOPEKEY }} BING_SEARCH_KEY: ${{ secrets.BING_SEARCH_KEY }} OSS_ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }} OSS_ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }} PAIRAG_RAG__embedding__source: "huggingface" PAIRAG_RAG__llm__source: "DashScope" PAIRAG_RAG__llm__model: "qwen-max" TRACE_TOKEN: ${{ secrets.TRACE_TOKEN }} DISABLE_REDIS_CACHE_IN_TESTS: "true" ENCRYPTION_KEY: ${{ secrets.ENCRYPTION_KEY }}
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - 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
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.