64 lines
2 KiB
YAML
64 lines
2 KiB
YAML
|
|
name: backend-integration-tests
|
||
|
|
|
||
|
|
on:
|
||
|
|
push:
|
||
|
|
branches:
|
||
|
|
- main
|
||
|
|
- high-performance
|
||
|
|
|
||
|
|
concurrency:
|
||
|
|
group: backend-tests-${{ github.ref }}
|
||
|
|
cancel-in-progress: true
|
||
|
|
|
||
|
|
jobs:
|
||
|
|
ai-credits:
|
||
|
|
runs-on: docker-ready
|
||
|
|
env:
|
||
|
|
TEST_DATABASE_URL: ${{ secrets.TEST_DATABASE_URL }}
|
||
|
|
steps:
|
||
|
|
- name: Checkout
|
||
|
|
uses: actions/checkout@v4
|
||
|
|
|
||
|
|
- name: Check for relevant changes
|
||
|
|
id: check
|
||
|
|
run: |
|
||
|
|
set -euo pipefail
|
||
|
|
if git rev-parse --verify HEAD^ >/dev/null 2>&1; then
|
||
|
|
BASE="${{ github.event.before }}"
|
||
|
|
if [ -z "$BASE" ] || [ "$BASE" = "0000000000000000000000000000000000000000" ] \
|
||
|
|
|| ! git rev-parse --verify "${BASE}^{commit}" >/dev/null 2>&1; then
|
||
|
|
BASE="HEAD^"
|
||
|
|
fi
|
||
|
|
CHANGED_FILES="$(git diff --name-only "$BASE" HEAD)"
|
||
|
|
else
|
||
|
|
CHANGED_FILES="$(git ls-files)"
|
||
|
|
fi
|
||
|
|
|
||
|
|
run=false
|
||
|
|
if echo "$CHANGED_FILES" | grep -Eq '^(crates/db/|Cargo\.toml|Cargo\.lock|\.forgejo/workflows/test\.yaml)'; then
|
||
|
|
run=true
|
||
|
|
fi
|
||
|
|
echo "run=$run" >> "$GITHUB_OUTPUT"
|
||
|
|
if [ "$run" = "false" ]; then
|
||
|
|
echo "No changes relevant to crates/db - skipping integration tests."
|
||
|
|
fi
|
||
|
|
|
||
|
|
- name: Verify TEST_DATABASE_URL is configured
|
||
|
|
if: steps.check.outputs.run == 'true'
|
||
|
|
run: |
|
||
|
|
test -n "${TEST_DATABASE_URL:-}" || { echo "TEST_DATABASE_URL secret is not set - see docs/LIVE_SERVER_RUNBOOK.md step 6"; exit 1; }
|
||
|
|
|
||
|
|
- name: Install Rust
|
||
|
|
if: steps.check.outputs.run == 'true'
|
||
|
|
run: |
|
||
|
|
set -euo pipefail
|
||
|
|
if ! command -v cargo >/dev/null 2>&1; then
|
||
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
||
|
|
fi
|
||
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||
|
|
|
||
|
|
- name: Run ai_credits integration tests
|
||
|
|
if: steps.check.outputs.run == 'true'
|
||
|
|
run: |
|
||
|
|
cargo test -p db --test ai_credits --test ai_credits_reaper -- --test-threads=1
|