-
Notifications
You must be signed in to change notification settings - Fork 62
191 lines (161 loc) · 6.08 KB
/
pull-request.yml
File metadata and controls
191 lines (161 loc) · 6.08 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Pull Request CI
on:
pull_request:
branches: [master]
types: [opened, synchronize, reopened]
jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint:check
unit-test:
name: Unit Tests
needs: lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run unit tests with coverage
run: npm run test:coverage
- name: Upload unit test coverage
uses: actions/upload-artifact@v4
with:
name: unit-coverage
path: coverage/
retention-days: 5
e2e-test:
name: E2E Tests
needs: lint
runs-on: ubuntu-latest
environment: integration
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Create .env.test file
run: |
echo "PUBLIC_ENV_NAME=${{ secrets.PUBLIC_ENV_NAME }}" > .env.integration
echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" >> .env.integration
echo "SUPABASE_PUBLIC_KEY=${{ secrets.SUPABASE_PUBLIC_KEY }}" >> .env.integration
echo "SUPABASE_SERVICE_ROLE_KEY=${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}" >> .env.integration
echo "E2E_USERNAME_ID=${{ secrets.E2E_USERNAME_ID }}" >> .env.integration
echo "E2E_USERNAME=${{ secrets.E2E_USERNAME }}" >> .env.integration
echo "E2E_PASSWORD=${{ secrets.E2E_PASSWORD }}" >> .env.integration
echo "CF_CAPTCHA_SITE_KEY=${{ secrets.CF_CAPTCHA_SITE_KEY }}" >> .env.integration
echo "CF_CAPTCHA_SECRET_KEY=${{ secrets.CF_CAPTCHA_SECRET_KEY }}" >> .env.integration
- name: Run E2E tests
run: npm run test:e2e
- name: Upload E2E test artifacts
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
retention-days: 5
status-comment:
name: Update PR Status
needs: [lint, unit-test, e2e-test]
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get PR details
id: pr_details
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const pr_number = context.issue.number;
return { owner, repo, pr_number };
- name: Download unit test coverage
uses: actions/download-artifact@v4
with:
name: unit-coverage
path: unit-coverage
- name: Download E2E report
uses: actions/download-artifact@v4
with:
name: playwright-report
path: playwright-report
- name: Create status comment
uses: actions/github-script@v7
if: ${{ needs.unit-test.result == 'success' && needs.e2e-test.result == 'success' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo, pr_number } = ${{ steps.pr_details.outputs.result }};
github.rest.issues.createComment({
owner,
repo,
issue_number: pr_number,
body: `✅ All checks have passed successfully!\n\n` +
`- Lint: ✅\n` +
`- Unit Tests: ✅\n` +
`- E2E Tests: ✅\n\n` +
`Coverage reports have been uploaded as artifacts.`
});
- name: Create failure comment
uses: actions/github-script@v7
if: ${{ needs.unit-test.result != 'success' || needs.e2e-test.result != 'success' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo, pr_number } = ${{ steps.pr_details.outputs.result }};
const lintStatus = "${{ needs.lint.result }}" === "success" ? "✅" : "❌";
const unitStatus = "${{ needs.unit-test.result }}" === "success" ? "✅" : "❌";
const e2eStatus = "${{ needs.e2e-test.result }}" === "success" ? "✅" : "❌";
github.rest.issues.createComment({
owner,
repo,
issue_number: pr_number,
body: `❌ Some checks have failed!\n\n` +
`- Lint: ${lintStatus}\n` +
`- Unit Tests: ${unitStatus}\n` +
`- E2E Tests: ${e2eStatus}\n\n` +
`Please check the workflow logs for details.`
});
deploy-mcp-worker:
name: Deploy Worker (mcp-server)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# We need Node.js to generate rules and run wrangler/npm
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc' # Assuming .nvmrc is in the root
cache: 'npm'
cache-dependency-path: '**/package-lock.json' # Cache npm deps for root and worker
- name: Install root dependencies
run: npm ci
- name: Generate preparedRules.json
run: npm run generate-rules # Assuming direct execution works
- name: Install worker dependencies
run: cd mcp-server && npm ci