Skip to content

Commit 3641239

Browse files
committed
composite action
1 parent f48f486 commit 3641239

File tree

4 files changed

+82
-49
lines changed

4 files changed

+82
-49
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: 'Extract Error'
2+
description: 'extract test error messaget to pull request comment'
3+
inputs:
4+
error_filepath:
5+
description: 'error mesasge file path'
6+
required: true
7+
openai_api_key:
8+
description: 'OpenAI API Key'
9+
required: true
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Generate Test Output Summary
15+
shell: bash
16+
if: github.event_name == 'pull_request'
17+
run: |
18+
OPENAI_API_KEY=${{ inputs.openai_api_key }} python .github/actions/extract_error/extract_error.py ${{ inputs.error_filepath }} /tmp/output.txt
19+
20+
- name: Get Test Output Summary
21+
shell: bash
22+
id: get-comment-body
23+
if: github.event_name == 'pull_request'
24+
run: |
25+
body="$(cat /tmp/output.txt)"
26+
delimiter="$(openssl rand -hex 8)"
27+
echo "body<<${delimiter}" >> $GITHUB_OUTPUT
28+
echo "${body}" >> $GITHUB_OUTPUT
29+
echo "${delimiter}" >> $GITHUB_OUTPUT
30+
31+
- name: Find Comment
32+
uses: peter-evans/find-comment@v2
33+
id: find-comment
34+
if: github.event_name == 'pull_request'
35+
with:
36+
issue-number: ${{ github.event.pull_request.number }}
37+
comment-author: 'github-actions[bot]'
38+
body-includes: Error Summary
39+
40+
- name: Create or update comment
41+
uses: peter-evans/create-or-update-comment@v2
42+
if: github.event_name == 'pull_request'
43+
with:
44+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
45+
issue-number: ${{ github.event.pull_request.number }}
46+
body: ${{ steps.get-comment-body.outputs.body }}
47+
edit-mode: replace
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import argparse
2+
import os
3+
from prompttrail.agent.templates import LinearTemplate
4+
from prompttrail.agent.runners import CommandLineRunner
5+
from prompttrail.models.openai import OpenAIChatCompletionModel, OpenAIModelConfiguration, OpenAIModelParameters
6+
from prompttrail.agent.user_interaction import UserInteractionTextCLIProvider
7+
8+
9+
def extract(error_message: str):
10+
return f"""# Error Summary
11+
12+
TODO: impl summarization of error_message by PromptTail.
13+
error_mesasge len: {len(error_message)}
14+
"""
15+
16+
17+
def main() -> None:
18+
parser = argparse.ArgumentParser()
19+
parser.add_argument('error_filepath')
20+
parser.add_argument('output_filepath')
21+
args = parser.parse_args()
22+
with open(args.error_filepath) as f:
23+
error_message = f.read()
24+
with open(args.output_filepath, 'w') as f:
25+
f.write(extract(error_message))
26+
27+
28+
if __name__ == "__main__":
29+
main()

.github/workflows/extract_error.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,42 +30,17 @@ jobs:
3030
- name: Run black
3131
run: black --check src examples tests
3232
- name: Run pytest
33-
run: pytest --cov=src --cov-report=xml tests >> /tmp/test_output.txt
33+
run: pytest --cov=src --cov-report=xml tests > /tmp/test_output.txt
3434
env:
3535
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
3636
GOOGLE_CLOUD_API_KEY: ${{ secrets.GOOGLE_CLOUD_API_KEY }}
3737

38-
- name: Generate Test Output Summary
39-
shell: bash
40-
if: github.event_name == 'pull_request'
41-
run: |
42-
python .github/workflows/extract_error.py /tmp/test_output.txt > /tmp/output.txt
43-
- name: Get Test Output Summary
44-
shell: bash
45-
id: get-comment-body
46-
if: github.event_name == 'pull_request'
47-
run: |
48-
body="$(cat /tmp/output.txt)"
49-
delimiter="$(openssl rand -hex 8)"
50-
echo "body<<${delimiter}" >> $GITHUB_OUTPUT
51-
echo "${body}" >> $GITHUB_OUTPUT
52-
echo "${delimiter}" >> $GITHUB_OUTPUT
53-
- name: Find Comment
54-
uses: peter-evans/find-comment@v2
55-
id: find-comment
56-
if: github.event_name == 'pull_request'
57-
with:
58-
issue-number: ${{ github.event.pull_request.number }}
59-
comment-author: 'github-actions[bot]'
60-
body-includes: Error Summary
61-
- name: Create or update comment
62-
uses: peter-evans/create-or-update-comment@v2
63-
if: github.event_name == 'pull_request'
38+
- name: Extract Error
39+
uses: ./.github/actions/extract_error
40+
if: failure()
6441
with:
65-
comment-id: ${{ steps.find-comment.outputs.comment-id }}
66-
issue-number: ${{ github.event.pull_request.number }}
67-
body: ${{ steps.get-comment-body.outputs.body }}
68-
edit-mode: replace
42+
error_filepath: /tmp/test_output.txt
43+
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
6944

7045
- name: Upload coverage reports to Codecov
7146
uses: codecov/codecov-action@v3

0 commit comments

Comments
 (0)