-
Notifications
You must be signed in to change notification settings - Fork 3
134 lines (113 loc) · 4.52 KB
/
api-tests.yml
File metadata and controls
134 lines (113 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# 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:
workflow_dispatch:
inputs:
version:
description: "SeaTable version (e.g. 6.1.8)"
required: true
default: "6.1.8"
image:
description: "Docker Hub repository"
required: true
type: choice
default: "seatable/seatable-enterprise"
options:
- "seatable/seatable-enterprise"
- "seatable/seatable-enterprise-testing"
jobs:
test:
runs-on: ubuntu-latest
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 }}" >> "$GITHUB_OUTPUT"
echo "image=${{ inputs.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
run: |
SEATABLE_IMAGE=${{ steps.version.outputs.image }} SEATABLE_VERSION=${{ steps.version.outputs.version }} 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