-
Notifications
You must be signed in to change notification settings - Fork 3
120 lines (99 loc) · 3.01 KB
/
ci.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
name: CI
on:
pull_request:
types: [opened, edited, synchronize]
push:
branches:
- main
- 'release/*'
- 'develop/*'
- 'feature/*'
jobs:
lint:
name: Lint Codebase
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install dependencies
run: npm install
- name: Run ESLint
run: npm run lint
test:
name: Run Tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14, 16, 18]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install
- name: Run Tests
run: npm test
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install dependencies
run: npm install
- name: Run npm audit
run: npm audit --audit-level=moderate
pr-template-check:
name: Validate PR Template Compliance
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Fetch PR Description
id: pr
run: echo "PR_BODY=$(gh pr view ${{ github.event.pull_request.number }} --json body --jq '.body')" >> $GITHUB_ENV
- name: Fetch PR Template
id: pr_template
run: |
TEMPLATE_PATH=$(find .github -name "PULL_REQUEST_TEMPLATE.md")
echo "PR_TEMPLATE=$(cat $TEMPLATE_PATH)" >> $GITHUB_ENV
- name: Compare PR Description with Template
run: |
if [[ "${{ env.PR_BODY }}" == "${{ env.PR_TEMPLATE }}" ]]; then
echo "PR description is too similar to the template. Please provide more detailed information."
exit 1
else
echo "PR description differs from the template."
fi
- name: Fail if PR description is empty
run: |
if [[ -z "${{ env.PR_BODY }}" ]]; then
echo "PR description is empty. Please provide a detailed description."
exit 1
fi
- name: Check if PR is ready for review
run: |
if [[ "${{ github.event.pull_request.draft }}" == "true" ]]; then
echo "PR is still a draft. Please mark it as ready for review when done."
exit 1
fi
- name: Complete PR template check
run: echo "PR template compliance check completed successfully."