Skip to content

Commit 0e25ab2

Browse files
authored
Merge pull request #3 from secure-dashboards/feat/add-ci
2 parents cebe726 + 5d6c4eb commit 0e25ab2

File tree

9 files changed

+7023
-271
lines changed

9 files changed

+7023
-271
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
services:
16+
postgres:
17+
image: postgres:17.2
18+
env:
19+
POSTGRES_DB: dashboard
20+
POSTGRES_USER: openjs
21+
POSTGRES_PASSWORD: password
22+
ports:
23+
- 5432:5432
24+
options: >-
25+
--health-cmd="pg_isready -U openjs"
26+
--health-interval=10s
27+
--health-timeout=5s
28+
--health-retries=5
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v3
33+
34+
- name: Set up Node.js
35+
uses: actions/setup-node@v3
36+
with:
37+
node-version: '22'
38+
39+
- name: Install dependencies
40+
run: npm install
41+
42+
- name: Lint files
43+
run: npm run lint
44+
45+
- name: Run migrations
46+
run: npm run db:migrate
47+
48+
- name: Seed database
49+
run: npm run db:seed
50+
51+
- name: Run tests
52+
run: npm test

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,34 @@ To seed the database with initial data, use the following command:
5454
npm run db:seed
5555
```
5656

57+
## Linting
58+
59+
To lint the files, use the following command:
60+
61+
```bash
62+
npm run lint
63+
```
64+
65+
To automatically fix linting issues, use the following command:
66+
67+
```bash
68+
npm run lint:fix
69+
```
70+
71+
## Running Tests
72+
73+
To run the tests, use the following command:
74+
75+
```bash
76+
npm test
77+
```
78+
79+
To run the tests with coverage, use the following command:
80+
81+
```bash
82+
npm run test:coverage
83+
```
84+
5785
## License
5886

5987
This project is licensed under the MIT License. See the [LICENSE](/LICENSE) file for details.

__tests__/index.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('Demo test', () => {
2+
it('should pass', () => {
3+
expect(1 + 1).toBe(2)
4+
})
5+
})

knexfile.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
const { normalizeBoolean } = require("@ulisesgascon/normalize-boolean");
1+
const { normalizeBoolean } = require('@ulisesgascon/normalize-boolean')
22
const dbSettings = {
3-
client: 'pg',
4-
connection: {
5-
host: process.env.DB_HOST || '0.0.0.0',
6-
user: process.env.DB_USER || 'openjs',
7-
password: process.env.DB_PASSWORD || 'password',
8-
database: process.env.DB_NAME || 'dashboard',
9-
},
10-
ssl: normalizeBoolean(process.env.DB_SSL),
11-
pool: {
12-
min: 2,
13-
max: 10
14-
},
15-
migrations: {
16-
directory: './src/database/migrations'
17-
},
18-
seeds: {
19-
directory: './src/database/seeds'
20-
}
3+
client: 'pg',
4+
connection: {
5+
host: process.env.DB_HOST || '0.0.0.0',
6+
user: process.env.DB_USER || 'openjs',
7+
password: process.env.DB_PASSWORD || 'password',
8+
database: process.env.DB_NAME || 'dashboard'
9+
},
10+
ssl: normalizeBoolean(process.env.DB_SSL),
11+
pool: {
12+
min: 2,
13+
max: 10
14+
},
15+
migrations: {
16+
directory: './src/database/migrations'
17+
},
18+
seeds: {
19+
directory: './src/database/seeds'
20+
}
2121
}
2222

2323
module.exports = {
24-
development: dbSettings
25-
}
24+
development: dbSettings
25+
}

0 commit comments

Comments
 (0)