diff --git a/.github/workflows/test-finder.yml b/.github/workflows/test-finder.yml index 7b4133bcb411..eaf672b59078 100644 --- a/.github/workflows/test-finder.yml +++ b/.github/workflows/test-finder.yml @@ -80,7 +80,7 @@ jobs: - Include a descriptive test name that explains what is being tested EOF - goose run -i /tmp/create_working_test.txt --with-builtin developer --path /tmp/goose-home/.local/share/goose/sessions/test_generation.jsonl + goose run -i /tmp/create_working_test.txt --with-builtin developer # Check the result if [ -f /tmp/test_result.txt ]; then @@ -104,15 +104,29 @@ jobs: - name: Extract token metrics id: metrics run: | - SESSION_FILE="/tmp/goose-home/.local/share/goose/sessions/test_generation.jsonl" - if [ -f "$SESSION_FILE" ]; then - TOKENS=$(head -1 "$SESSION_FILE" | jq -r '.accumulated_total_tokens // 0') - INPUT_TOKENS=$(head -1 "$SESSION_FILE" | jq -r '.accumulated_input_tokens // 0') - OUTPUT_TOKENS=$(head -1 "$SESSION_FILE" | jq -r '.accumulated_output_tokens // 0') - echo "total_tokens=${TOKENS}" >> $GITHUB_OUTPUT - echo "input_tokens=${INPUT_TOKENS}" >> $GITHUB_OUTPUT - echo "output_tokens=${OUTPUT_TOKENS}" >> $GITHUB_OUTPUT - echo "Token usage - Total: ${TOKENS}, Input: ${INPUT_TOKENS}, Output: ${OUTPUT_TOKENS}" + # Find the most recently created session file in the goose sessions directory + SESSION_DIR="$HOME/.local/share/goose/sessions" + if [ -d "$SESSION_DIR" ]; then + SESSION_FILE=$(ls -t "$SESSION_DIR"/*.jsonl 2>/dev/null | head -1) + if [ -f "$SESSION_FILE" ]; then + echo "Found session file: $SESSION_FILE" + # Current context size metrics + TOKENS=$(head -1 "$SESSION_FILE" | jq -r '.total_tokens // 0') + INPUT_TOKENS=$(head -1 "$SESSION_FILE" | jq -r '.input_tokens // 0') + OUTPUT_TOKENS=$(head -1 "$SESSION_FILE" | jq -r '.output_tokens // 0') + echo "total_tokens=${TOKENS}" >> $GITHUB_OUTPUT + echo "input_tokens=${INPUT_TOKENS}" >> $GITHUB_OUTPUT + echo "output_tokens=${OUTPUT_TOKENS}" >> $GITHUB_OUTPUT + # Accumulated API usage metrics + ACC_TOKENS=$(head -1 "$SESSION_FILE" | jq -r '.accumulated_total_tokens // 0') + ACC_INPUT_TOKENS=$(head -1 "$SESSION_FILE" | jq -r '.accumulated_input_tokens // 0') + ACC_OUTPUT_TOKENS=$(head -1 "$SESSION_FILE" | jq -r '.accumulated_output_tokens // 0') + echo "accumulated_total_tokens=${ACC_TOKENS}" >> $GITHUB_OUTPUT + echo "accumulated_input_tokens=${ACC_INPUT_TOKENS}" >> $GITHUB_OUTPUT + echo "accumulated_output_tokens=${ACC_OUTPUT_TOKENS}" >> $GITHUB_OUTPUT + echo "Token usage - Total: ${TOKENS}, Input: ${INPUT_TOKENS}, Output: ${OUTPUT_TOKENS}" + echo "Accumulated usage - Total: ${ACC_TOKENS}, Input: ${ACC_INPUT_TOKENS}, Output: ${ACC_OUTPUT_TOKENS}" + fi fi - name: Create Pull Request @@ -140,9 +154,14 @@ jobs: - [ ] No unnecessary changes included ### Metrics - - **Total tokens used**: ${{ steps.metrics.outputs.total_tokens }} - - **Input tokens**: ${{ steps.metrics.outputs.input_tokens }} - - **Output tokens**: ${{ steps.metrics.outputs.output_tokens }} + #### Current Context Size + - **Total**: ${{ steps.metrics.outputs.total_tokens }} tokens + - **Input**: ${{ steps.metrics.outputs.input_tokens }} tokens + - **Output**: ${{ steps.metrics.outputs.output_tokens }} tokens + #### API Usage (Billable) + - **Total**: ${{ steps.metrics.outputs.accumulated_total_tokens }} tokens + - **Input**: ${{ steps.metrics.outputs.accumulated_input_tokens }} tokens + - **Output**: ${{ steps.metrics.outputs.accumulated_output_tokens }} tokens --- *Generated by the Daily Test Coverage Finder workflow* @@ -164,4 +183,4 @@ jobs: echo "📝 Function tested: $FUNCTION_NAME" else echo "â„šī¸ No suitable untested code found today" - fi + fi \ No newline at end of file