Enhance document attachment with schema validation #4016
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
paths-ignore: | |
- "api/docs/**" | |
- "build/charts/**" | |
- "design/**" | |
- "**/*.md" | |
- "**/*.txt" | |
- "**/.gitignore" | |
env: | |
GO_VERSION: "1.23" | |
jobs: | |
ci-target-check: | |
runs-on: ubuntu-latest | |
outputs: | |
build: ${{ steps.ci-target-check.outputs.build }} | |
bench: ${{ steps.ci-target-check.outputs.bench }} | |
complex-test: ${{ steps.ci-target-check.outputs.complex-test }} | |
load-test: ${{ steps.ci-target-check.outputs.load-test }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: CI target check by path | |
uses: dorny/paths-filter@v3 | |
id: ci-target-check | |
with: | |
filters: | | |
build: '**' | |
bench: | |
- 'test/bench/**' | |
- 'pkg/**' | |
- 'server/**' | |
- 'client/**' | |
- 'admin/**' | |
- 'cluster/**' | |
- 'api/converter/**' | |
complex-test: | |
- 'test/complex/**' | |
- 'server/backend/database/**' | |
- 'pkg/document/**' | |
- 'client/**' | |
load-test: | |
- 'test/k6/**' | |
- 'pkg/**' | |
- 'server/**' | |
- 'client/**' | |
- 'admin/**' | |
- 'cluster/**' | |
- 'api/converter/**' | |
build: | |
name: build | |
runs-on: ubuntu-latest | |
needs: ci-target-check | |
if: ${{ github.ref == 'refs/heads/main' || needs.ci-target-check.outputs.build == 'true' }} | |
steps: | |
- name: Set up Go ${{ env.GO_VERSION }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Setup buf action | |
uses: bufbuild/buf-setup-action@v1 | |
with: | |
github_token: ${{ github.token }} | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Get tools dependencies | |
run: make tools | |
- name: Lint | |
run: make lint | |
- name: Lint proto files | |
uses: bufbuild/buf-lint-action@v1 | |
- name: Build | |
run: make build | |
- name: Stack | |
run: docker compose -f build/docker/docker-compose.yml up --build -d | |
- name: Test | |
run: go test -tags integration -race -coverprofile=coverage.txt -covermode=atomic -v ./... | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage.txt | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
bench: | |
name: bench | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: ci-target-check | |
if: ${{ github.ref == 'refs/heads/main' || needs.ci-target-check.outputs.bench == 'true' }} | |
steps: | |
- name: Set up Go ${{ env.GO_VERSION }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Checkout current repository | |
uses: actions/checkout@v4 | |
with: | |
path: repo | |
- name: Checkout benchmark branch | |
uses: actions/checkout@v4 | |
with: | |
ref: yorkie-ci-benchmark | |
path: benchmark-repo | |
continue-on-error: true | |
- name: Read previous benchmark result | |
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.repository | |
id: prev-bench | |
run: | | |
echo "PREV_BENCH_RESULT=null" >> $GITHUB_OUTPUT | |
echo "PREV_COMMIT=null" >> $GITHUB_OUTPUT | |
if [ -d "benchmark-repo" ] && [ -f "benchmark-repo/bench_result.txt" ]; then | |
content=$(cat benchmark-repo/bench_result.txt | jq -R -s .) | |
echo "PREV_BENCH_RESULT=$content" >> $GITHUB_OUTPUT | |
if [ -f "benchmark-repo/commit_hash.txt" ]; then | |
prev_commit=$(cat benchmark-repo/commit_hash.txt) | |
echo "PREV_COMMIT=$prev_commit" >> $GITHUB_OUTPUT | |
fi | |
fi | |
- name: Stack | |
run: docker compose -f repo/build/docker/docker-compose.yml up --build -d | |
- name: Bench | |
id: curr-bench | |
run: | | |
cd repo | |
make bench | |
content=$(cat output.txt | jq -R -s .) | |
echo "BENCH_RESULT=$content" >> $GITHUB_OUTPUT | |
- name: Trigger n8n webhook | |
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.repository | |
env: | |
BENCH_RESULT: ${{ steps.curr-bench.outputs.BENCH_RESULT }} | |
PREV_BENCH_RESULT: ${{ steps.prev-bench.outputs.PREV_BENCH_RESULT }} | |
run: | | |
payload=$(jq -n \ | |
--arg repo "${{ github.repository }}" \ | |
--arg pr_number "${{ github.event.pull_request.number }}" \ | |
--arg commit_id "${{ github.sha }}" \ | |
--arg prev_commit_id "${{ steps.prev-bench.outputs.PREV_COMMIT }}" \ | |
--arg bench_result "$BENCH_RESULT" \ | |
--arg prev_bench_result "$PREV_BENCH_RESULT" \ | |
'{ | |
target: "bench", | |
repo: $repo, | |
pr_number: $pr_number, | |
commit_id: $commit_id, | |
prev_commit_id: $prev_commit_id, | |
bench_result: $bench_result, | |
prev_bench_result: $prev_bench_result, | |
}') | |
response=$(curl -f -X POST ${{ secrets.N8N_WEBHOOK_URL }} \ | |
-H "Content-Type: application/json" \ | |
-d "$payload" || echo "CURL_ERROR") | |
if [ "$response" = "CURL_ERROR" ]; then | |
echo "::error::Failed to trigger n8n webhook" | |
exit 1 | |
fi | |
- name: Store benchmark result | |
if: github.ref == 'refs/heads/main' | |
run: | | |
mkdir -p benchmark-repo | |
cp repo/output.txt benchmark-repo/bench_result.txt | |
echo "${{ github.sha }}" > benchmark-repo/commit_hash.txt | |
cd benchmark-repo | |
git config user.name "GitHub Actions" | |
git config user.email "actions@github.com" | |
if [ ! -d ".git" ]; then | |
git init | |
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
fi | |
git add bench_result.txt | |
git add commit_hash.txt | |
TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M:%S UTC") | |
git diff --staged --quiet || git commit -m "Update benchmark results at $TIMESTAMP" | |
git checkout -B yorkie-ci-benchmark | |
git push -f origin yorkie-ci-benchmark | |
echo "Benchmark results have been pushed to yorkie-ci-benchmark branch" | |
complex-test: | |
name: complex-test | |
runs-on: ubuntu-latest | |
needs: ci-target-check | |
if: ${{ github.ref == 'refs/heads/main' || needs.ci-target-check.outputs.complex-test == 'true' }} | |
steps: | |
- name: Set up Go ${{ env.GO_VERSION }} | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Check Docker Compose Version | |
run: docker compose --version | |
- name: Run the Config server, Shard 1 and Shard 2 | |
run: docker compose -f build/docker/sharding/docker-compose.yml up --build -d --wait config1 shard1-1 shard2-1 | |
- name: Initialize the Config server | |
run: docker compose -f build/docker/sharding/docker-compose.yml exec config1 mongosh test /scripts/init-config1.js | |
- name: Initialize the Shard 1 | |
run: docker compose -f build/docker/sharding/docker-compose.yml exec shard1-1 mongosh test /scripts/init-shard1-1.js | |
- name: Initialize the Shard 2 | |
run: docker compose -f build/docker/sharding/docker-compose.yml exec shard2-1 mongosh test /scripts/init-shard2-1.js | |
- name: Run the Mongos | |
run: docker compose -f build/docker/sharding/docker-compose.yml up --build -d --wait mongos1 | |
- name: Initialize the Mongos | |
run: docker compose -f build/docker/sharding/docker-compose.yml exec mongos1 mongosh test /scripts/init-mongos1.js | |
- name: Run the tests with complex tag | |
run: go test -tags complex -race -v ./test/complex/... | |
load-test: | |
name: load-test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Set up Go ${{ env.GO_VERSION }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Checkout current repository | |
uses: actions/checkout@v4 | |
with: | |
path: repo | |
- name: Stack | |
run: docker compose -f repo/build/docker/docker-compose.yml up --build -d | |
- name: Checkout load branch | |
uses: actions/checkout@v4 | |
with: | |
ref: yorkie-ci-load | |
path: load-repo | |
continue-on-error: true | |
- name: Read previous load result | |
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.repository | |
id: prev-load | |
run: | | |
echo "PREV_LOAD_RESULT=null" >> $GITHUB_OUTPUT | |
echo "PREV_LOAD_SUMMARY=null" >> $GITHUB_OUTPUT | |
echo "PREV_COMMIT=null" >> $GITHUB_OUTPUT | |
if [ -d "load-repo" ] && [ -f "load-repo/load_summary.json" ]; then | |
content=$(cat load-repo/output.txt | jq -R -s .) | |
echo "PREV_LOAD_RESULT=$content" >> $GITHUB_OUTPUT | |
echo "PREV_LOAD_SUMMARY=$(jq -c . load-repo/load_summary.json)" >> $GITHUB_OUTPUT | |
if [ -f "load-repo/commit_hash.txt" ]; then | |
prev_commit=$(cat load-repo/commit_hash.txt) | |
echo "PREV_COMMIT=$prev_commit" >> $GITHUB_OUTPUT | |
fi | |
fi | |
- name: Setup K6 | |
uses: grafana/setup-k6-action@v1 | |
- name: Start the server | |
run: cd repo && make start | |
- name: Run local k6 test | |
id: curr-load | |
run: | | |
cd repo | |
sleep 5 | |
if ! k6 run test/k6/presence.ts --summary-export=summary.json | tee output.txt; then | |
echo "::error::K6 load test failed" | |
exit 1 | |
fi | |
echo "LOAD_RESULT=$(cat output.txt | jq -R -s .)" >> $GITHUB_OUTPUT | |
echo "LOAD_SUMMARY=$(jq -c . summary.json)" >> $GITHUB_OUTPUT | |
- name: Stop the server | |
run: cd repo && make stop | |
- name: Trigger n8n webhook | |
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.repository | |
env: | |
LOAD_RESULT: ${{ steps.curr-load.outputs.LOAD_RESULT }} | |
PREV_LOAD_RESULT: ${{ steps.prev-load.outputs.PREV_LOAD_RESULT }} | |
LOAD_SUMMARY: ${{ steps.curr-load.outputs.LOAD_SUMMARY }} | |
PREV_LOAD_SUMMARY: ${{ steps.prev-load.outputs.PREV_LOAD_SUMMARY }} | |
run: | | |
payload=$(jq -n \ | |
--arg repo "${{ github.repository }}" \ | |
--arg pr_number "${{ github.event.pull_request.number }}" \ | |
--arg commit_id "${{ github.sha }}" \ | |
--arg prev_commit_id "${{ steps.prev-load.outputs.PREV_COMMIT }}" \ | |
--arg load_result "$LOAD_RESULT" \ | |
--arg prev_load_result "$PREV_LOAD_RESULT" \ | |
--arg load_summary "$LOAD_SUMMARY" \ | |
--arg prev_load_summary "$PREV_LOAD_SUMMARY" \ | |
'{ | |
target: "load", | |
repo: $repo, | |
pr_number: $pr_number, | |
commit_id: $commit_id, | |
prev_commit_id: $prev_commit_id, | |
load_result: $load_result, | |
prev_load_result: $prev_load_result, | |
load_summary: $load_summary, | |
prev_load_summary: $prev_load_summary | |
}') | |
response=$(curl -f -X POST ${{ secrets.N8N_WEBHOOK_URL }} \ | |
-H "Content-Type: application/json" \ | |
-d "$payload" || echo "CURL_ERROR") | |
if [ "$response" = "CURL_ERROR" ]; then | |
echo "::error::Failed to trigger n8n webhook" | |
exit 1 | |
fi | |
- name: Store load result | |
if: github.ref == 'refs/heads/main' | |
run: | | |
mkdir -p load-repo | |
cp repo/summary.json load-repo/load_summary.json | |
cp repo/output.txt load-repo/output.txt | |
echo "${{ github.sha }}" > load-repo/commit_hash.txt | |
cd load-repo | |
git config user.name "GitHub Actions" | |
git config user.email "actions@github.com" | |
if [ ! -d ".git" ]; then | |
git init | |
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
fi | |
git add load_summary.json | |
git add output.txt | |
git add commit_hash.txt | |
TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M:%S UTC") | |
git diff --staged --quiet || git commit -m "Update load results at $TIMESTAMP" | |
git checkout -B yorkie-ci-load | |
git push -f origin yorkie-ci-load | |
echo "load results have been pushed to yorkie-ci-load branch" |