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: | |
types: | |
- opened | |
- labeled | |
- synchronize | |
pull_request_review: | |
types: | |
- submitted | |
- edited | |
concurrency: | |
group: backend-e2e-${{ github.event.number }} | |
cancel-in-progress: true | |
jobs: | |
triggers: | |
name: Get Triggers | |
runs-on: ubuntu-latest | |
outputs: | |
is_pull_request_opened: ${{ github.event_name == 'pull_request' && github.event.action == 'opened'}} | |
is_pull_request_review_approved: ${{ github.event_name == 'pull_request_review' && github.event.review.state == 'APPROVED'}} | |
is_pull_request_labeled_with_run_tests: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-tests')}} | |
steps: | |
- run: true | |
test: | |
needs: triggers | |
if: ${{ needs.triggers.outputs.is_pull_request_opened == 'true' || needs.triggers.outputs.is_pull_request_review_approved == 'true' || needs.triggers.outputs.is_pull_request_labeled_with_run_tests == 'true' }} | |
runs-on: ubuntu-latest | |
env: | |
PYTHONPATH: ${{ github.workspace }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Copy .env file | |
run: cp .env.example .env | |
- name: Set OPENAIKEY in the .env file so it can be loaded from the environment | |
env: | |
OPENAIKEY: ${{ secrets.OPENAIKEY }} | |
run: sed -i "s/<add_your_openai_api_key_here>/${OPENAIKEY}/g" .env | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Build Docker image | |
run: docker compose build | |
- name: Run Docker Compose | |
run: docker compose up -d | |
- name: Wait for services to be up | |
timeout-minutes: 5 | |
run: | | |
timeout=60 | |
counter=0 | |
while [[ "$counter" -lt "$timeout" ]]; do | |
if curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ping","params":[],"id":1}' http://0.0.0.0:4000/api | grep -q "OK"; then | |
echo "RPC server is up!" | |
break | |
else | |
echo "Waiting for RPC server... ($counter/$timeout)" | |
sleep 5 | |
counter=$((counter+1)) | |
fi | |
done | |
# Fail if the service didn't start within the timeout | |
if [[ "$counter" -ge "$timeout" ]]; then | |
echo "Error: Timeout while waiting for RPC server" | |
exit 1 | |
fi | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12.4 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install -r requirements.test.txt | |
- name: Run tests | |
run: pytest tests/integration/ -vv | |
- name: Dump Docker Compose logs | |
run: docker compose logs | |
if: failure() | |
- name: Shutdown Docker Compose | |
if: always() | |
run: docker compose down |