-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (91 loc) · 2.74 KB
/
ci.yaml
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
name: CI/CD collab_api
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
jobs:
build-test:
runs-on: ubuntu-latest
services:
testdb:
image: mariadb:latest
env:
MYSQL_ROOT_PASSWORD: toto
MYSQL_DATABASE: dtc
MYSQL_PASSWORD: toto
ports:
- 3341:3306
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
# - name: Log environment variables
# run: |
# echo "DB_DATABASE: ${{ secrets.DB_DATABASE }}"
# echo "DB_USERNAME: ${{ secrets.DB_USERNAME }}"
# echo "DB_PASSWORD: ${{ secrets.DB_PASSWORD }}"
# echo "DB_HOST: ${{ secrets.DB_HOST }}"
- name: Run tests
env:
DB_APP_DATABASE: "dtc"
DB_APP_USERNAME: "root"
DB_APP_PASSWORD: "toto"
DB_APP_HOST: localhost
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
run: npm run test
- name: Start server
run: node server.js &
env:
DB_APP_DATABASE: "dtc"
DB_APP_USERNAME: "root"
DB_APP_PASSWORD: "toto"
DB_APP_HOST: localhost
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
- name: Install Newman
run: npm install -g newman
- name: Run Postman Collection
run: newman run tests/postman/collabdb.postman_collection.json
- name: Stop server
run: pkill node
docker:
runs-on: ubuntu-latest
needs: build-test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/collab_api-app:latest
sonarqube:
name: SonarQube
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: SonarQube Scan
uses: SonarSource/[email protected]
env:
SONAR_TOKEN: ${{ secrets.SONARTOKEN }}