-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (120 loc) · 4.09 KB
/
ci-cd.test.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
# name: CI/CD Test Pipeline
# on:
# push:
# branches:
# - test
# pull_request:
# branches:
# - test
# env:
# ENVIRONMENT: test
# DATABASE_URL: ${{ secrets.TEST_DATABASE_URL }}
# NEXTAUTH_SECRET: ${{ secrets.TEST_NEXTAUTH_SECRET }}
# NEXT_PUBLIC_SITE_URL: http://test.ismail-mouyahada.com
# NEXT_PUBLIC_SOCKET_URL: ws://test-socket.ismail-mouyahada.com
# jobs:
# deps-vulnerability:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Install dependencies
# run: npm install
# - name: Run dependency vulnerability scan
# uses: advanced-security/npm-audit-action@v1
# lint:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Install dependencies
# run: npm install
# - name: Run Linting
# run: npm run lint
# unit-tests:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Install dependencies
# run: npm install
# - name: Run Jest Unit Tests
# run: npm run test:watch
# codecov:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Install dependencies
# run: npm install
# - name: Run tests and generate coverage report
# run: npm run test -- --coverage
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# security:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Run security analysis
# uses: github/codeql-action/analyze@v2
# lighthouse:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Install dependencies
# run: npm install
# - name: Run Lighthouse CI
# run: npx lhci autorun
# docker-build:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Login to GitHub Container Registry
# run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# - name: Build Docker image
# run: docker build -t ghcr.io/ismail-mouyahada/sat-square:test-${{ github.sha }} -f Dockerfile.test .
# - name: Scan Docker image for vulnerabilities
# uses: aquasecurity/[email protected]
# with:
# image-ref: ghcr.io/ismail-mouyahada/sat-square:test-${{ github.sha }}
# - name: Push Docker image to GitHub Container Registry
# run: docker push ghcr.io/ismail-mouyahada/sat-square:test-${{ github.sha }}
# e2e-tests:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Install dependencies
# run: npm install
# - name: Run end-to-end tests
# run: npm run test:e2e
# stress-test:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Install dependencies
# run: npm install
# - name: Run stress tests
# run: npm run test:stress
# notify:
# runs-on: ubuntu-latest
# needs: [deps-vulnerability, lint, unit-tests, codecov, security, lighthouse, docker-build, e2e-tests, stress-test]
# steps:
# - name: Send Discord notification on success
# if: success()
# run: |
# curl -X POST -H "Content-Type: application/json" \
# -d '{"content": "CI/CD Test Pipeline succeeded!"}' \
# ${{ secrets.DISCORD_WEBHOOK_URL }}
# - name: Send Discord notification on failure
# if: failure()
# run: |
# curl -X POST -H "Content-Type: application/json" \
# -d '{"content": "CI/CD Test Pipeline failed!"}' \
# ${{ secrets.DISCORD_WEBHOOK_URL }}