|
1 | 1 | on: |
2 | | - # Elements that trigger the workflow |
3 | 2 | push: |
4 | 3 | branches: |
5 | | - - '*' # Runs on all branches |
| 4 | + - "*" # Runs on all branches |
6 | 5 | pull_request: |
7 | 6 | branches: |
8 | | - - '*' # Runs on all branches |
| 7 | + - "*" # Runs on all branches |
9 | 8 |
|
10 | 9 | jobs: |
11 | | - # Define a job "build" |
12 | 10 | build: |
13 | 11 | runs-on: ubuntu-latest |
14 | 12 |
|
15 | | - |
16 | 13 | steps: |
17 | | - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
18 | 14 | - name: Checkout code |
19 | 15 | uses: actions/checkout@v2 |
| 16 | + with: |
| 17 | + fetch-depth: 0 # Required for SonarQube analysis |
20 | 18 |
|
21 | | - # set up express server |
22 | 19 | - name: Set up Node.js |
23 | 20 | uses: actions/setup-node@v2 |
24 | 21 | with: |
25 | | - node-version: '18' |
| 22 | + node-version: "18" |
26 | 23 |
|
27 | | - # Inject environment variables (MongoDB Atlas & Firebase connections) |
28 | 24 | - name: Create .env file |
29 | 25 | run: | |
30 | 26 | echo "DB_CONN_STRING=${{ secrets.DB_CONN_STRING }}" >> chathaven/.env |
31 | 27 | echo "DB_NAME=chatHavenDB" >> chathaven/.env |
32 | 28 | echo "PORT=3000" >> chathaven/.env |
33 | 29 | echo "FIREBASE_API_KEY=${{ secrets.FIREBASE_API_KEY }}" >> chathaven/.env |
34 | | - echo "GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY }}" >> chathaven/.env # Add this line |
| 30 | + echo "GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY }}" >> chathaven/.env |
35 | 31 |
|
36 | | - # Install backend dependencies |
37 | 32 | - name: Install backend dependencies |
38 | 33 | working-directory: ./chathaven/backend |
39 | 34 | run: npm ci |
40 | 35 |
|
41 | | - # Install frontend dependencies |
42 | 36 | - name: Install frontend dependencies |
43 | 37 | working-directory: ./chathaven/frontend |
44 | 38 | run: npm ci |
45 | 39 |
|
46 | | - # # Run backend tests |
47 | 40 | - name: Run Jest Unit Tests |
48 | 41 | working-directory: ./chathaven/backend |
49 | 42 | run: npm test |
| 43 | + |
| 44 | + - name: SonarQube Scan |
| 45 | + uses: SonarSource/sonarqube-scan-action@v5 |
| 46 | + with: |
| 47 | + projectBaseDir: ./chathaven/backend |
| 48 | + env: |
| 49 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 50 | + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} |
0 commit comments