chore: document stuff in the workflow #2230
Workflow file for this run
This file contains 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: CI | |
on: | |
pull_request_target: | |
paths-ignore: | |
- "**.md" | |
workflow_dispatch: | |
permissions: | |
contents: read | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# see https://datachain.ai/blog/testing-external-contributions-using-github-actions-secrets | |
# the point of this is to forbid external contributors from running ci without explicit | |
# approval from the maintainers (via the environment external-contributors) | |
# this allows tests to be run with secrets on forks after the maintainers have approved the run | |
# | |
# note: you may think the "run ci with approval setting" in github is enough, | |
# but it doesn't work for pull_request_target | |
authorize: | |
environment: | |
${{ github.event_name == 'pull_request_target' && | |
github.event.pull_request.head.repo.full_name != github.repository && | |
'external-contributors' || 'internal-contributors' }} | |
runs-on: ubuntu-latest | |
steps: | |
- run: true | |
build-and-test-extension: | |
needs: authorize | |
# services: | |
# ollama: | |
# image: ollama/ollama:latest | |
# ports: | |
# - 11434:11434 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
postgres-version: [ 16, 17 ] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# in a pull_request_target event, the ref is the `main` branch not the PR branch | |
# so we need to tell checkout to use the head.ref instead. | |
ref: ${{ github.event.pull_request.head.ref || github.ref }} | |
- uses: taiki-e/install-action@just | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Verify Docker installation | |
run: | | |
docker --version | |
docker info | |
- name: Build Docker image | |
run: just ext docker-build | |
env: | |
PG_MAJOR: ${{ matrix.postgres-version }} | |
- name: Run Docker container | |
run: just ext docker-run | |
- name: Build | |
run: docker exec pgai-ext just build | |
- name: Lint SQL and Python | |
run: docker exec pgai-ext just lint | |
- name: Check Python Formatting | |
run: docker exec pgai-ext just format | |
- name: Compare requirements file | |
run: docker exec pgai-ext just check-requirements | |
- name: Install extension | |
run: docker exec pgai-ext just install-all | |
- name: Run test server | |
run: docker exec -d | |
-e OPENAI_API_KEY | |
-e ANTHROPIC_API_KEY | |
-e COHERE_API_KEY | |
-e VOYAGE_API_KEY | |
pgai-ext just test-server | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} | |
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }} | |
- name: Run tests | |
run: docker exec | |
-e OPENAI_API_KEY | |
-e ANTHROPIC_API_KEY | |
-e COHERE_API_KEY | |
-e VOYAGE_API_KEY | |
-e OLLAMA_HOST | |
pgai-ext just test | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} | |
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }} | |
OLLAMA_HOST: "0" | |
#OLLAMA_HOST: http://localhost:11434 | |
- name: Stop and remove Docker container | |
run: | | |
just ext docker-stop | |
just ext docker-rm | |
build-and-test-pgai: | |
needs: authorize | |
services: | |
ollama: | |
image: ollama/ollama:latest | |
ports: | |
- 11434:11434 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# in a pull_request_target event, the ref is the `main` branch not the PR branch | |
# so we need to tell checkout to use the head.ref instead. | |
ref: ${{ github.event.pull_request.head.sha || github.ref }} | |
- uses: taiki-e/install-action@just | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
version: "0.5.20" | |
enable-cache: true | |
cache-dependency-glob: "./projects/pgai/uv.lock" | |
- name: "Set up Python" | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: "./projects/pgai/.python-version" | |
- name: CI pipeline. Install dependencies, run linters and formatters, execute tests and build the project", | |
run: just pgai ci | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |