-
-
Notifications
You must be signed in to change notification settings - Fork 892
243 lines (211 loc) · 7.27 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
##############################################################################
##############################################################################
#
# NOTE!
#
# Please read the README.md file in this directory that defines what should
# be placed in this file.
#
##############################################################################
##############################################################################
name: PR Workflow
on:
pull_request:
branches:
- '**'
env:
CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }}
jobs:
Code-Quality-Checks:
name: Check for linting, formatting, and type errors
runs-on: ubuntu-latest
steps:
- name: Checkout repository content
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Count number of lines
run: |
chmod +x ./.github/workflows/countline.py
./.github/workflows/countline.py --lines 600 --exclude_files src/types/generatedGraphQLTypes.ts tests
- name: Restore node_modules from cache
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-code-quality-checks-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-code-quality-checks-${{ env.cache-name }}-
${{ runner.os }}-code-quality-checks-
${{ runner.os }}-
- name: Install Dependencies
run: npm ci
# Lint, but exclude typescript files in the .eslintignore file
# or else we'll get failures
- name: Get changed files
id: changed_files
uses: tj-actions/changed-files@v42
with:
files: |
**.ts
'!src/types/**.ts'
- name: Run ESLint to check for linting errors in modified files
if: steps.changed_files.outputs.any_changed == 'true'
env:
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
run: npx eslint ${CHANGED_FILES}
- name: Check for formatting errors
run: npm run format:check
- name: Run Typescript Type-Checker
run: npm run typecheck
File-count-check:
name: Counting files changed
runs-on: ubuntu-latest
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Checkout code
run: git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-branch
working-directory: ${{ github.workspace }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11.6'
- name: Compare changes between Base branch and PR Head.
id: changed-files-base
run: |
git fetch origin $BASE_BRANCH
git checkout $BASE_BRANCH
python .github/workflows/check_files_submitted.py \
--base_branch $BASE_BRANCH --pr_branch pr-branch
Test-Application:
name: Testing Application
runs-on: ubuntu-latest
needs: [Code-Quality-Checks]
strategy:
matrix:
node-version: [20.x]
services:
mongo:
image: mongo:4.4
options: >-
--health-cmd mongo
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 27017:27017
redis:
image: redis:6.0
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 6379:6379
env:
MONGO_DB_URL: mongodb://localhost:27017/talawa-test-db
REDIS_HOST: localhost
REDIS_PORT: 6379
RECAPTCHA_SITE_KEY: ${{secrets.RECAPTCHA_SITE_KEY}}
RECAPTCHA_SECRET_KEY: ${{secrets.RECAPTCHA_SECRET_KEY}}
MAIL_USERNAME: ${{secrets.MAIL_USERNAME}}
MAIL_PASSWORD: ${{secrets.MAIL_PASSWORD}}
IS_SMTP: ""
SMTP_HOST: ""
SMTP_PASSWORD: ""
SMTP_USERNAME: ""
LAST_RESORT_SUPERADMIN_EMAIL: "abc@gmail.com"
COLORIZE_LOGS: "true"
LOG_LEVEL: "info"
# ACCESS_TOKEN_SECRET: ${{ secrets.ACCESS_TOKEN_SECRET }}
# REFRESH_TOKEN_SECRET: ${{ secrets.REFRESH_TOKEN_SECRET }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Generate Access Token Secret
run: echo "ACCESS_TOKEN_SECRET=$(openssl rand -hex 32)" >> $GITHUB_ENV
- name: Generate Refresh Token Secret
run: echo "REFRESH_TOKEN_SECRET=$(openssl rand -hex 32)" >> $GITHUB_ENV
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
- name: Install dependencies
run: npm ci
- name: Sleep for 10s
uses: juliangruber/sleep-action@v1
with:
time: 10s
- name: Run the tests
run: npm run test
- name: Start the development server
run: |
npm run dev &
echo "Development server started..."
- name: Check server status
run: |
if curl -f 'http://localhost:4000' | jq -e '. == {"talawa-version":"v1","status":"healthy"}' > /dev/null; then
echo "Server is up and healthy"
else
echo "Server is down"
exit 1
fi
- name: Check Apollo Server status
run: |
if curl -f 'http://localhost:4000/graphql?query=%7B__typename%7D' \
-H 'Apollo-Require-Preflight: true' | jq -e '. == {"data":{"__typename":"Query"}}' > /dev/null; then
echo "Apollo Server is up"
else
echo "Server is down"
exit 1
fi
- name: Import Sample Data
run: npm run import:sample-data
- 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: 95.0
JSDocs:
name: 'JSDocs comments and pipeline'
runs-on: ubuntu-latest
needs: Test-Application
steps:
- uses: actions/checkout@v4
- name: 'Check whether comments exists for JSDocs'
run: |
chmod +x ./.github/workflows/check-jsdocs-comment.py
./.github/workflows/check-jsdocs-comment.py
- name: 'Run JSDocs'
if: env.RUN_JSDOCS == 'True'
run: echo "Run JSdocs :${{ env.RUN_JSDOCS }}"
Branch-check:
name: "Base branch check"
runs-on: ubuntu-latest
steps:
- name: "Check if base branch is develop"
if: github.event.pull_request.base.ref != 'develop'
run: |
echo "PR is not against develop branch. Please refer PR_GUIDELINES.md"
exit 1