Skip to content

Commit 73b1c41

Browse files
Copilothuangyiirene
andcommitted
Add necessary GitHub workflows for enhanced CI/CD and automation
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent eacd171 commit 73b1c41

9 files changed

Lines changed: 425 additions & 0 deletions
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "^http://localhost"
5+
},
6+
{
7+
"pattern": "^https://localhost"
8+
},
9+
{
10+
"pattern": "^http://127.0.0.1"
11+
},
12+
{
13+
"pattern": "^https://example.com"
14+
},
15+
{
16+
"pattern": "^https://www.google.com/search"
17+
}
18+
],
19+
"replacementPatterns": [],
20+
"httpHeaders": [
21+
{
22+
"urls": ["https://github.com"],
23+
"headers": {
24+
"Accept-Encoding": "zstd, br, gzip, deflate"
25+
}
26+
}
27+
],
28+
"timeout": "20s",
29+
"retryOn429": true,
30+
"retryCount": 3,
31+
"fallbackRetryDelay": "30s",
32+
"aliveStatusCodes": [200, 206]
33+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Auto-approve Dependabot PRs"
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
pull-requests: write
9+
contents: write
10+
11+
jobs:
12+
auto-approve:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 3
15+
if: github.actor == 'dependabot[bot]'
16+
steps:
17+
- name: Dependabot metadata
18+
id: metadata
19+
uses: dependabot/fetch-metadata@v2
20+
with:
21+
github-token: "${{ secrets.GITHUB_TOKEN }}"
22+
23+
- name: Auto-approve patch and minor updates
24+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'
25+
run: gh pr review --approve "$PR_URL"
26+
env:
27+
PR_URL: ${{ github.event.pull_request.html_url }}
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Comment on major updates
31+
if: steps.metadata.outputs.update-type == 'version-update:semver-major'
32+
run: |
33+
gh pr comment "$PR_URL" --body "⚠️ This is a **major version update**. Please review the changelog carefully before merging."
34+
env:
35+
PR_URL: ${{ github.event.pull_request.html_url }}
36+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/benchmark.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: "Performance Benchmark"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
benchmark:
16+
name: Run Performance Benchmarks
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 10
19+
services:
20+
redis:
21+
image: redis
22+
ports:
23+
- 6379:6379
24+
options: >-
25+
--health-cmd "redis-cli ping"
26+
--health-interval 10s
27+
--health-timeout 5s
28+
--health-retries 5
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- uses: pnpm/action-setup@v3
34+
with:
35+
version: 10
36+
37+
- name: Use Node.js 20.x
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 20.x
41+
cache: 'pnpm'
42+
43+
- name: Install dependencies
44+
run: pnpm install --frozen-lockfile
45+
timeout-minutes: 2
46+
47+
- name: Build packages
48+
run: pnpm run build
49+
timeout-minutes: 3
50+
51+
- name: Run benchmarks
52+
run: |
53+
echo "Checking for benchmark scripts..."
54+
if pnpm -r list | grep -q "benchmark"; then
55+
echo "Running benchmarks..."
56+
pnpm -r run benchmark --if-present
57+
else
58+
echo "No benchmark scripts found. Skipping benchmarks."
59+
echo "To add benchmarks, add a 'benchmark' script to package.json files."
60+
fi
61+
timeout-minutes: 5
62+
continue-on-error: true
63+
64+
- name: Store benchmark result
65+
if: github.ref == 'refs/heads/main'
66+
uses: benchmark-action/github-action-benchmark@v1
67+
with:
68+
name: ObjectQL Benchmarks
69+
tool: 'benchmarkjs'
70+
output-file-path: benchmark-results.json
71+
github-token: ${{ secrets.GITHUB_TOKEN }}
72+
auto-push: true
73+
comment-on-alert: true
74+
alert-threshold: '150%'
75+
fail-on-alert: false
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: "Changelog Preview"
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, labeled, unlabeled]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
changelog-preview:
13+
name: Generate Changelog Preview
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 5
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- uses: pnpm/action-setup@v3
23+
with:
24+
version: 10
25+
26+
- name: Use Node.js 20.x
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 20.x
30+
cache: 'pnpm'
31+
32+
- name: Install dependencies
33+
run: pnpm install --frozen-lockfile
34+
timeout-minutes: 2
35+
36+
- name: Generate Changeset Preview
37+
run: |
38+
echo "Checking for changeset files..."
39+
if [ -d ".changeset" ] && [ "$(ls -A .changeset/*.md 2>/dev/null | grep -v README | wc -l)" -gt 0 ]; then
40+
echo "### 📋 Changelog Preview" > changeset-preview.md
41+
echo "" >> changeset-preview.md
42+
echo "The following changes will be included in the next release:" >> changeset-preview.md
43+
echo "" >> changeset-preview.md
44+
pnpm changeset status --verbose >> changeset-preview.md 2>&1 || echo "Changeset status completed with warnings"
45+
else
46+
echo "### ⚠️ No Changeset Found" > changeset-preview.md
47+
echo "" >> changeset-preview.md
48+
echo "This PR does not include a changeset file." >> changeset-preview.md
49+
echo "If this PR includes user-facing changes, please add a changeset by running:" >> changeset-preview.md
50+
echo "\`\`\`bash" >> changeset-preview.md
51+
echo "pnpm changeset" >> changeset-preview.md
52+
echo "\`\`\`" >> changeset-preview.md
53+
fi
54+
timeout-minutes: 1
55+
56+
- name: Comment Changeset Preview
57+
uses: thollander/actions-comment-pull-request@v2
58+
with:
59+
filePath: changeset-preview.md
60+
comment-tag: changeset-preview

.github/workflows/cleanup-runs.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Delete Old Workflow Runs"
2+
3+
on:
4+
schedule:
5+
# Run every week on Sunday at 00:00 UTC
6+
- cron: '0 0 * * 0'
7+
workflow_dispatch:
8+
9+
permissions:
10+
actions: write
11+
contents: read
12+
13+
jobs:
14+
delete-old-runs:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 10
17+
steps:
18+
- name: Delete workflow runs older than 30 days
19+
uses: Mattraks/delete-workflow-runs@v2
20+
with:
21+
token: ${{ github.token }}
22+
repository: ${{ github.repository }}
23+
retain_days: 30
24+
keep_minimum_runs: 6

.github/workflows/coverage.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Test Coverage
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
coverage:
11+
name: Test Coverage Report
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 8
14+
services:
15+
redis:
16+
image: redis
17+
ports:
18+
- 6379:6379
19+
options: >-
20+
--health-cmd "redis-cli ping"
21+
--health-interval 10s
22+
--health-timeout 5s
23+
--health-retries 5
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: pnpm/action-setup@v3
29+
with:
30+
version: 10
31+
32+
- name: Use Node.js 20.x
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: 20.x
36+
cache: 'pnpm'
37+
38+
- name: Cache MongoDB Binary
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.cache/mongodb-binaries
42+
key: mongodb-binaries-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
43+
restore-keys: |
44+
mongodb-binaries-${{ runner.os }}-
45+
46+
- name: Install dependencies
47+
run: pnpm install --frozen-lockfile
48+
timeout-minutes: 2
49+
50+
- name: Setup MongoDB Memory Server
51+
run: |
52+
# Pre-download MongoDB binary for mongodb-memory-server
53+
cd packages/drivers/mongo
54+
npx mongodb-memory-server preinstall || echo "MongoDB binary download failed, tests will skip gracefully"
55+
timeout-minutes: 1
56+
continue-on-error: true
57+
58+
- name: Build packages
59+
run: pnpm run build
60+
timeout-minutes: 3
61+
62+
- name: Run tests with coverage
63+
run: pnpm -r run test -- --coverage --coverageReporters=text --coverageReporters=lcov
64+
timeout-minutes: 5
65+
continue-on-error: true
66+
67+
- name: Upload coverage reports to Codecov
68+
uses: codecov/codecov-action@v4
69+
with:
70+
token: ${{ secrets.CODECOV_TOKEN }}
71+
files: ./packages/*/coverage/lcov.info
72+
flags: unittests
73+
name: codecov-umbrella
74+
fail_ci_if_error: false
75+
verbose: true

.github/workflows/link-checker.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Check Documentation Links"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- 'docs/**'
8+
- '**/*.md'
9+
pull_request:
10+
branches: [ "main" ]
11+
paths:
12+
- 'docs/**'
13+
- '**/*.md'
14+
schedule:
15+
# Run weekly on Monday at 00:00 UTC
16+
- cron: '0 0 * * 1'
17+
workflow_dispatch:
18+
19+
permissions:
20+
contents: read
21+
issues: write
22+
23+
jobs:
24+
link-checker:
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 5
27+
steps:
28+
- name: Checkout Repository
29+
uses: actions/checkout@v4
30+
31+
- name: Check Links in Markdown Files
32+
uses: gaurav-nelson/github-action-markdown-link-check@v1
33+
with:
34+
use-quiet-mode: 'yes'
35+
use-verbose-mode: 'no'
36+
config-file: '.github/markdown-link-check-config.json'
37+
folder-path: '.'
38+
file-path: './README.md'
39+
max-depth: -1
40+
check-modified-files-only: 'no'
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: "PR Size Labeler"
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
size-label:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 3
15+
steps:
16+
- name: Label PR by Size
17+
uses: codelytv/pr-size-labeler@v1
18+
with:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
xs_label: 'size/XS'
21+
xs_max_size: 10
22+
s_label: 'size/S'
23+
s_max_size: 50
24+
m_label: 'size/M'
25+
m_max_size: 200
26+
l_label: 'size/L'
27+
l_max_size: 500
28+
xl_label: 'size/XL'
29+
fail_if_xl: false
30+
message_if_xl: >
31+
This PR is very large. Consider splitting it into smaller PRs for easier review.
32+
files_to_ignore: |
33+
pnpm-lock.yaml
34+
package-lock.json
35+
yarn.lock
36+
*.md
37+
*.txt

0 commit comments

Comments
 (0)