Skip to content

Update Tests Results #114

Update Tests Results

Update Tests Results #114

Workflow file for this run

name: Update Tests Results
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' # Runs every Monday at 00:00 UTC
jobs:
run_tests_and_update_markdown:
runs-on: ubuntu-latest
env:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }}
FIRECRAWL_API_KEY: ${{ secrets.FIRECRAWL_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
TOGETHER_API_KEY: ${{ secrets.TOGETHER_API_KEY }}
# utils.ts forwards these into the sandbox but the workflow never defined
# them. NOTE: these secrets are not set on the repo yet, so they resolve to
# empty and the watsonx examples stay out of the test list until they are.
WATSONX_API_KEY: ${{ secrets.WATSONX_API_KEY }}
WATSONX_PROJECT_ID: ${{ secrets.WATSONX_PROJECT_ID }}
WATSONX_URL: ${{ secrets.WATSONX_URL }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: '22'
- name: Install dependencies
run: npm install
# Kept as continue-on-error so the reporting steps below still run on failure.
# The "Fail if any example failed" step at the end is what turns the job red.
# The runner writes ./tests/results.json itself.
- name: Run the examples and save results
id: tests
run: npm test
continue-on-error: true
- name: Upload test results as an artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: ./tests/results.json
- name: Upload per-example logs as an artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: example-logs
path: ./logs
if-no-files-found: warn
- name: Update Tests.md with test results
if: always()
run: node ./tests/updateTestsMd.js # Your custom script to update Tests.md with test results
- name: Upload markdown report as an artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-md
path: ./tests/Tests.txt
- name: Read Tests.txt for Slack message
if: always()
id: read_tests
run: |
TESTS_CONTENT=$(cat ./tests/Tests.txt)
echo "TESTS_CONTENT<<EOF" >> $GITHUB_ENV
echo "$TESTS_CONTENT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Notify Slack with test results
if: always()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ steps.tests.outcome == 'success' && '#36a64f' || '#d00000' }}
SLACK_MESSAGE: |
*Test Results:*
${{ env.TESTS_CONTENT }}
SLACK_TITLE: Test Results Update
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }}
# Without this the workflow reported success while examples were failing.
- name: Fail if any example failed
if: steps.tests.outcome == 'failure'
run: |
echo "One or more examples failed. See the test-results and example-logs artifacts."
exit 1