Skip to content

Add audit logs + tests #94

Add audit logs + tests

Add audit logs + tests #94

Workflow file for this run

# Validates API responses against OpenAPI schemas.
#
# Starts SeaTable via Docker, runs the test suite with schema validation,
# and reports any spec violations.
#
# Required GitHub Secrets:
# DOCKERHUB_USERNAME - Docker Hub username (for private image access)
# DOCKERHUB_TOKEN - Docker Hub Personal Access Token
# SEATABLE_LICENSE - SeaTable Enterprise license file content
name: "[RUN] API Tests"
on:
push:
workflow_dispatch:
inputs:
version:
description: "SeaTable version"
required: true
default: "7.0.7"
image:
description: "Docker Hub repository"
required: true
type: choice
default: "seatable/seatable-enterprise"
options:
- "seatable/seatable-enterprise"
- "seatable/seatable-enterprise-testing"
env:
DEFAULT_VERSION: "7.0.7"
DEFAULT_IMAGE: "seatable/seatable-enterprise-testing"
DTABLE_SERVER_VERSION: "7.0.7-testing"
jobs:
test:
runs-on: ubuntu-26.04
steps:
- name: Check out repo
uses: actions/checkout@v6
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Determine SeaTable version
id: version
run: |
echo "version=${{ inputs.version || env.DEFAULT_VERSION }}" >> "$GITHUB_OUTPUT"
echo "image=${{ inputs.image || env.DEFAULT_IMAGE }}" >> "$GITHUB_OUTPUT"
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install test dependencies
run: pip install -r tests/requirements.txt
- name: Write SeaTable license file
working-directory: version-compare
env:
SEATABLE_LICENSE: ${{ secrets.SEATABLE_LICENSE }}
run: echo "${SEATABLE_LICENSE}" > seatable-license.txt
- name: Start SeaTable ${{ steps.version.outputs.version }}
working-directory: version-compare
env:
SEATABLE_IMAGE: ${{ steps.version.outputs.image }}
SEATABLE_VERSION: ${{ steps.version.outputs.version }}
run: |
docker compose up -d
./setup.sh
- name: Run API tests
working-directory: tests
run: |
set -a && source ../version-compare/.env && set +a
pytest --color=yes -v 2>&1 | tee /tmp/test-output.txt
continue-on-error: true
- name: Generate report
if: always()
run: |
mkdir -p /tmp/report
passed=$(grep -oE '[0-9]+ passed' /tmp/test-output.txt | head -1 || echo "0 passed")
failed=$(grep -oE '[0-9]+ failed' /tmp/test-output.txt | head -1 || echo "")
errors=$(grep -oE '[0-9]+ error' /tmp/test-output.txt | head -1 || echo "")
cat > /tmp/report/summary.md << HEADER
# API Test Report
**SeaTable:** ${{ steps.version.outputs.image }}:${{ steps.version.outputs.version }}
**Branch:** ${GITHUB_REF_NAME}
**Results:** ${passed} ${failed} ${errors}
HEADER
if grep -qE "FAILED|ERROR" /tmp/test-output.txt; then
echo "" >> /tmp/report/summary.md
echo "## Failures" >> /tmp/report/summary.md
echo "" >> /tmp/report/summary.md
echo '```' >> /tmp/report/summary.md
grep -E "^FAILED" /tmp/test-output.txt >> /tmp/report/summary.md || true
echo '```' >> /tmp/report/summary.md
if grep -q "CheckFailed" /tmp/test-output.txt; then
echo "" >> /tmp/report/summary.md
echo "## Schema Validation Failures" >> /tmp/report/summary.md
echo "" >> /tmp/report/summary.md
echo '```' >> /tmp/report/summary.md
grep -B 2 -A 10 "Response violates schema" /tmp/test-output.txt \
| head -200 >> /tmp/report/summary.md || true
echo '```' >> /tmp/report/summary.md
fi
else
echo "" >> /tmp/report/summary.md
echo "All tests passed. API responses conform to OpenAPI schemas." >> /tmp/report/summary.md
fi
cp /tmp/test-output.txt /tmp/report/
- name: Stop SeaTable
if: always()
working-directory: version-compare
run: SEATABLE_VERSION=${{ steps.version.outputs.version }} docker compose down -v
- name: Upload test report
if: always()
uses: actions/upload-artifact@v7
with:
name: api-tests-${{ steps.version.outputs.version }}
path: /tmp/report/
retention-days: 30
- name: Fail if tests failed
run: |
if grep -qE '[0-9]+ (failed|error)' /tmp/test-output.txt; then
exit 1
fi