diff --git a/.github/workflows/integration-test-trigger.yml b/.github/workflows/integration-test-trigger.yml new file mode 100644 index 00000000..c3adb5ec --- /dev/null +++ b/.github/workflows/integration-test-trigger.yml @@ -0,0 +1,55 @@ +name: Trigger Integration Tests + +on: + issue_comment: + types: + - created + +jobs: + trigger: + if: | + github.event.issue.pull_request && + startsWith(github.event.comment.body, '/integration-test') && + ( + github.event.comment.author_association == 'MEMBER' || + github.event.comment.author_association == 'OWNER' + ) + + runs-on: ubuntu-latest + + permissions: + actions: write + contents: read + pull-requests: read + + steps: + - name: Get PR details + id: pr + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number + }); + + core.setOutput('head_sha', pr.data.head.sha); + core.setOutput('head_ref', pr.data.head.ref); + core.setOutput('head_repo', pr.data.head.repo.full_name); + + - name: Dispatch integration workflow + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: 'integration-tests.yml', + ref: 'main', + inputs: { + sha: '${{ steps.pr.outputs.head_sha }}', + ref: '${{ steps.pr.outputs.head_ref }}', + repository: '${{ steps.pr.outputs.head_repo }}' + } + }); diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 9a369d02..9585add1 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -6,59 +6,57 @@ on: - main workflow_dispatch: + inputs: + sha: + required: false + type: string - issue_comment: - types: - - created + ref: + required: false + type: string + + repository: + required: false + type: string jobs: integration: name: Live LLM Integration Tests - if: | - github.event_name == 'push' || - github.event_name == 'workflow_dispatch' || - ( - github.event_name == 'issue_comment' && - github.event.issue.pull_request && - startsWith(github.event.comment.body, '/integration-test') && - ( - github.event.comment.author_association == 'MEMBER' || - github.event.comment.author_association == 'OWNER' - ) - ) - runs-on: ubuntu-latest + permissions: + statuses: write + contents: read + defaults: run: working-directory: ./backend steps: - - name: Get PR details - if: github.event_name == 'issue_comment' - id: pr + - name: Set pending status + if: inputs.sha != '' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 with: script: | - const pr = await github.rest.pulls.get({ + await github.rest.repos.createCommitStatus({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: context.issue.number + sha: '${{ inputs.sha }}', + state: 'pending', + context: 'Live LLM Integration Tests', + target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` }); - core.setOutput('head_ref', pr.data.head.ref); - core.setOutput('head_repo', pr.data.head.repo.full_name); - - - name: Checkout PR branch - if: github.event_name == 'issue_comment' + - name: Checkout PR commit + if: inputs.sha != '' uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 #v4.3.1 with: - repository: ${{ steps.pr.outputs.head_repo }} - ref: ${{ steps.pr.outputs.head_ref }} + repository: ${{ inputs.repository }} + ref: ${{ inputs.sha }} - name: Checkout repository - if: github.event_name != 'issue_comment' + if: inputs.sha == '' uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 #v4.3.1 - name: Set up Python @@ -72,7 +70,22 @@ jobs: pip install -e . - name: Run integration tests + id: tests env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: make test-integration + + - name: Set final status + if: always() && inputs.sha != '' + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + await github.rest.repos.createCommitStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + sha: '${{ inputs.sha }}', + state: '${{ steps.tests.outcome }}' === 'success' ? 'success' : 'failure', + context: 'Live LLM Integration Tests', + target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` + }); diff --git a/backend/test_settings.py b/backend/test_settings.py index b9789f57..dce0671d 100644 --- a/backend/test_settings.py +++ b/backend/test_settings.py @@ -114,7 +114,7 @@ def root(*args): }, "root": { "handlers": ["console"], - "level": "DEBUG", + "level": "INFO", }, }