-
-
Notifications
You must be signed in to change notification settings - Fork 1k
314 lines (286 loc) · 10.5 KB
/
pull-request.yml
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
##############################################################################
##############################################################################
#
# NOTE!
#
# Please read the README.md file in this directory that defines what should
# be placed in this file.
#
##############################################################################
##############################################################################
name: Pull request workflow
on:
pull_request:
branches:
- "**"
jobs:
check_base_branch:
# only run the job if the pull request actor is not dependabot
if: ${{ github.actor != 'dependabot[bot]' }}
name: Check base branch of the pull request to be develop-postgres
runs-on: ubuntu-latest
steps:
- if: github.event.pull_request.base.ref != 'develop-postgres'
name: Check base branch
run: |
echo "Pull requests are only allowed against the 'develop-postgres' branch. Please refer to the pull request guidelines."
echo "Error: Close this PR and try again."
exit 1
Code-Quality-Checks:
name: Checking code quality
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Build talawa api non production environment docker image
run: docker buildx build --file ./docker/api.Containerfile --tag talawa_api --target non_production ./
- name: Check type errors
run: docker container run talawa_api pnpm check_code_quality
- name: Check if the source and target branches are different
if: ${{ github.event.pull_request.base.ref == github.event.pull_request.head.ref }}
run: |
echo "Source Branch ${{ github.event.pull_request.head.ref }}"
echo "Target Branch ${{ github.event.pull_request.base.ref }}"
echo "Error: Source and Target Branches are the same. Please ensure they are different."
echo "Error: Close this PR and try again."
exit 1
check_biome_ignore:
name: Check for biome_ignore
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Run Python script
run: |
python .github/workflows/scripts/biome_disable_check.py --files ${{ steps.changed-files.outputs.all_changed_files }}
check_code_coverage_disable:
name: Check for code coverage disable
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Run Python script
run: |
python .github/workflows/scripts/code_coverage_disable_check.py --files ${{ steps.changed-files.outputs.all_changed_files }}
check_gql_tada:
name: Check gql tada files and configuration
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Build talawa api non production environment docker image
run: docker buildx build --file ./docker/api.Containerfile --tag talawa_api --target non_production ./
- name: Check gql tada
run: docker container run talawa_api pnpm check_gql_tada
check_drizzle_migrations:
name: Check drizzle migration files
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Build talawa api non production environment docker image
run: docker buildx build --file ./docker/api.Containerfile --tag talawa_api --target non_production ./
- name: Check drizzle migrations
run: docker container run --env-file ./envFiles/.env.ci talawa_api pnpm check_drizzle_migrations
check_type_errors:
name: Check type errors
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Build talawa api non production environment docker image
run: docker buildx build --file ./docker/api.Containerfile --tag talawa_api --target non_production ./
- name: Check type errors
run: docker container run talawa_api pnpm check_type_errors
Check-Sensitive-Files:
if: ${{ github.actor != 'dependabot[bot]' && !contains(github.event.pull_request.labels.*.name, 'ignore-sensitive-files-pr') }}
name: Checks if sensitive files have been changed without authorization
needs: [Code-Quality-Checks]
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]
- id: changed_files
name: Get changed files
uses: tj-actions/[email protected]
with:
files: |
.coderabbit.yaml
Caddyfile
codegen.ts
Dockerfile*
docker-compose*
drizzle_migrations/**
.dockerignore
.env.sample
.env_test
eslint.config.mjs
envFiles/**
.gitignore
init-mongo.sh
.prettierignore
.prettierrc.json
.pylintrc
.github/**
biome.jsonc
drizzle_migrations/**
renovate.json
requirements.txt
schema.graphql
CODEOWNERS
LICENSE
tsconfig.json
vitest.config.ts
pnpm-lock.yaml
package.json
package-lock.json
.nojekyll
docs/docusaurus.config.ts
docs/sidebar*
setup.ts
tsconfig.build.json
vite.config.mts
CNAME
CODE_OF_CONDUCT.md
CODE_STYLE.md
CONTRIBUTING.md
DOCUMENTATION.md
INSTALLATION.md
ISSUE_GUIDELINES.md
PR_GUIDELINES.md
README.md
- env:
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
if: steps.changed_files.outputs.any_changed == 'true' || steps.changed_files.outputs.any_deleted == 'true'
name: Show changed files
run: |
echo "Unauthorized changes were made in the following files:"
for FILE in ${CHANGED_FILES}; do
echo "$FILE"
done
echo "To override this, apply the 'ignore-sensitive-files-pr' label"
exit 1
Run-Tests:
name: Run tests for talawa api
runs-on: ubuntu-latest
needs: [Code-Quality-Checks, check_code_coverage_disable]
env:
CODECOV_UNIQUE_NAME: ${{github.workflow}}-${{github.ref_name}}
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Create .env file for talawa api testing environment
run: cp ./envFiles/.env.ci ./.env
- name: Build talawa api compose testing environment
run: docker compose build
- name: Run tests
run: docker compose up --exit-code-from api
- name: Copy coverage from container
run: |
CONTAINER_ID=$(docker ps -aq --filter "ancestor=talawa-api")
docker cp $CONTAINER_ID:/home/talawa/api/coverage ./coverage
- name: Present and upload coverage to Codecov as ${{env.CODECOV_UNIQUE_NAME}}
uses: codecov/codecov-action@v4
with:
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
name: "${{env.CODECOV_UNIQUE_NAME}}"
- name: Test acceptable level of code coverage
uses: VeryGoodOpenSource/very_good_coverage@v2
with:
path: "./coverage/lcov.info"
min_coverage: 39.0
Test-Docusaurus-Deployment:
name: Test Deployment to https://docs-api.talawa.io
runs-on: ubuntu-latest
needs: [Run-Tests]
# Run only if the develop-postgres branch and not dependabot
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.base.ref == 'develop-postgres' }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
cache: pnpm
cache-dependency-path: |
docs/pnpm-lock.yaml
docs/package.json
# Run Docusaurus in the ./docs directory
- name: Install dependencies
working-directory: ./docs
run: pnpm install --frozen-lockfile
- name: Test building the website
working-directory: ./docs
run: pnpm build
Validate-Coderabbit:
name: Validate CodeRabbit Approval
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
needs: [Test-Docusaurus-Deployment]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Validate CodeRabbit.ai Approval
run: |
chmod +x .github/workflows/scripts/validate-coderabbit.sh
.github/workflows/scripts/validate-coderabbit.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_REPOSITORY: ${{ github.repository }}
Python-Compliance:
name: Check Python Code Style
runs-on: ubuntu-latest
needs: [Code-Quality-Checks]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python3 -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r .github/workflows/requirements.txt
- name: Run Black Formatter Check
run: |
source venv/bin/activate
black --check .
- name: Run Flake8 Linter
run: |
source venv/bin/activate
flake8 --docstring-convention google --ignore E402,E722,E203,F401,W503 .github
- name: Run pydocstyle
run: |
source venv/bin/activate
pydocstyle --convention=google --add-ignore=D415,D205 .github
- name: Run docstring compliance check
run: |
source venv/bin/activate
python .github/workflows/scripts/check_docstrings.py --directories .github