|
| 1 | +name: Feature PR to Main |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +jobs: |
| 8 | + test: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + services: |
| 12 | + postgres: |
| 13 | + image: postgres:15-alpine |
| 14 | + env: |
| 15 | + POSTGRES_DB: cueapi_test |
| 16 | + POSTGRES_USER: runner |
| 17 | + POSTGRES_PASSWORD: "" |
| 18 | + POSTGRES_HOST_AUTH_METHOD: trust |
| 19 | + ports: |
| 20 | + - 5432:5432 |
| 21 | + options: >- |
| 22 | + --health-cmd "pg_isready -U runner -d cueapi_test" |
| 23 | + --health-interval 2s |
| 24 | + --health-timeout 3s |
| 25 | + --health-retries 15 |
| 26 | +
|
| 27 | + redis: |
| 28 | + image: redis:7-alpine |
| 29 | + ports: |
| 30 | + - 6379:6379 |
| 31 | + options: >- |
| 32 | + --health-cmd "redis-cli ping" |
| 33 | + --health-interval 2s |
| 34 | + --health-timeout 3s |
| 35 | + --health-retries 10 |
| 36 | +
|
| 37 | + steps: |
| 38 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.7 |
| 39 | + |
| 40 | + - name: Checkout cueapi-core |
| 41 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.7 |
| 42 | + with: |
| 43 | + repository: cueapi/cueapi-core |
| 44 | + path: cueapi-core |
| 45 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + |
| 47 | + - uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.3.0 |
| 48 | + with: |
| 49 | + python-version: '3.12' |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + run: | |
| 53 | + pip install -r cueapi-core/requirements.txt |
| 54 | + pip install -e . |
| 55 | +
|
| 56 | + - name: Run tests |
| 57 | + env: |
| 58 | + DATABASE_URL: postgresql+asyncpg://runner@localhost:5432/cueapi_test |
| 59 | + REDIS_URL: redis://localhost:6379 |
| 60 | + SESSION_SECRET: test-session-secret-32-chars-minimum!! |
| 61 | + ENV: test |
| 62 | + RESEND_API_KEY: "" |
| 63 | + CUEAPI_STAGING_URL: https://api-staging-e962.up.railway.app |
| 64 | + CUEAPI_STAGING_API_KEY: ${{ secrets.ARGUS_STAGING_KEY }} |
| 65 | + run: pytest tests/ -v --tb=short |
| 66 | + |
| 67 | + auto-merge: |
| 68 | + needs: test |
| 69 | + runs-on: ubuntu-latest |
| 70 | + steps: |
| 71 | + - name: Auto-merge PR |
| 72 | + run: gh pr merge ${{ github.event.pull_request.number }} --squash --auto |
| 73 | + env: |
| 74 | + GH_TOKEN: ${{ secrets.GOVIND_GITHUB_TOKEN }} |
| 75 | + GH_REPO: ${{ github.repository }} |
| 76 | + |
| 77 | + notify-merge: |
| 78 | + needs: auto-merge |
| 79 | + runs-on: ubuntu-latest |
| 80 | + steps: |
| 81 | + - name: Create merge confirmation cue |
| 82 | + run: | |
| 83 | + FIRE_AT=$(date -u -d '+2 minutes' '+%Y-%m-%dT%H:%M:%SZ' 2>/dev/null || \ |
| 84 | + date -u -v+2M '+%Y-%m-%dT%H:%M:%SZ') |
| 85 | + curl -s -w "\n%{http_code}" -X POST https://api.cueapi.ai/v1/cues \ |
| 86 | + -H "Authorization: Bearer ${{ secrets.ARGUS_CUEAPI_KEY }}" \ |
| 87 | + -H "Content-Type: application/json" \ |
| 88 | + -d "{ |
| 89 | + \"name\": \"cueapi-python-merged-${{ github.event.pull_request.number }}\", |
| 90 | + \"schedule\": {\"type\": \"once\", \"at\": \"${FIRE_AT}\"}, |
| 91 | + \"transport\": \"worker\", |
| 92 | + \"payload\": { |
| 93 | + \"task\": \"verify-github-merge\", |
| 94 | + \"repo\": \"cueapi/cueapi-python\", |
| 95 | + \"pr_number\": \"${{ github.event.pull_request.number }}\", |
| 96 | + \"commit_sha\": \"${{ github.event.pull_request.head.sha }}\" |
| 97 | + } |
| 98 | + }" |
0 commit comments