Skip to content

Reduce CI test timeouts and enable unbuffered Python output #2079

Reduce CI test timeouts and enable unbuffered Python output

Reduce CI test timeouts and enable unbuffered Python output #2079

name: Build and Test
on:
push:
paths-ignore:
- "**/*.md"
- "docs/**"
- "LICENSE"
- "book.json"
- "SECURITY.md"
- "CODE_OF_CONDUCT.md"
release:
types: [published]
jobs:
build:
uses: ./.github/workflows/docker.yml
name: Build AGiXT
with:
registry-dockerhub-enable: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
registry-repo-name: AGiXT
registry-readme: ./docs/README.md
secrets:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
test-agixt-postgres:
uses: ./.github/workflows/python-tests.yml
permissions:
contents: read
packages: read
with:
test-file: tests/endpoint_tests.py
image: ${{ needs.build.outputs.primary-image }}
port: "7437"
database-type: "postgresql"
report-name: "agixt-postgres-tests"
needs: build
secrets:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
test-agixt-sqlite:
uses: ./.github/workflows/python-tests.yml
permissions:
contents: read
packages: read
with:
test-file: tests/endpoint_tests.py
image: ${{ needs.build.outputs.primary-image }}
port: "7437"
database-type: "sqlite"
report-name: "agixt-sqlite-tests"
needs: build
secrets:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
deploy:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: read
name: Deploy to Production
needs: test-agixt-postgres
if: github.event_name == 'release'
steps:
- name: Deploy Application
id: deploy
env:
RAW_COMMIT_MSG: ${{ github.event.head_commit.message }}
run: |
# Build JSON payload safely using jq to handle special characters in commit messages
COMMIT_MSG=$(printf '%.100s' "$RAW_COMMIT_MSG" | tr '\n' ' ')
JSON_BODY=$(jq -n \
--arg domain "${{ secrets.DEPLOY_DOMAIN }}" \
--arg actor "${{ github.actor }}" \
--arg commit_id "${{ github.sha }}" \
--arg commit_message "$COMMIT_MSG" \
--arg repository "${{ github.repository }}" \
--arg branch "${{ github.ref_name }}" \
'{domain: $domain, github_actor: $actor, commit_id: $commit_id, commit_message: $commit_message, repository: $repository, branch: $branch}')
RESPONSE=$(curl -s -w "\nHTTP_STATUS_CODE:%{http_code}" -X POST "${{ secrets.DEPLOY_URI }}" \
-H "Content-Type: application/json" \
-H "X-API-Key: ${{ secrets.DEPLOY_SECRET }}" \
-d "$JSON_BODY")
HTTP_STATUS=$(echo "$RESPONSE" | grep -o "HTTP_STATUS_CODE:[0-9]*" | cut -d: -f2)
RESPONSE_BODY=$(echo "$RESPONSE" | sed '/HTTP_STATUS_CODE:/d')
echo "deploy_response=$RESPONSE_BODY" >> $GITHUB_OUTPUT
echo "deploy_status=$HTTP_STATUS" >> $GITHUB_OUTPUT
if [ "$HTTP_STATUS" -ge 200 ] && [ "$HTTP_STATUS" -lt 300 ]; then
echo "Deployment successful with status $HTTP_STATUS"
else
echo "Deployment failed with status $HTTP_STATUS"
exit 1
fi