114 lines
4.3 KiB
YAML
114 lines
4.3 KiB
YAML
name: Scheduled Optimization Tests
|
|
run-name: "${{ github.event.schedule == '0 2 * * 0' && 'Weekly' || 'Daily' }} scheduled Optimization Tests"
|
|
|
|
on:
|
|
# We create two different (overlapping) schedules - a daily schedule and a weekly schedule
|
|
# We detect the schedule in the job definition, and run different tests depending on the schedule
|
|
# If you change any of the 'cron' strings below, make sure to also update them in the 'optimizations-tests' definition below
|
|
schedule:
|
|
# Run daily at 2 AM UTC
|
|
- cron: "0 2 * * *"
|
|
# Run weekly at 2 AM UTC
|
|
- cron: "0 2 * * 0"
|
|
workflow_dispatch: # Allow manual triggering
|
|
|
|
permissions:
|
|
contents: read # Required for checkout or repository metadata reads.
|
|
actions: read # Required to read workflow run, cache, or artifact metadata.
|
|
|
|
env:
|
|
CARGO_INCREMENTAL: 0
|
|
FORCE_COLOR: 1
|
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }}
|
|
TOGETHER_API_KEY: ${{ secrets.TOGETHER_API_KEY }}
|
|
GOOGLE_APPLICATION_CREDENTIALS: ${{ github.workspace }}/gcp_jwt_key.json
|
|
WEEKLY_TESTS: "test_slow_optimization_openai_rft"
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
optimization-tests:
|
|
name: optimization-tests
|
|
if: github.repository == 'tensorzero/tensorzero'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 90
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Cleanup disk space
|
|
run: bash ci/free-disk-space.sh
|
|
|
|
- name: Write GCP JWT key to file
|
|
env:
|
|
GCP_JWT_KEY: ${{ secrets.GCP_JWT_KEY }}
|
|
run: echo "$GCP_JWT_KEY" > $GITHUB_WORKSPACE/gcp_jwt_key.json
|
|
|
|
- name: Install Rust (from rust-toolchain.toml)
|
|
working-directory: crates
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
if timeout 5m rustup show; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install Rust toolchain after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
shell: bash
|
|
|
|
- name: Cache Rust dependencies
|
|
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
|
|
with:
|
|
shared-key: "optimization-test-cache"
|
|
workspaces: "crates -> target"
|
|
|
|
- name: Install cargo-nextest
|
|
uses: taiki-e/install-action@60581cd7025e0e855cebd745379013e286d9c787 # v2.64.2
|
|
with:
|
|
tool: cargo-nextest
|
|
|
|
- name: Launch ClickHouse container for optimization tests
|
|
run: docker compose -f crates/tensorzero-optimizers/tests/docker-compose.yml up --wait
|
|
|
|
- name: Run daily optimization tests
|
|
working-directory: crates
|
|
if: github.event.schedule == '0 2 * * *' || github.event_name == 'workflow_dispatch'
|
|
run: TENSORZERO_CLICKHOUSE_URL=http://chuser:chpassword@localhost:8123/tensorzero_e2e_tests cargo test-optimization --nocapture --no-fail-fast -- --skip "$WEEKLY_TESTS"
|
|
|
|
- name: Run weekly optimization tests
|
|
working-directory: crates
|
|
if: github.event.schedule == '0 2 * * 0'
|
|
run: TENSORZERO_CLICKHOUSE_URL=http://chuser:chpassword@localhost:8123/tensorzero_e2e_tests cargo test-optimization --nocapture --no-fail-fast "$WEEKLY_TESTS"
|
|
|
|
- name: Print ClickHouse container logs
|
|
if: always()
|
|
continue-on-error: true
|
|
run: docker compose -f crates/tensorzero-optimizers/tests/docker-compose.yml logs -t
|
|
|
|
- name: Log test completion
|
|
if: always()
|
|
env:
|
|
TEST_RESULT: ${{ job.status }}
|
|
run: |
|
|
echo "Optimization tests completed at $(date)"
|
|
echo "Test result: $TEST_RESULT"
|
|
|
|
- name: Post to Slack on failure
|
|
if: failure()
|
|
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
|
|
with:
|
|
method: chat.postMessage
|
|
token: ${{ secrets.SLACK_BOT_TOKEN }}
|
|
payload: |
|
|
channel: C09DM0RGDFG
|
|
text: Live optimization tests failed for run <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_id }}>
|