Skip to content

CI

CI #1620

Workflow file for this run

name: CI
on:
push:
schedule:
# Every day at ~7:17am Chicago time.
#
# Using a non-zero minute offset since GitHub Actions suggests
# running jobs at a random minute to avoid overloading their
# servers.
#
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: '17 12 * * *'
# Cancel in progress runs of this workflow when we push changes to the branch
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
AUTOBLOCKS_TRACER_THROW_ON_ERROR: '1'
AUTOBLOCKS_API_KEY: ${{ secrets.AUTOBLOCKS_API_KEY }}
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
- run: npx --package renovate renovate-config-validator --strict
test-readmes-up-to-date:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Make READMEs
run: node tools/make-readmes.js
- name: Ensure READMEs are up to date
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "::error::The READMEs are out of date. Please run 'node tools/make-readmes.js' and commit the changes."
exit 1
else
echo "READMEs are up to date!"
fi
test-python:
runs-on: ubuntu-latest
strategy:
matrix:
project:
- Python/openai-tracing
- Python/prompt-sdk
- Python/openai-assistants-api
defaults:
run:
shell: bash
working-directory: ${{ matrix.project }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create .env file
run: |
touch .env
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
echo "AUTOBLOCKS_INGESTION_KEY=${{ secrets.AUTOBLOCKS_INGESTION_KEY }}" >> .env
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Check pyproject.toml & poetry.lock are in sync
run: poetry lock --check
- name: Install dependencies
run: poetry install
- name: Run script
run: poetry run start
test-javascript:
runs-on: ubuntu-latest
strategy:
matrix:
project:
- JavaScript/openai-tracing
- JavaScript/prompt-sdk
- JavaScript/spans
- JavaScript/openai-assistants-api
defaults:
run:
shell: bash
working-directory: ${{ matrix.project }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create .env file
run: |
touch .env
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
echo "AUTOBLOCKS_INGESTION_KEY=${{ secrets.AUTOBLOCKS_INGESTION_KEY }}" >> .env
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Run script
run: npm run start
# This allows us to have one required status check on the "test" job
# since it's not feasible to maintain required status checks on each
# job in the matrixes above.
test:
needs:
- test-python
- test-javascript
if: always()
runs-on: ubuntu-latest
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "::error::One of the jobs failed or was cancelled."
exit 1
notify:
needs:
- test-python
- test-javascript
if: always() && contains(needs.*.result, 'failure') && github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- uses: slackapi/[email protected]
with:
payload: |
{
"text": ":warning: Workflow `${{ github.workflow }}` in repository `${{ github.repository }}` failed. <${{ env.run-url }}|Logs>"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}